summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgaberm <gaberm@gmail.com>2020-11-23 21:03:06 +0200
committergaberm <gaberm@gmail.com>2020-11-23 21:03:06 +0200
commit5dbfab72489a06348cf332461ae8ceef592b6085 (patch)
treee80f0317fce26532ea750324cb22c75144211ef4
parent0e1d31ad6f5663d4f56bd02ecb01b58fe6f162e1 (diff)
added icon to mpris popup
-rw-r--r--mpris-widget/init.lua35
1 files changed, 26 insertions, 9 deletions
diff --git a/mpris-widget/init.lua b/mpris-widget/init.lua
index e18edf5..1fe47ae 100644
--- a/mpris-widget/init.lua
+++ b/mpris-widget/init.lua
@@ -13,7 +13,7 @@ local wibox = require("wibox")
local naughty = require("naughty")
local GET_MPD_CMD =
- "playerctl -f '{{status}};{{xesam:artist}};{{xesam:title}}' metadata"
+ "playerctl -f '{{status}};{{xesam:artist}};{{xesam:title}};{{mpris:artUrl}}' metadata"
local TOGGLE_MPD_CMD = "playerctl play-pause"
local PAUSE_MPD_CMD = "playerctl pause"
@@ -28,7 +28,7 @@ local STOP_ICON_NAME = PATH_TO_ICONS .. "/actions/24/player_stop.png"
local LIBRARY_ICON_NAME = PATH_TO_ICONS .. "/actions/24/music-library.png"
-- retriving song info
-current_song, artist = nil, nil
+current_song, artist, artUrl = nil, nil, nil
local icon = wibox.widget {
id = "icon",
@@ -59,13 +59,26 @@ local mpdarc_current_song_widget = wibox.widget {
}
local update_graphic = function(widget, stdout, _, _, _)
- mpdstatus, artist, current_song = stdout:match("(%w+)%;+(.-)%;(.*)")
+ -- mpdstatus, artist, current_song = stdout:match("(%w+)%;+(.-)%;(.*)")
+ local words = {}
+ for w in stdout:gmatch("([^;]*)") do
+ print(w)
+ table.insert(words, w)
+ end
+
+ mpdstatus = words[1]
+ current_song = words[2]
+ artist = words[3]
+ local art = words[4]
+
if current_song ~= nil then
- if current_song.len == 18 then
- current_song = string.sub(current_song, 0, 9) .. ".."
+ if string.len(current_song) > 18 then
+ current_song = string.sub(current_song, 0, 12) .. " .."
end
end
+ if art ~= nil then artUrl = string.sub(art, 8, -1) end
+
if mpdstatus == "Playing" then
mpdarc_icon_widget.visible = true
icon.image = PLAY_ICON_NAME
@@ -106,16 +119,20 @@ mpdarc:connect_signal("button::press", function(_, _, _, button)
end)
end)
-local notification
+-- local notification
function show_MPD_status()
spawn.easy_async(GET_MPD_CMD, function(stdout, _, _, _)
notification = naughty.notify {
- text = current_song .. " by " .. artist,
+ margin = 5,
title = mpdstatus,
+ -- position = "top_left",
+ width = 440,
+ height = 120,
+ text = current_song .. " by " .. artist,
timeout = 5,
hover_timeout = 0.5,
- width = 600
- }
+ image = artUrl
+ };
end)
end