From f42a3a2cc941e34dd938b1e6bc24785a44781db2 Mon Sep 17 00:00:00 2001 From: delta Date: Sun, 21 May 2023 10:12:46 +0200 Subject: major update of awesome config add new icons, switch over to using stylesheets instead of gears.color.recolor_image, add a music widget to the panel, optimize services in common.lua, fix the application lense filtering and increase the update rate of services in common.lua Signed-off-by: delta --- .config/awesome/quarrel/ui.lua | 91 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 81 insertions(+), 10 deletions(-) (limited to '.config/awesome/quarrel/ui.lua') diff --git a/.config/awesome/quarrel/ui.lua b/.config/awesome/quarrel/ui.lua index 8e979cb..274d48a 100644 --- a/.config/awesome/quarrel/ui.lua +++ b/.config/awesome/quarrel/ui.lua @@ -1,5 +1,6 @@ local awful = require "awful" -local gears = require "gears" +local gtable = require "gears.table" +local qbind = require "quarrel.bind" local qvars = require "quarrel.vars" local wibox = require "wibox" @@ -17,12 +18,8 @@ function qui.font(factor) return qvars.text_font .. " " .. qvars.font_size * (factor or 1) end -function qui.symbol_font(factor) - return qvars.symbol_font .. " " .. qvars.font_size * (factor or 1) -end - function qui.styled(target) - return gears.table.crush({ + return gtable.crush({ bg = qvars.colors.bg, border_color = qvars.colors.bright.black, border_width = qvars.border_width, @@ -30,14 +27,14 @@ function qui.styled(target) }, target) end -function qui.popup(args) - args.widget = { +function qui.popup(target) + target.widget = { widget = wibox.container.margin, margins = qvars.big_padding, - args.widget + target.widget } - return awful.popup(qui.styled(args)) + return awful.popup(qui.styled(target)) end function qui.tooltip(objects, callback) @@ -49,4 +46,78 @@ function qui.tooltip(objects, callback) }) end +function qui.recolor(color) + return "svg{fill:" .. color .. "}" +end + +function qui.icon(image, color, target) + local widget = { + widget = wibox.widget.imagebox, + image = image, + forced_width = qvars.char_height, + forced_height = qvars.char_height, + stylesheet = qui.recolor(color or qvars.colors.fg) + } + if target then + return gtable.crush(widget, target) + else + return widget + end +end + +function qui.button(args) + args.press = args.press or function(_) end + local widget = wibox.widget(gtable.crush({ + widget = wibox.widget.imagebox, + image = args.image, + forced_height = qvars.char_height, + forced_width = qvars.char_height, + stylesheet = qui.recolor(qvars.colors.fg), + press = args.press + }, args.widget or {})) + + widget.buttons = { + qbind:new { + triggers = qvars.btns.left, + press = function() + widget:press() + end, + hidden = true + } + } + + return widget +end + +function qui.toggle(args) + args.press = args.press or function(_) end + local widget = qui.button({ + widget = gtable.crush({ + toggled = false, + silent_press = function(self, state) + if state then + self.toggled = state + else + self.toggled = not self.toggled + end + + if self.toggled then + self.image = args.on + else + self.image = args.off + end + end, + }, args.widget or {}), + image = args.off, + press = function(self) + if not args.manual then + self:silent_press() + end + args.press(self) + end + }) + + return widget +end + return qui -- cgit v1.2.3