summaryrefslogtreecommitdiff
path: root/spotify-widget
diff options
context:
space:
mode:
authorpmakhov <pavel.makhov@savoirfairelinux.com>2017-10-11 14:22:51 -0400
committerpmakhov <pavel.makhov@savoirfairelinux.com>2017-10-11 14:22:51 -0400
commit74c6db82f594b1960a05bce01be46808f93c7985 (patch)
tree445bee6461710b7f605a2b61e3ab48e8387d4bba /spotify-widget
parent6b79e3022b612358d842f1b209ef32e49036d2e9 (diff)
refactoring
Diffstat (limited to 'spotify-widget')
-rw-r--r--spotify-widget/spotify.lua17
1 files changed, 9 insertions, 8 deletions
diff --git a/spotify-widget/spotify.lua b/spotify-widget/spotify.lua
index a3f72f0..4ecce79 100644
--- a/spotify-widget/spotify.lua
+++ b/spotify-widget/spotify.lua
@@ -1,9 +1,10 @@
-local wibox = require("wibox")
local awful = require("awful")
+local wibox = require("wibox")
local watch = require("awful.widget.watch")
-local get_spotify_status_cmd = '/home/'.. os.getenv("USER") .. '/.config/awesome/awesome-wm-widgets/spotify-widget/spotify_stat'
-local get_current_song_cmd = 'sp current-oneline'
+local GET_SPOTIFY_STATUS_CMD = os.getenv("HOME") .. '/.config/awesome/awesome-wm-widgets/spotify-widget/spotify_stat'
+local GET_CURRENT_SONG_CMD = 'sp current-oneline'
+local PATH_TO_ICONS = "/usr/share/icons/Arc"
spotify_widget = wibox.widget {
{
@@ -27,9 +28,9 @@ spotify_widget = wibox.widget {
local update_widget_icon = function(widget, stdout, _, _, _)
stdout = string.gsub(stdout, "\n", "")
if (stdout == 'RUNNING') then
- widget:set_image("/usr/share/icons/Arc/actions/24/player_play.png")
+ widget:set_image(PATH_TO_ICONS .. "/actions/24/player_play.png")
elseif (stdout == "CORKED") then
- widget:set_image("/usr/share/icons/Arc/actions/24/player_pause.png")
+ widget:set_image(PATH_TO_ICONS .. "/actions/24/player_pause.png")
else
widget:set_image(nil)
end
@@ -45,8 +46,8 @@ local update_widget_text = function(widget, stdout, _, _, _)
end
end
-watch(get_spotify_status_cmd, 1, update_widget_icon, spotify_widget)
-watch(get_current_song_cmd, 1, update_widget_text, spotify_widget)
+watch(GET_SPOTIFY_STATUS_CMD, 1, update_widget_icon, spotify_widget)
+watch(GET_CURRENT_SONG_CMD, 1, update_widget_text, spotify_widget)
--[[
-- Adds mouse control to the widget:
@@ -58,7 +59,7 @@ spotify_widget:connect_signal("button::press", function(_, _, _, button)
elseif (button == 4) then awful.spawn("sp next", false) -- scroll up
elseif (button == 5) then awful.spawn("sp prev", false) -- scroll down
end
- awful.spawn.easy_async(get_spotify_status_cmd, function(stdout, stderr, exitreason, exitcode)
+ awful.spawn.easy_async(GET_SPOTIFY_STATUS_CMD, function(stdout, stderr, exitreason, exitcode)
update_widget_icon(spotify_widget, stdout, stderr, exitreason, exitcode)
end)
end) \ No newline at end of file