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>
201 lines
6.7 KiB
Lua
201 lines
6.7 KiB
Lua
local cairo = require "lgi".cairo
|
|
local gcolor = require "gears.color"
|
|
local gsurface = require "gears.surface"
|
|
local imagebox = require "ui.statusbar.panel.widgets.imagebox"
|
|
local phosphor = require "assets.phosphor"
|
|
local playerctl = require "services.playerctl"
|
|
local qnative = require "quarrel.native"
|
|
local qui = require "quarrel.ui"
|
|
local qvars = require "quarrel.vars"
|
|
local wibox = require "wibox"
|
|
|
|
local default_cover = phosphor.vinyl_record_fill
|
|
local default_text = "Nothing playing"
|
|
|
|
local function faded_cover(cover)
|
|
local surface = gsurface(cover)
|
|
local w,h = gsurface.get_size(surface)
|
|
local cr = cairo.Context(surface)
|
|
local pattern = gcolor(qvars.colors.bg .. "aa")
|
|
cr:rectangle(0, 0, w, h)
|
|
cr:set_source(pattern)
|
|
cr:fill_preserve()
|
|
return surface
|
|
end
|
|
|
|
local w_title = wibox.widget {
|
|
widget = wibox.widget.textbox,
|
|
text = "Nothing playing",
|
|
}
|
|
|
|
local w_artist = wibox.widget {
|
|
widget = wibox.container.background,
|
|
fg = qvars.colors.dim.fg,
|
|
{
|
|
widget = wibox.widget.textbox,
|
|
text = ""
|
|
}
|
|
}
|
|
|
|
local w_cover = wibox.widget {
|
|
widget = imagebox,
|
|
image = default_cover,
|
|
stylesheet = qui.recolor(qvars.colors.bright.black),
|
|
forced_height = qvars.char_height * 6 + qvars.big_padding * 2,
|
|
forced_width = qvars.expanded_bar_size - qvars.big_padding,
|
|
horizontal_fit_policy = "cover",
|
|
vertical_fit_policy = "cover",
|
|
valign = "center",
|
|
halign = "center"
|
|
}
|
|
|
|
local w_progress_bar = wibox.widget {
|
|
widget = wibox.widget.progressbar,
|
|
max_value = 0,
|
|
value = 0,
|
|
forced_height = qvars.char_height / 2,
|
|
forced_width = qvars.expanded_bar_size - (qvars.big_padding + qvars.big_padding * 2 + qvars.padding * 2) - (qvars.char_height / 1.25 + qvars.padding) * 3,
|
|
color = qvars.colors.yellow,
|
|
background_color = qvars.colors.black,
|
|
shape = qvars.shape,
|
|
}
|
|
|
|
local w_play_pause = qui.toggle {
|
|
widget = {
|
|
forced_height = qvars.char_height / 1.25,
|
|
forced_width = qvars.char_height / 1.25
|
|
},
|
|
off = phosphor.play_fill,
|
|
on = phosphor.pause_fill,
|
|
manual = true,
|
|
press = function()
|
|
playerctl:play_pause()
|
|
end
|
|
}
|
|
|
|
local w_skip_forward = qui.button {
|
|
widget = {
|
|
forced_height = qvars.char_height / 1.25,
|
|
forced_width = qvars.char_height / 1.25
|
|
},
|
|
image = phosphor.skip_forward_fill,
|
|
press = function()
|
|
playerctl:next()
|
|
end
|
|
}
|
|
|
|
local w_skip_back = qui.button {
|
|
widget = {
|
|
forced_height = qvars.char_height / 1.25,
|
|
forced_width = qvars.char_height / 1.25
|
|
},
|
|
image = phosphor.skip_back_fill,
|
|
press = function()
|
|
playerctl:previous()
|
|
end
|
|
}
|
|
|
|
local music = wibox.widget(qui.styled {
|
|
widget = wibox.container.background,
|
|
{
|
|
{
|
|
widget = wibox.container.background,
|
|
bg = qvars.colors.black
|
|
},
|
|
w_cover,
|
|
{
|
|
widget = wibox.container.margin,
|
|
margins = qvars.big_padding,
|
|
{
|
|
{
|
|
{
|
|
widget = wibox.container.background,
|
|
bg = qvars.colors.bg,
|
|
shape = qvars.shape,
|
|
{
|
|
widget = wibox.container.margin,
|
|
margins = qvars.padding,
|
|
{
|
|
{
|
|
widget = wibox.container.constraint,
|
|
width = qvars.expanded_bar_size - (qvars.big_padding + qvars.big_padding * 2 + qvars.padding * 2),
|
|
height = qvars.char_height,
|
|
{
|
|
widget = wibox.container.scroll.horizontal,
|
|
speed = 50,
|
|
step_function = wibox.container.scroll.step_functions.waiting_nonlinear_back_and_forth,
|
|
w_title
|
|
}
|
|
},
|
|
{
|
|
widget = wibox.container.constraint,
|
|
width = qvars.expanded_bar_size - (qvars.big_padding + qvars.big_padding * 2 + qvars.padding * 2),
|
|
height = qvars.char_height,
|
|
{
|
|
widget = wibox.container.scroll.horizontal,
|
|
speed = 50,
|
|
step_function = wibox.container.scroll.step_functions.waiting_nonlinear_back_and_forth,
|
|
w_artist
|
|
}
|
|
},
|
|
layout = wibox.layout.fixed.vertical
|
|
}
|
|
}
|
|
},
|
|
nil,
|
|
nil,
|
|
layout = wibox.layout.align.horizontal
|
|
},
|
|
nil,
|
|
{
|
|
widget = wibox.container.background,
|
|
bg = qvars.colors.bg,
|
|
shape = qvars.shape,
|
|
{
|
|
widget = wibox.container.margin,
|
|
margins = qvars.padding,
|
|
{
|
|
w_play_pause,
|
|
w_skip_back,
|
|
{
|
|
widget = wibox.container.place,
|
|
w_progress_bar
|
|
},
|
|
w_skip_forward,
|
|
layout = wibox.layout.fixed.horizontal,
|
|
spacing = qvars.padding
|
|
}
|
|
}
|
|
},
|
|
layout = wibox.layout.align.vertical
|
|
}
|
|
},
|
|
layout = wibox.layout.stack
|
|
}
|
|
})
|
|
|
|
awesome.connect_signal("services::playerctl::metadata", function(title, artist, album_path)
|
|
w_title.text = title ~= "" and qnative.decode_html(title) or default_text
|
|
w_artist.widget.text = qnative.decode_html(artist)
|
|
w_cover.image = faded_cover(album_path)
|
|
end)
|
|
|
|
awesome.connect_signal("services::playerctl::position", function(position, length)
|
|
w_progress_bar.value = position
|
|
w_progress_bar.max_value = length
|
|
end)
|
|
|
|
awesome.connect_signal("services::playerctl::no_players", function()
|
|
w_title = default_text
|
|
w_artist = ""
|
|
w_cover.image = default_cover
|
|
w_progress_bar.value = 0
|
|
w_progress_bar.max_value = 0
|
|
end)
|
|
|
|
awesome.connect_signal("services::playerctl::playback_status", function(playing)
|
|
w_play_pause:silent_press(playing)
|
|
end)
|
|
|
|
return music
|