mpris-widget: make play/pause icon work

The middle part of mpris_widget was meant to be a play/pause icon. It
only displayed a circle, as an unrelated widget that was not shown was
set up and modified according to the play state. Delete the invisible
widget, add the icon where it should be.
This commit is contained in:
Romanos Skiadas 2021-10-15 18:34:09 +03:00
parent aacbf61fac
commit 567b5bb84f
1 changed files with 7 additions and 27 deletions

View File

@ -28,12 +28,19 @@ local LIBRARY_ICON_NAME = PATH_TO_ICONS .. "/actions/24/music-library.png"
local default_player = '' local default_player = ''
local icon = wibox.widget {
id = "icon",
widget = wibox.widget.imagebox,
image = PLAY_ICON_NAME
}
local mpris_widget = wibox.widget{ local mpris_widget = wibox.widget{
{ {
id = 'artist', id = 'artist',
widget = wibox.widget.textbox widget = wibox.widget.textbox
}, },
{ {
icon,
max_value = 1, max_value = 1,
value = 0, value = 0,
thickness = 2, thickness = 2,
@ -130,29 +137,6 @@ local function worker()
-- retrieve song info -- retrieve song info
local current_song, artist, player_status, art, artUrl local current_song, artist, player_status, art, artUrl
local icon = wibox.widget {
id = "icon",
widget = wibox.widget.imagebox,
image = PLAY_ICON_NAME
}
local mirrored_icon = wibox.container.mirror(icon, {horizontal = true})
local mpdarc = wibox.widget {
mirrored_icon,
-- max_value = 1,
-- value = 0,
thickness = 2,
start_angle = 4.71238898, -- 2pi*3/4
forced_height = 24,
forced_width = 24,
rounded_edge = true,
bg = "#ffffff11",
paddings = 0,
widget = wibox.container.arcchart
}
local mpdarc_icon_widget = wibox.container.mirror(mpdarc, {horizontal = true})
local update_graphic = function(widget, stdout, _, _, _) local update_graphic = function(widget, stdout, _, _, _)
local words = {} local words = {}
for w in stdout:gmatch("([^;]*);") do table.insert(words, w) end for w in stdout:gmatch("([^;]*);") do table.insert(words, w) end
@ -170,21 +154,17 @@ local function worker()
if art ~= nil then artUrl = string.sub(art, 8, -1) end if art ~= nil then artUrl = string.sub(art, 8, -1) end
if player_status == "Playing" then if player_status == "Playing" then
mpdarc_icon_widget.visible = true
icon.image = PLAY_ICON_NAME icon.image = PLAY_ICON_NAME
widget.colors = {beautiful.widget_main_color} widget.colors = {beautiful.widget_main_color}
widget:set_text(artist, current_song) widget:set_text(artist, current_song)
elseif player_status == "Paused" then elseif player_status == "Paused" then
mpdarc_icon_widget.visible = true
icon.image = PAUSE_ICON_NAME icon.image = PAUSE_ICON_NAME
widget.colors = {beautiful.widget_main_color} widget.colors = {beautiful.widget_main_color}
widget:set_text(artist, current_song) widget:set_text(artist, current_song)
elseif player_status == "Stopped" then elseif player_status == "Stopped" then
mpdarc_icon_widget.visible = true
icon.image = STOP_ICON_NAME icon.image = STOP_ICON_NAME
else -- no player is running else -- no player is running
icon.image = LIBRARY_ICON_NAME icon.image = LIBRARY_ICON_NAME
mpdarc_icon_widget.visible = false
widget.colors = {beautiful.widget_red} widget.colors = {beautiful.widget_red}
end end
end end