From c95ff15ab4eea8d9673fc5f04e665fbcf4ee4421 Mon Sep 17 00:00:00 2001 From: gaberm Date: Mon, 16 Nov 2020 21:38:16 +0200 Subject: adding an mpris widget --- README.md | 13 ++--- mpris-widget/README.md | 26 ++++++++++ mpris-widget/init.lua | 131 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 164 insertions(+), 6 deletions(-) create mode 100644 mpris-widget/README.md create mode 100644 mpris-widget/init.lua diff --git a/README.md b/README.md index 96500de..6704489 100644 --- a/README.md +++ b/README.md @@ -12,9 +12,9 @@

-Set of super simple widgets compatible with Awesome Window Manager v.4+. +Set of super simple widgets compatible with Awesome Window Manager v.4+. -## Screenshots +## Screenshots Spotify, CPU, RAM, brightness-arc, volume-arc and battery-arc widgets: @@ -35,19 +35,20 @@ Some more screenshots in this reddit [post](https://www.reddit.com/r/unixporn/co From left to right: - [spotify-widget](https://github.com/streetturtle/AwesomeWM/tree/master/spotify-widget) / [rhythmbox-widget](https://github.com/streetturtle/AwesomeWM/tree/master/rhythmbox-widget) -- [cpu-widget](https://github.com/streetturtle/AwesomeWM/tree/master/cpu-widget) +- [cpu-widget](https://github.com/streetturtle/AwesomeWM/tree/master/cpu-widget) - [weather-widget](https://github.com/streetturtle/AwesomeWM/tree/master/weather-widget) - [email-widget](https://github.com/streetturtle/AwesomeWM/tree/master/email-widget) - [brightness-widget](https://github.com/streetturtle/AwesomeWM/tree/master/brightness-widget) - [volume-widget](https://github.com/streetturtle/AwesomeWM/tree/master/volume-widget) -- [volumebar-widget](https://github.com/streetturtle/AwesomeWM/tree/master/volumebar-widget) -- [volumearc-widget](https://github.com/streetturtle/AwesomeWM/tree/master/volumearc-widget) -- [batteryarc-widget](https://github.com/streetturtle/AwesomeWM/tree/master/batteryarc-widget) +- [volumebar-widget](https://github.com/streetturtle/AwesomeWM/tree/master/volumebar-widget) +- [volumearc-widget](https://github.com/streetturtle/AwesomeWM/tree/master/volumearc-widget) +- [batteryarc-widget](https://github.com/streetturtle/AwesomeWM/tree/master/batteryarc-widget) - [battery-widget](https://github.com/streetturtle/AwesomeWM/tree/master/battery-widget) - [ram-widget](https://github.com/streetturtle/AwesomeWM/tree/master/ram-widget) - [translate-widget](https://github.com/streetturtle/AwesomeWM/tree/master/translate-widget) (not on the screenshot) - [spotify-shell](https://github.com/streetturtle/AwesomeWM/tree/master/spotify-shell) (not on the screenshot) - [run-shell](https://github.com/streetturtle/AwesomeWM/tree/master/run-shell) (not on the screenshot) +- [mpris-widget](https://github.com/streetturtle/AwesomeWM/tree/master/mpris-widget) (not on the screenshot) # Installation diff --git a/mpris-widget/README.md b/mpris-widget/README.md new file mode 100644 index 0000000..317385f --- /dev/null +++ b/mpris-widget/README.md @@ -0,0 +1,26 @@ +# MPRIS Widget + +Music Player Info widget cy @mgabs + +# Prerequisite + +Install `playerctl` (mpris implementation), should be available in repo, e.g for Ubuntu: + +```bash +sudo apt-get install playerctl +``` + +## Installation + +To use this widget clone repo under **~/.config/awesome/** and then add it in **rc.lua**: + +```lua +local mpris_widget = require("awesome-wm-widgets.mpris-widget") +... +s.mytasklist, -- Middle widget + { -- Right widgets + layout = wibox.layout.fixed.horizontal, + ... + mpris_widget, + ... +``` diff --git a/mpris-widget/init.lua b/mpris-widget/init.lua new file mode 100644 index 0000000..c9b2389 --- /dev/null +++ b/mpris-widget/init.lua @@ -0,0 +1,131 @@ +------------------------------------------------- +-- mpris based Arc Widget for Awesome Window Manager +-- Modelled after Pavel Makhov's work +-- @author Mohammed Gaber +-- requires - playerctl +-- @copyright 2020 +------------------------------------------------- +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 GET_MPD_CMD = + "playerctl -f '{{lc(status)}};{{xesam:artist}};{{xesam:title}}' metadata" + +local TOGGLE_MPD_CMD = "playerctl play-pause" +local PAUSE_MPD_CMD = "playerctl pause" +local STOP_MPD_CMD = "playerctl stop" +local NEXT_MPD_CMD = "playerctl next" +local PREV_MPD_CMD = "playerctl prev" + +local PATH_TO_ICONS = "/usr/share/icons/Arc" +local PAUSE_ICON_NAME = PATH_TO_ICONS .. "/actions/24/player_pause.png" +local PLAY_ICON_NAME = PATH_TO_ICONS .. "/actions/24/player_play.png" +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 + +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 mpdarc_current_song_widget = wibox.widget { + id = 'current_song', + widget = wibox.widget.textbox, + font = 'Play 10' +} + +local update_graphic = function(widget, stdout, _, _, _) + mpdstatus, artist, current_song = stdout:match("(%w+)%;+(.-)%;(.*)") + if current_song ~= nil then + if current_song.len == 18 then + current_song = string.sub(current_song, 0, 9) .. ".." + end + end + + if mpdstatus == "playing" then + icon.image = PLAY_ICON_NAME + widget.colors = {beautiful.widget_main_color} + mpdarc_current_song_widget.markup = current_song + elseif mpdstatus == "paused" then + icon.image = PAUSE_ICON_NAME + widget.colors = {beautiful.widget_main_color} + mpdarc_current_song_widget.markup = current_song + elseif mpdstatus == "stopped" then + icon.image = STOP_ICON_NAME + mpdarc_current_song_widget.markup = "" + else -- no player is running + icon.image = LIBRARY_ICON_NAME + mpdarc_current_song_widget.markup = "" + widget.colors = {beautiful.widget_red} + end +end + +mpdarc:connect_signal("button::press", function(_, _, _, button) + if (button == 1) then + awful.spawn(TOGGLE_MPD_CMD, false) -- left click + elseif (button == 2) then + awful.spawn(STOP_MPD_CMD, false) + elseif (button == 3) then + awful.spawn(PAUSE_MPD_CMD, false) + elseif (button == 4) then + awful.spawn(NEXT_MPD_CMD, false) -- scroll up + elseif (button == 5) then + awful.spawn(PREV_MPD_CMD, false) -- scroll down + end + + spawn.easy_async(GET_MPD_CMD, function(stdout, stderr, exitreason, exitcode) + update_graphic(mpdarc, stdout, stderr, exitreason, exitcode) + end) +end) + +local notification +function show_MPD_status() + spawn.easy_async(GET_MPD_CMD, function(stdout, _, _, _) + notification = naughty.notify { + text = current_song .. " by " .. artist, + title = "Now Playing", + timeout = 5, + hover_timeout = 0.5, + width = 600 + } + end) +end + +mpdarc:connect_signal("mouse::enter", function() + if current_song ~= nil and artist ~= nil then show_MPD_status() end +end) +mpdarc:connect_signal("mouse::leave", + function() naughty.destroy(notification) end) + +watch(GET_MPD_CMD, 1, update_graphic, mpdarc) + +local mpdarc_widget = wibox.widget { + mpdarc_icon_widget, + mpdarc_current_song_widget, + layout = wibox.layout.align.horizontal +} +return mpdarc_widget -- cgit v1.2.3 From 0e1d31ad6f5663d4f56bd02ecb01b58fe6f162e1 Mon Sep 17 00:00:00 2001 From: gaberm Date: Sat, 21 Nov 2020 14:45:37 +0200 Subject: Fixed notify status - mpris widget --- mpris-widget/init.lua | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/mpris-widget/init.lua b/mpris-widget/init.lua index c9b2389..e18edf5 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 '{{lc(status)}};{{xesam:artist}};{{xesam:title}}' metadata" + "playerctl -f '{{status}};{{xesam:artist}};{{xesam:title}}' metadata" local TOGGLE_MPD_CMD = "playerctl play-pause" local PAUSE_MPD_CMD = "playerctl pause" @@ -66,19 +66,23 @@ local update_graphic = function(widget, stdout, _, _, _) end end - if mpdstatus == "playing" then + if mpdstatus == "Playing" then + mpdarc_icon_widget.visible = true icon.image = PLAY_ICON_NAME widget.colors = {beautiful.widget_main_color} mpdarc_current_song_widget.markup = current_song - elseif mpdstatus == "paused" then + elseif mpdstatus == "Paused" then + mpdarc_icon_widget.visible = true icon.image = PAUSE_ICON_NAME widget.colors = {beautiful.widget_main_color} mpdarc_current_song_widget.markup = current_song - elseif mpdstatus == "stopped" then + elseif mpdstatus == "Stopped" then + mpdarc_icon_widget.visible = true icon.image = STOP_ICON_NAME mpdarc_current_song_widget.markup = "" else -- no player is running icon.image = LIBRARY_ICON_NAME + mpdarc_icon_widget.visible = false mpdarc_current_song_widget.markup = "" widget.colors = {beautiful.widget_red} end @@ -107,7 +111,7 @@ function show_MPD_status() spawn.easy_async(GET_MPD_CMD, function(stdout, _, _, _) notification = naughty.notify { text = current_song .. " by " .. artist, - title = "Now Playing", + title = mpdstatus, timeout = 5, hover_timeout = 0.5, width = 600 @@ -124,6 +128,7 @@ mpdarc:connect_signal("mouse::leave", watch(GET_MPD_CMD, 1, update_graphic, mpdarc) local mpdarc_widget = wibox.widget { + screen = 'primary', mpdarc_icon_widget, mpdarc_current_song_widget, layout = wibox.layout.align.horizontal -- cgit v1.2.3 From 30199568c6a427e6495493f1d191674304f10f55 Mon Sep 17 00:00:00 2001 From: streetturtle Date: Mon, 23 Nov 2020 09:55:37 -0500 Subject: wrap widget in a function --- mpris-widget/init.lua | 211 ++++++++++++++++++++++++++------------------------ 1 file changed, 111 insertions(+), 100 deletions(-) diff --git a/mpris-widget/init.lua b/mpris-widget/init.lua index e18edf5..370957d 100644 --- a/mpris-widget/init.lua +++ b/mpris-widget/init.lua @@ -3,7 +3,7 @@ -- Modelled after Pavel Makhov's work -- @author Mohammed Gaber -- requires - playerctl --- @copyright 2020 +-- @copyright 2020 ------------------------------------------------- local awful = require("awful") local beautiful = require("beautiful") @@ -19,7 +19,7 @@ local TOGGLE_MPD_CMD = "playerctl play-pause" local PAUSE_MPD_CMD = "playerctl pause" local STOP_MPD_CMD = "playerctl stop" local NEXT_MPD_CMD = "playerctl next" -local PREV_MPD_CMD = "playerctl prev" +local PREV_MPD_CMD = "playerctl previous" local PATH_TO_ICONS = "/usr/share/icons/Arc" local PAUSE_ICON_NAME = PATH_TO_ICONS .. "/actions/24/player_pause.png" @@ -27,110 +27,121 @@ local PLAY_ICON_NAME = PATH_TO_ICONS .. "/actions/24/player_play.png" 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 - -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 mpdarc_current_song_widget = wibox.widget { - id = 'current_song', - widget = wibox.widget.textbox, - font = 'Play 10' -} - -local update_graphic = function(widget, stdout, _, _, _) - mpdstatus, artist, current_song = stdout:match("(%w+)%;+(.-)%;(.*)") - if current_song ~= nil then - if current_song.len == 18 then - current_song = string.sub(current_song, 0, 9) .. ".." + +local mpdarc_widget = {} + +local function worker(args) + + -- retriving song info + local current_song, artist, mpdstatus + + 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 mpdarc_current_song_widget = wibox.widget { + id = 'current_song', + widget = wibox.widget.textbox, + font = 'Play 10' + } + + local update_graphic = function(widget, stdout, _, _, _) + mpdstatus, artist, current_song = stdout:match("(%w+)%;+(.-)%;(.*)") + if current_song ~= nil then + if current_song.len == 18 then + current_song = string.sub(current_song, 0, 9) .. ".." + end end - end - if mpdstatus == "Playing" then - mpdarc_icon_widget.visible = true - icon.image = PLAY_ICON_NAME - widget.colors = {beautiful.widget_main_color} - mpdarc_current_song_widget.markup = current_song - elseif mpdstatus == "Paused" then - mpdarc_icon_widget.visible = true - icon.image = PAUSE_ICON_NAME - widget.colors = {beautiful.widget_main_color} - mpdarc_current_song_widget.markup = current_song - elseif mpdstatus == "Stopped" then - mpdarc_icon_widget.visible = true - icon.image = STOP_ICON_NAME - mpdarc_current_song_widget.markup = "" - else -- no player is running - icon.image = LIBRARY_ICON_NAME - mpdarc_icon_widget.visible = false - mpdarc_current_song_widget.markup = "" - widget.colors = {beautiful.widget_red} + if mpdstatus == "Playing" then + mpdarc_icon_widget.visible = true + icon.image = PLAY_ICON_NAME + widget.colors = {beautiful.widget_main_color} + mpdarc_current_song_widget.markup = current_song + elseif mpdstatus == "Paused" then + mpdarc_icon_widget.visible = true + icon.image = PAUSE_ICON_NAME + widget.colors = {beautiful.widget_main_color} + mpdarc_current_song_widget.markup = current_song + elseif mpdstatus == "Stopped" then + mpdarc_icon_widget.visible = true + icon.image = STOP_ICON_NAME + mpdarc_current_song_widget.markup = "" + else -- no player is running + icon.image = LIBRARY_ICON_NAME + mpdarc_icon_widget.visible = false + mpdarc_current_song_widget.markup = "" + widget.colors = {beautiful.widget_red} + end end -end -mpdarc:connect_signal("button::press", function(_, _, _, button) - if (button == 1) then - awful.spawn(TOGGLE_MPD_CMD, false) -- left click - elseif (button == 2) then - awful.spawn(STOP_MPD_CMD, false) - elseif (button == 3) then - awful.spawn(PAUSE_MPD_CMD, false) - elseif (button == 4) then - awful.spawn(NEXT_MPD_CMD, false) -- scroll up - elseif (button == 5) then - awful.spawn(PREV_MPD_CMD, false) -- scroll down - end + mpdarc:connect_signal("button::press", function(_, _, _, button) + if (button == 1) then + awful.spawn(TOGGLE_MPD_CMD, false) -- left click + elseif (button == 2) then + awful.spawn(STOP_MPD_CMD, false) + elseif (button == 3) then + awful.spawn(PAUSE_MPD_CMD, false) + elseif (button == 4) then + awful.spawn(NEXT_MPD_CMD, false) -- scroll up + elseif (button == 5) then + awful.spawn(PREV_MPD_CMD, false) -- scroll down + end - spawn.easy_async(GET_MPD_CMD, function(stdout, stderr, exitreason, exitcode) - update_graphic(mpdarc, stdout, stderr, exitreason, exitcode) + spawn.easy_async(GET_MPD_CMD, function(stdout, stderr, exitreason, exitcode) + update_graphic(mpdarc, stdout, stderr, exitreason, exitcode) + end) end) -end) - -local notification -function show_MPD_status() - spawn.easy_async(GET_MPD_CMD, function(stdout, _, _, _) - notification = naughty.notify { - text = current_song .. " by " .. artist, - title = mpdstatus, - timeout = 5, - hover_timeout = 0.5, - width = 600 - } + + local notification + local function show_MPD_status() + spawn.easy_async(GET_MPD_CMD, function(stdout, _, _, _) + notification = naughty.notify { + text = current_song .. " by " .. artist, + title = mpdstatus, + timeout = 5, + hover_timeout = 0.5, + width = 600 + } + end) + end + + mpdarc:connect_signal("mouse::enter", function() + if current_song ~= nil and artist ~= nil then show_MPD_status() end end) + mpdarc:connect_signal("mouse::leave", + function() naughty.destroy(notification) end) + + watch(GET_MPD_CMD, 1, update_graphic, mpdarc) + + mpdarc_widget = wibox.widget { + screen = 'primary', + mpdarc_icon_widget, + mpdarc_current_song_widget, + layout = wibox.layout.align.horizontal + } + return mpdarc_widget + end -mpdarc:connect_signal("mouse::enter", function() - if current_song ~= nil and artist ~= nil then show_MPD_status() end -end) -mpdarc:connect_signal("mouse::leave", - function() naughty.destroy(notification) end) - -watch(GET_MPD_CMD, 1, update_graphic, mpdarc) - -local mpdarc_widget = wibox.widget { - screen = 'primary', - mpdarc_icon_widget, - mpdarc_current_song_widget, - layout = wibox.layout.align.horizontal -} -return mpdarc_widget +return setmetatable(mpdarc_widget, { __call = function(_, ...) + return worker(...) +end }) \ No newline at end of file -- cgit v1.2.3 From 5dbfab72489a06348cf332461ae8ceef592b6085 Mon Sep 17 00:00:00 2001 From: gaberm Date: Mon, 23 Nov 2020 21:03:06 +0200 Subject: added icon to mpris popup --- mpris-widget/init.lua | 35 ++++++++++++++++++++++++++--------- 1 file 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 -- cgit v1.2.3 From 062a6d77628647d26a92126a3484907115e7fa3b Mon Sep 17 00:00:00 2001 From: gaberm Date: Wed, 25 Nov 2020 23:11:32 +0200 Subject: Added image icon for streaming from firefox --- mpris-widget/init.lua | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/mpris-widget/init.lua b/mpris-widget/init.lua index 5144ea8..5af85b4 100644 --- a/mpris-widget/init.lua +++ b/mpris-widget/init.lua @@ -32,7 +32,7 @@ local mpdarc_widget = {} local function worker(args) -- retriving song info - local current_song, artist, mpdstatus + local current_song, artist, mpdstatus, art, artUrl local icon = wibox.widget { id = "icon", @@ -55,7 +55,8 @@ local function worker(args) widget = wibox.container.arcchart } - local mpdarc_icon_widget = wibox.container.mirror(mpdarc, {horizontal = true}) + local mpdarc_icon_widget = wibox.container.mirror(mpdarc, + {horizontal = true}) local mpdarc_current_song_widget = wibox.widget { id = 'current_song', widget = wibox.widget.textbox, @@ -63,13 +64,22 @@ local function worker(args) } 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 table.insert(words, w) end + + mpdstatus = words[1] + artist = words[2] + current_song = words[3] + art = words[4] if current_song ~= nil then - if current_song.len == 18 then + if string.len(current_song) > 18 then current_song = string.sub(current_song, 0, 9) .. ".." 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 @@ -105,7 +115,8 @@ local function worker(args) awful.spawn(PREV_MPD_CMD, false) -- scroll down end - spawn.easy_async(GET_MPD_CMD, function(stdout, stderr, exitreason, exitcode) + spawn.easy_async(GET_MPD_CMD, + function(stdout, stderr, exitreason, exitcode) update_graphic(mpdarc, stdout, stderr, exitreason, exitcode) end) end) @@ -113,12 +124,15 @@ local function worker(args) local notification local function show_MPD_status() spawn.easy_async(GET_MPD_CMD, function(stdout, _, _, _) - notification = naughty.notify { - text = current_song .. " by " .. artist, - title = mpdstatus, + notification = naughty.notification { + margin = 10, timeout = 5, hover_timeout = 0.5, - width = 600 + width = 240, + height = 90, + title = "" .. mpdstatus .. "", + text = current_song .. " by " .. artist, + image = artUrl } end) end @@ -127,7 +141,7 @@ local function worker(args) if current_song ~= nil and artist ~= nil then show_MPD_status() end end) mpdarc:connect_signal("mouse::leave", - function() naughty.destroy(notification) end) + function() naughty.destroy(notification) end) watch(GET_MPD_CMD, 1, update_graphic, mpdarc) @@ -141,6 +155,5 @@ local function worker(args) end -return setmetatable(mpdarc_widget, { __call = function(_, ...) - return worker(...) -end }) \ No newline at end of file +return setmetatable(mpdarc_widget, + {__call = function(_, ...) return worker(...) end}) -- cgit v1.2.3