diff options
Diffstat (limited to '.config/awesome/ui/powermenu')
-rw-r--r-- | .config/awesome/ui/powermenu/init.lua | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/.config/awesome/ui/powermenu/init.lua b/.config/awesome/ui/powermenu/init.lua new file mode 100644 index 0000000..81d2ea3 --- /dev/null +++ b/.config/awesome/ui/powermenu/init.lua @@ -0,0 +1,114 @@ +local awful = require "awful" +local phosphor = require "assets.phosphor" +local qui = require "quarrel.ui" +local qvars = require "quarrel.vars" +local rubato = require "lib.rubato" +local wibox = require "wibox" + +local function create_button(title, icon, color, exec) + return wibox.widget { + widget = wibox.container.background, + shape = qvars.shape, + { + widget = wibox.container.margin, + margins = qvars.big_padding, + { + qui.styled { + widget = wibox.container.background, + border_color = color, + { + widget = wibox.container.margin, + margins = qvars.big_padding, + qui.icon { + widget = { + forced_height = qvars.char_height * 4 - qvars.big_padding * 2, + forced_width = qvars.char_height * 4 - qvars.big_padding * 2, + }, + icon = icon, + color = color, + }, + }, + }, + { + widget = wibox.container.place, + { + widget = wibox.widget.textbox, + text = title, + }, + }, + layout = wibox.layout.fixed.vertical, + spacing = qvars.big_padding, + exec = exec, + }, + }, + select = function(self) + self.bg = qvars.colors.black + end, + } +end + +local powermenu = {} +local toggled = false + +screen.connect_signal("request::desktop_decoration", function(s) + powermenu._widget = qui.popup { + ontop = true, + visible = false, + minimum_width = s.geometry.width, + minimum_height = s.geometry.height, + bg = qvars.colors.bg .. "ee", + border_width = 0, + widget = { + widget = wibox.container.place, + qui.styled { + widget = wibox.container.background, + { + widget = wibox.container.margin, + margins = qvars.big_padding, + { + layout = wibox.layout.fixed.horizontal, + spacing = qvars.big_padding * 2, + id = "list", + }, + }, + }, + }, + } + + local layout = powermenu._widget.widget:get_children_by_id("list")[1] + + layout:add(create_button("Shutdown", phosphor.power_bold, qvars.colors.red, function() + awful.spawn "poweroff" + end)) + layout:add(create_button("Log out", phosphor.sign_out_bold, qvars.colors.green, function() + awesome.quit() + end)) + layout:add(create_button("Lock", phosphor.lock_simple_fill, qvars.colors.blue, function() + require("quarrel").debug "locked!l" + end)) + layout:add(create_button("Restart", phosphor.arrow_clockwise_bold, qvars.colors.pink, function() + awful.spawn "reboot" + end)) +end) + +local timed = rubato.timed { + duration = qvars.anim_duration, + intro = qvars.anim_intro, + pos = 0, + subscribed = function(pos) + powermenu._widget.opacity = pos + + if pos == 0 then + powermenu._widget.visible = false + else + powermenu._widget.visible = true + end + end, +} + +function powermenu:toggle() + timed.target = toggled and 0 or 1 + toggled = not toggled +end + +return powermenu |