import power menu

This commit is contained in:
Izaya 2022-03-04 09:57:59 +11:00
parent 7eeb920ca1
commit e572e841d8
5 changed files with 68 additions and 0 deletions

68
init.lua Normal file
View File

@ -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

BIN
lock.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
poweroff.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

BIN
restart.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.9 KiB

BIN
suspend.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB