aboutsummaryrefslogtreecommitdiff
path: root/.config/awesome/ui/powermenu/init.lua
diff options
context:
space:
mode:
authordelta <darkussdelta@gmail.com>2024-03-05 14:48:59 +0100
committerdelta <darkussdelta@gmail.com>2024-03-05 14:48:59 +0100
commit510ef8e178929cf5e0c7fd5a5120fecf5f1b79f2 (patch)
tree3582e5cd7d000335ca94f2a009f3aed57bd86919 /.config/awesome/ui/powermenu/init.lua
parent95ba8030f722a616cff06c122dcfb2f63e25cf45 (diff)
idk anymore
Diffstat (limited to '.config/awesome/ui/powermenu/init.lua')
-rw-r--r--.config/awesome/ui/powermenu/init.lua114
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