local awful = require "awful" local phosphor = require "assets.phosphor" local qcolor = require "quarrel.color" 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 = qui.shape, { widget = wibox.container.margin, margins = qui.BIG_PADDING, { qui.styled { widget = wibox.container.background, border_color = color, { widget = wibox.container.margin, margins = qui.BIG_PADDING, qui.icon { widget = { forced_height = qui.CHAR_HEIGHT * 4 - qui.BIG_PADDING * 2, forced_width = qui.CHAR_HEIGHT * 4 - qui.BIG_PADDING * 2, }, icon = icon, color = color, }, }, }, { widget = wibox.container.place, { widget = wibox.widget.textbox, text = title, }, }, layout = wibox.layout.fixed.vertical, spacing = qui.BIG_PADDING, exec = exec, }, }, select = function(self) self.bg = qcolor.palette.bg.high 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 = qcolor.palette.bg() .. "ee", border_width = 0, widget = { widget = wibox.container.place, qui.styled { widget = wibox.container.background, { widget = wibox.container.margin, margins = qui.BIG_PADDING, { layout = wibox.layout.fixed.horizontal, spacing = qui.BIG_PADDING * 2, id = "list", }, }, }, }, } local layout = powermenu._widget.widget:get_children_by_id("list")[1] layout:add(create_button("Shutdown", phosphor.power_bold, qcolor.palette.red(), function() awful.spawn "poweroff" end)) layout:add(create_button("Log out", phosphor.sign_out_bold, qcolor.palette.green(), function() awesome.quit() end)) layout:add(create_button("Lock", phosphor.lock_simple_fill, qcolor.palette.blue(), function() require("quarrel").debug "locked!l" end)) layout:add(create_button("Restart", phosphor.arrow_clockwise_bold, qcolor.palette.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