delta
f42a3a2cc9
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 <darkussdelta@gmail.com>
124 lines
3 KiB
Lua
124 lines
3 KiB
Lua
local awful = require "awful"
|
|
local gtable = require "gears.table"
|
|
local qbind = require "quarrel.bind"
|
|
local qvars = require "quarrel.vars"
|
|
local wibox = require "wibox"
|
|
|
|
local qui = {}
|
|
|
|
function qui.markup_fg(color, text)
|
|
return "<span color=\"" .. color .. "\">" .. text .. "</span>"
|
|
end
|
|
|
|
function qui.markup_bg(color, text)
|
|
return "<span bgcolor=\"" .. color .. "\">" .. text .. "</span>"
|
|
end
|
|
|
|
function qui.font(factor)
|
|
return qvars.text_font .. " " .. qvars.font_size * (factor or 1)
|
|
end
|
|
|
|
function qui.styled(target)
|
|
return gtable.crush({
|
|
bg = qvars.colors.bg,
|
|
border_color = qvars.colors.bright.black,
|
|
border_width = qvars.border_width,
|
|
shape = qvars.shape
|
|
}, target)
|
|
end
|
|
|
|
function qui.popup(target)
|
|
target.widget = {
|
|
widget = wibox.container.margin,
|
|
margins = qvars.big_padding,
|
|
target.widget
|
|
}
|
|
|
|
return awful.popup(qui.styled(target))
|
|
end
|
|
|
|
function qui.tooltip(objects, callback)
|
|
awful.tooltip(qui.styled {
|
|
objects = objects,
|
|
timer_function = callback,
|
|
margin_leftright = qvars.padding,
|
|
margin_topbottom = qvars.padding
|
|
})
|
|
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
|