diff --git a/README.md b/README.md index a3b9144..94569bc 100644 --- a/README.md +++ b/README.md @@ -10,16 +10,19 @@ Simple popup power menu for awesomewm local powermenu = require "awesome-powermenu" ``` -Initialise the menu: +Initialise the menu, for a given screen: ``` -powermenu.new() +awful.screen.connect_for_each_screen(function(s) + ... + s.powermenu = powermenu.new(s) +end ``` Bind it to something: ``` -global_key({modkey}, "p", function() powermenuPopup:toggle() end, +global_key({modkey}, "p", function() awful.screen.focused().powermenu:toggle() end, "show power menu", "launcher") ``` diff --git a/brightness-down.png b/brightness-down.png deleted file mode 100644 index e7de945..0000000 Binary files a/brightness-down.png and /dev/null differ diff --git a/brightness-down.svg b/brightness-down.svg new file mode 100644 index 0000000..1596148 --- /dev/null +++ b/brightness-down.svg @@ -0,0 +1,477 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/brightness-up.png b/brightness-up.png deleted file mode 100644 index 3e8ba33..0000000 Binary files a/brightness-up.png and /dev/null differ diff --git a/brightness-up.svg b/brightness-up.svg new file mode 100644 index 0000000..e2b1042 --- /dev/null +++ b/brightness-up.svg @@ -0,0 +1,510 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/init.lua b/init.lua index 54b80f6..12d7e6b 100644 --- a/init.lua +++ b/init.lua @@ -1,8 +1,8 @@ local awful = require "awful" local wibox = require("wibox") local gears = require("gears") -local naughty = require("naughty") local beautiful = require("beautiful") +local longpress = require("awesome-longpress") local powermenu = { buttonsize = 128, spacing = 5, @@ -13,9 +13,18 @@ local powermenu = { suspend = function() error("Suspend requested, but no function specified") end, + logout = function() + error("Logout requested, but no function specified") + end, poweroff = function() error("Power off requested, but no function specified") end, + reboot = function() + error("Reboot requested, but no function specified") + end, + fullscreen = function(self) + self.screen.navbar.visible = not self.screen.navbar.visible + end, rotateLeft = function() awful.spawn(gears.filesystem.get_configuration_dir() .. "/awesome-powermenu/rotate.lua left") awesome.restart() @@ -70,9 +79,9 @@ local powermenu = { end } -function powermenu.new() +function powermenu.new(s) local powermenuWidget = wibox.widget{ - layout = wibox.layout.grid.vertical(2), + layout = wibox.layout.grid.vertical(3), spacing = powermenu.spacing, } local powermenuPopup = awful.popup{ @@ -83,35 +92,42 @@ function powermenu.new() border_width = 2, ontop = true, placement = awful.placement.centered, + screen = s, visible = false, } - local function addButton(icon, fn, hide) + local function addButton(icon, fn, lfn, hide) if hide == nil then hide = true end local newButton = awful.widget.button{ - image = powermenu.iconPath .. "/" .. icon + image = powermenu.iconPath .. "/" .. icon, } newButton:set_forced_width(powermenu.buttonsize) newButton:set_forced_height(powermenu.buttonsize) - newButton:buttons(gears.table.join( - newButton:buttons(), - awful.button({}, 1, nil, function() - fn() + longpress.add(newButton, + function() + fn(powermenuPopup) if hide then powermenuPopup:hide() end - end) - )) + end, + function() + lfn(powermenuPopup) + if hide then + powermenuPopup:hide() + end + end + ) powermenuWidget:add(newButton) end - addButton("poweroff.png", powermenu.poweroff) - addButton("suspend.png", powermenu.suspend) - addButton("restart.png", awesome.restart) - addButton("lock.png", powermenu.lock) - addButton("rotate-left.png", powermenu.rotateLeft) - addButton("rotate-right.png", powermenu.rotateRight) - addButton("brightness-up.png", powermenu.brightnessUp, false) - addButton("brightness-down.png", powermenu.brightnessDown, false) + addButton("system-log-out.svg", powermenu.logout, powermenu.poweroff) + addButton("system-lock-screen.svg", powermenu.lock) + addButton("system-reboot.svg", awesome.restart, powermenu.reboot) + addButton("object-rotate-left.svg", powermenu.rotateLeft) + addButton("system-suspend.svg", powermenu.suspend) + addButton("object-rotate-right.svg", powermenu.rotateRight) + addButton("brightness-up.svg", powermenu.brightnessUp, nil, false) + addButton("view-fullscreen.svg", powermenu.fullscreen) + addButton("brightness-down.svg", powermenu.brightnessDown, nil, false) function powermenuPopup.show(self) self.visible = true diff --git a/lock.png b/lock.png deleted file mode 100644 index d2abd27..0000000 Binary files a/lock.png and /dev/null differ diff --git a/object-rotate-left.svg b/object-rotate-left.svg new file mode 100644 index 0000000..d5ce1d0 --- /dev/null +++ b/object-rotate-left.svg @@ -0,0 +1,190 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + diff --git a/object-rotate-right.svg b/object-rotate-right.svg new file mode 100644 index 0000000..da43efa --- /dev/null +++ b/object-rotate-right.svg @@ -0,0 +1,189 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + diff --git a/poweroff.png b/poweroff.png deleted file mode 100644 index 9159995..0000000 Binary files a/poweroff.png and /dev/null differ diff --git a/restart.png b/restart.png deleted file mode 100644 index 520a63b..0000000 Binary files a/restart.png and /dev/null differ diff --git a/rotate-left.png b/rotate-left.png deleted file mode 100644 index 9dd2126..0000000 Binary files a/rotate-left.png and /dev/null differ diff --git a/rotate-right.png b/rotate-right.png deleted file mode 100644 index fd391f9..0000000 Binary files a/rotate-right.png and /dev/null differ diff --git a/suspend.png b/suspend.png deleted file mode 100644 index db8f04b..0000000 Binary files a/suspend.png and /dev/null differ diff --git a/system-lock-screen.svg b/system-lock-screen.svg new file mode 100644 index 0000000..5d191e6 --- /dev/null +++ b/system-lock-screen.svg @@ -0,0 +1,203 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + diff --git a/system-log-out.svg b/system-log-out.svg new file mode 100644 index 0000000..e4cdd10 --- /dev/null +++ b/system-log-out.svg @@ -0,0 +1,169 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + diff --git a/system-reboot.svg b/system-reboot.svg new file mode 100644 index 0000000..125a34c --- /dev/null +++ b/system-reboot.svg @@ -0,0 +1,194 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + diff --git a/system-suspend.svg b/system-suspend.svg new file mode 100644 index 0000000..649c085 --- /dev/null +++ b/system-suspend.svg @@ -0,0 +1,198 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + diff --git a/view-fullscreen.svg b/view-fullscreen.svg new file mode 100644 index 0000000..6617c24 --- /dev/null +++ b/view-fullscreen.svg @@ -0,0 +1,204 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + +