From 4614f1cee5e301bc99775424636f55e673e8c346 Mon Sep 17 00:00:00 2001 From: Hasan Ramezani Date: Fri, 2 Nov 2018 17:52:55 +0100 Subject: Define TOGGLE_MPD_CMD and use it for mpdarc-widget. Signed-off-by: Hasan Ramezani --- mpdarc-widget/mpdarc.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'mpdarc-widget') diff --git a/mpdarc-widget/mpdarc.lua b/mpdarc-widget/mpdarc.lua index 56009ef..7b8aea3 100644 --- a/mpdarc-widget/mpdarc.lua +++ b/mpdarc-widget/mpdarc.lua @@ -14,6 +14,7 @@ local wibox = require("wibox") local naughty = require("naughty") local GET_MPD_CMD = "mpc status" +local TOGGLE_MPD_CMD = "mpc toggle" local PAUSE_MPD_CMD = "mpc pause" local STOP_MPD_CMD = "mpc stop" local NEXT_MPD_CMD = "mpc next" @@ -66,7 +67,7 @@ local update_graphic = function(widget, stdout, _, _, _) end mpdarc:connect_signal("button::press", function(_, _, _, button) - if (button == 1) then awful.spawn("mpc toggle", false) -- left click + 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 -- cgit v1.2.3 From d9cfaeecd3f28080d57c4e8a39035b7586346dd1 Mon Sep 17 00:00:00 2001 From: Hasan Ramezani Date: Fri, 2 Nov 2018 22:56:55 +0100 Subject: Add Installation section to mpdarc-widget/README.md --- mpdarc-widget/README.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'mpdarc-widget') diff --git a/mpdarc-widget/README.md b/mpdarc-widget/README.md index 0a6ffa6..2192410 100644 --- a/mpdarc-widget/README.md +++ b/mpdarc-widget/README.md @@ -10,5 +10,17 @@ Install `mpd` (Music Player Daemon itself) and `mpc` (Music Player Client - prog sudo apt-get install mpd mpc ``` -Set them up and then just follow the [installation](https://github.com/streetturtle/awesome-wm-widgets#installation) section of the repo. +## Installation +To use this widget clone repo under **~/.config/awesome/** and then add it in **rc.lua**: + +```lua +local mpdarc_widget = require("awesome-wm-widgets.mpdarc-widget.mpdarc") +... +s.mytasklist, -- Middle widget + { -- Right widgets + layout = wibox.layout.fixed.horizontal, + ... + mpdarc_widget, + ... +``` -- cgit v1.2.3 From be68535271043437d339d2992498deabffd5ab9e Mon Sep 17 00:00:00 2001 From: Hasan Ramezani Date: Mon, 5 Nov 2018 11:54:50 +0100 Subject: Add current song text box to mpdarc-widget. --- mpdarc-widget/mpdarc.lua | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'mpdarc-widget') diff --git a/mpdarc-widget/mpdarc.lua b/mpdarc-widget/mpdarc.lua index 7b8aea3..da596f6 100644 --- a/mpdarc-widget/mpdarc.lua +++ b/mpdarc-widget/mpdarc.lua @@ -46,9 +46,15 @@ local mpdarc = wibox.widget { widget = wibox.container.arcchart } -local mpdarc_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, + font = 'Play 9' +} local update_graphic = function(widget, stdout, _, _, _) + local current_song = string.gmatch(stdout, "[^\r\n]+")() stdout = string.gsub(stdout, "\n", "") local mpdpercent = string.match(stdout, "(%d%d)%%") local mpdstatus = string.match(stdout, "%[(%a+)%]") @@ -56,13 +62,16 @@ local update_graphic = function(widget, stdout, _, _, _) icon.image = PLAY_ICON_NAME widget.colors = { beautiful.widget_main_color } widget.value = tonumber((100-mpdpercent)/100) - elseif mpdstatus == "paused" then + mpdarc_current_song_widget.markup = current_song + elseif mpdstatus == "paused" then icon.image = PAUSE_ICON_NAME widget.colors = { beautiful.widget_main_color } widget.value = tonumber(mpdpercent/100) + mpdarc_current_song_widget.markup = current_song else icon.image = STOP_ICON_NAME widget.colors = { beautiful.widget_red } + mpdarc_current_song_widget.markup = "" end end @@ -98,4 +107,9 @@ mpdarc:connect_signal("mouse::leave", function() naughty.destroy(notification) e watch(GET_MPD_CMD, 1, update_graphic, mpdarc) +local mpdarc_widget = { + mpdarc_icon_widget, + mpdarc_current_song_widget, + layout = wibox.layout.align.horizontal, + } return mpdarc_widget -- cgit v1.2.3 From 944c00201a89dfaaa10632b9e3603ebecd174a30 Mon Sep 17 00:00:00 2001 From: Hasan Ramezani Date: Tue, 6 Nov 2018 21:42:27 +0100 Subject: Set `MPD is not running` in mpdarc-widget current song when MPD is not running. --- mpdarc-widget/mpdarc.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'mpdarc-widget') diff --git a/mpdarc-widget/mpdarc.lua b/mpdarc-widget/mpdarc.lua index da596f6..ca0f411 100644 --- a/mpdarc-widget/mpdarc.lua +++ b/mpdarc-widget/mpdarc.lua @@ -70,8 +70,12 @@ local update_graphic = function(widget, stdout, _, _, _) mpdarc_current_song_widget.markup = current_song else icon.image = STOP_ICON_NAME - widget.colors = { beautiful.widget_red } - mpdarc_current_song_widget.markup = "" + if string.len(stdout) == 0 then -- MPD is not running + mpdarc_current_song_widget.markup = "MPD is not running" + else + widget.colors = { beautiful.widget_red } + mpdarc_current_song_widget.markup = "" + end end end -- cgit v1.2.3