69 lines
1.8 KiB
Lua
69 lines
1.8 KiB
Lua
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() .. "/awesome-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
|