Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function get_screen_id(s)
- local name = ""
- for i, e in pairs(s.outputs) do
- name = tostring(i)
- end
- return name
- end
- mydisplaymenu = awful.menu({ })
- function display_menu ()
- local current_display = get_screen_id(awful.screen.focused())
- local terms = {}
- local displays = io.popen("xrandr | grep ' connected' | awk {'print $1'}")
- for l in displays:lines() do
- if l ~= current_display then
- local item = l
- table.insert(terms, { current_display .. " <-> " .. item, {
- { "duplicate with " .. item, function() awful.util.spawn("displayexec.sh " .. current_display .. " duplicate " .. item) end },
- {"switch to " .. item, function() awful.util.spawn("displayexec.sh " .. current_display .. " switch " .. item) end },
- {"extend to " .. item, {
- {"left", function() awful.util.spawn("displayexec.sh " .. current_display .. " extend " .. item .. " left") end },
- {"above", function() awful.util.spawn("displayexec.sh " .. current_display .. " extend " .. item .. " above") end },
- {"right", function() awful.util.spawn("displayexec.sh " .. current_display .. " extend " .. item .. " right") end },
- {"below", function() awful.util.spawn("displayexec.sh " .. current_display .. " extend " .. item .. " below") end },
- }}}})
- end
- end
- displays:close()
- mydisplaymenu = awful.menu( { items = terms, theme = { width = 200 }} )
- end
- function display_menu_toggle_fn()
- instance = nil
- return function ()
- if instance and instance.wibox.visible then
- instance:hide()
- instance = nil
- else
- display_menu()
- instance = mydisplaymenu
- mydisplaymenu:update()
- mydisplaymenu:show()
- end
- end
- end
- display_widget = wibox.widget { widget = wibox.widget.textbox }
- display_widget:set_text(" ▢ ")
- display_widget:buttons(gears.table.join(
- awful.button({ }, 1, display_menu_toggle_fn() )
- ))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement