summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRomanos Skiadas <rom.skiad@gmail.com>2021-10-16 09:56:12 +0300
committerRomanos Skiadas <rom.skiad@gmail.com>2021-10-16 09:59:03 +0300
commit4bc22fbb70fc50d402dacd3bdabbc2f405def9ff (patch)
tree9e8a8dc6a4dd5dcef7f00cd9fd06995766d07d2e
parentca085289269122da468dd123edb8cd4a0144dc59 (diff)
mpris-widget: delete on mouse::enter code
this code is janky, because the notification is set asynchronously, it can end up not being cleaned by the mouse exit and then you can end up with multiple ones. Also, the image field of the table needs to be icon, but if the icon is an http url like some players print or even a local file like firefox does, setting the icon causes an error as it can't be read.
-rw-r--r--mpris-widget/init.lua30
1 files changed, 2 insertions, 28 deletions
diff --git a/mpris-widget/init.lua b/mpris-widget/init.lua
index c9fa723..5e45ffa 100644
--- a/mpris-widget/init.lua
+++ b/mpris-widget/init.lua
@@ -7,13 +7,11 @@
-------------------------------------------------
local awful = require("awful")
local beautiful = require("beautiful")
-local spawn = require("awful.spawn")
local watch = require("awful.widget.watch")
local wibox = require("wibox")
-local naughty = require("naughty")
local gears = require("gears")
-local GET_MPD_CMD = "playerctl -p %s -f '{{status}};{{xesam:artist}};{{xesam:title}};{{mpris:artUrl}}' metadata"
+local GET_MPD_CMD = "playerctl -p %s -f '{{status}};{{xesam:artist}};{{xesam:title}}' metadata"
local TOGGLE_MPD_CMD = "playerctl play-pause"
local NEXT_MPD_CMD = "playerctl next"
@@ -135,14 +133,13 @@ end
local function worker()
-- retrieve song info
- local current_song, artist, player_status, artUrl
+ local current_song, artist, player_status
local update_graphic = function(widget, stdout, _, _, _)
local words = gears.string.split(stdout, ';')
player_status = words[1]
artist = words[2]
current_song = words[3]
- artUrl = words[4]
if current_song ~= nil then
if string.len(current_song) > 18 then
current_song = string.sub(current_song, 0, 9) .. ".."
@@ -181,29 +178,6 @@ local function worker()
)
)
-
-
- local notification
- local function show_status()
- spawn.easy_async(GET_MPD_CMD, function()
- notification = naughty.notify {
- margin = 10,
- timeout = 5,
- hover_timeout = 0.5,
- width = 240,
- height = 90,
- title = player_status,
- text = current_song .. " - " .. artist,
- image = artUrl
- }
- end)
- end
-
- mpris_widget:connect_signal("mouse::enter", function()
- if current_song ~= nil and artist ~= nil then show_status() end
- end)
- mpris_widget:connect_signal("mouse::leave", function() naughty.destroy(notification) end)
-
watch(string.format(GET_MPD_CMD, "'" .. default_player .. "'"), 1, update_graphic, mpris_widget)
return mpris_widget