diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..dc7a9ec --- /dev/null +++ b/init.lua @@ -0,0 +1,68 @@ +local awful = require "awful" +local wibox = require("wibox") +local gears = require("gears") +local beautiful = require("beautiful") +local powermenu = { + buttonsize = 128, + spacing = 5, + iconPath = gears.filesystem.get_configuration_dir() .. "/powermenu/", + lock = function() + error("Lock requested, but no function specified") + end, + suspend = function() + error("Suspend requested, but no function specified") + end, + poweroff = function() + error("Power off requested, but no function specified") + end, +} + +function powermenu.new() + local powermenuWidget = wibox.widget{ + layout = wibox.layout.grid.vertical(2), + spacing = powermenu.spacing, + } + local powermenuPopup = awful.popup{ + layout = wibox.layout.fixed.vertical, +-- widget = wibox.container.constraint(powermenuWidget, "min", 512, 512), + widget = powermenuWidget, + border_color = beautiful.border_focus, + border_width = 2, + ontop = true, + placement = awful.placement.centered, + visible = false, + } + local function addButton(icon, fn) + local newButton = awful.widget.button{ + 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() + powermenuPopup:hide() + 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) + + function powermenuPopup.show(self) + self.visible = true + end + function powermenuPopup.hide(self) + self.visible = false + end + function powermenuPopup.toggle(self) + self.visible = not self.visible + end + return powermenuPopup +end + +return powermenu diff --git a/lock.png b/lock.png new file mode 100644 index 0000000..d2abd27 Binary files /dev/null and b/lock.png differ diff --git a/poweroff.png b/poweroff.png new file mode 100644 index 0000000..9159995 Binary files /dev/null and b/poweroff.png differ diff --git a/restart.png b/restart.png new file mode 100644 index 0000000..520a63b Binary files /dev/null and b/restart.png differ diff --git a/suspend.png b/suspend.png new file mode 100644 index 0000000..db8f04b Binary files /dev/null and b/suspend.png differ