summaryrefslogtreecommitdiff
path: root/experiments
diff options
context:
space:
mode:
authorstreetturtle <streetturtle@gmail.com>2021-01-26 20:59:04 -0500
committerstreetturtle <streetturtle@gmail.com>2021-01-26 20:59:04 -0500
commitadb6d2accc0ab73ccba58a1ca16a2d3494269319 (patch)
tree6e8c085946359df1f880e9b90229cc3aded145b8 /experiments
parentfceec794508cd45d133f7c236df2158f36bce50a (diff)
[spotify-player] more changes
Diffstat (limited to 'experiments')
-rw-r--r--experiments/spotify-player/spotify-indicator.svg8
-rw-r--r--experiments/spotify-player/spotify-player.lua34
2 files changed, 26 insertions, 16 deletions
diff --git a/experiments/spotify-player/spotify-indicator.svg b/experiments/spotify-player/spotify-indicator.svg
new file mode 100644
index 0000000..0b96c0a
--- /dev/null
+++ b/experiments/spotify-player/spotify-indicator.svg
@@ -0,0 +1,8 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" version="1.1">
+ <defs>
+ <style id="current-color-scheme" type="text/css">
+ .ColorScheme-Text { color:#dfdfdf; } .ColorScheme-Highlight { color:#4285f4; }
+ </style>
+ </defs>
+ <path style="fill:currentColor" class="ColorScheme-Text" d="m 12,4 c -4.4182999,0 -7.9999999,3.5816996 -7.9999999,8 0,4.4183 3.5817,8 7.9999999,8 4.4183,0 8,-3.5817 8,-8 0,-4.4183004 -3.5817,-8 -8,-8 z m -1.484375,4.001953 c 0.135577,-0.0025 0.273043,-0.00125 0.40625,0 3.196934,0.043793 5.685547,1.3710939 5.685547,1.3710939 0.32387,0.1720431 0.478757,0.6868991 0.34375,1.0996091 -0.135016,0.41271 -0.551129,0.642746 -0.875,0.470703 0,0 -4.055029,-2.1406733 -8.1835939,-0.824218 -0.347652,0.145366 -0.785915,-0.135667 -0.875,-0.587891 -0.08907,-0.452224 0.170933,-0.9774967 0.53125,-1.0585939 1.017797,-0.3245495 2.017773,-0.4508522 2.9667969,-0.4707031 z m 0.435547,3 c 0.112731,-10e-4 0.212326,-0.0042 0.322266,0 2.638513,0.09188 4.466796,1.550781 4.466796,1.550781 0.234052,0.185402 0.328171,0.661373 0.207032,1.019532 -0.121139,0.358115 -0.441752,0.53892 -0.675782,0.353515 0,0 -2.907877,-2.344468 -6.6425779,-0.974609 -0.262497,0.124051 -0.553359,-0.122359 -0.617187,-0.53125 -0.06386,-0.40893 0.141317,-0.858788 0.412109,-0.929688 0.897365,-0.329138 1.7382149,-0.481181 2.5273439,-0.488281 z M 11.265625,14 c 1.291618,0.02495 2.442203,0.50401 3.542969,1.154297 0.164454,0.107427 0.243604,0.411344 0.152344,0.628906 -0.09126,0.217545 -0.337279,0.284734 -0.486329,0.140625 0,0 -2.036051,-1.658526 -5.0566399,-0.734375 -0.17338,0.07498 -0.372018,-0.06945 -0.41211,-0.314453 -0.04008,-0.245057 0.10336,-0.525057 0.283204,-0.560547 C 9.9993371,14.09714 10.660752,13.996 11.265625,14 Z"/>
+</svg>
diff --git a/experiments/spotify-player/spotify-player.lua b/experiments/spotify-player/spotify-player.lua
index eba85d6..981978b 100644
--- a/experiments/spotify-player/spotify-player.lua
+++ b/experiments/spotify-player/spotify-player.lua
@@ -4,7 +4,7 @@
-- https://github.com/streetturtle/awesome-wm-widgets/tree/master/spotify-player
-- @author Pavel Makhov
--- @copyright 2020 Pavel Makhov
+-- @copyright 2021 Pavel Makhov
-------------------------------------------------
--luacheck:ignore
local awful = require("awful")
@@ -19,12 +19,10 @@ local gs = require("gears.string")
local awesomebuttons = require("awesome-buttons.awesome-buttons")
local HOME_DIR = os.getenv("HOME")
-local WIDGET_DIR = HOME_DIR .. '/.config/awesome/awesome-wm-widgets/experiments/spotify-player'
+local WIDGET_DIR = HOME_DIR .. '/.config/awesome/awesome-wm-widgets/experiments/spotify-player/'
local ICON_DIR = WIDGET_DIR
-local spotify_playerr = {}
-
-local BLUR_CMD = 'convert %s ( -clone 0 -fill white -colorize 100 -fill black -draw "polygon 0,200 300,200 300,300 0,300" -alpha off -write mpr:mask +delete ) -mask mpr:mask -blur 0x3 +mask %s'
+local spotify_player = {}
local function show_warning(message)
naughty.notify{
@@ -33,9 +31,9 @@ local function show_warning(message)
text = message}
end
-local function worker(args)
+local function worker(user_args)
- local args = args or {}
+ local args = user_args or {}
local artwork_size = args.artwork_size or 300
local timeout = args.timeout or 1
@@ -58,10 +56,9 @@ local function worker(args)
layout = wibox.layout.align.vertical,
}
- spotify_playerr.widget = wibox.widget {
- --image = ,
- text = 'sp-player',
- widget = wibox.widget.textbox
+ spotify_player.widget = wibox.widget {
+ image = ICON_DIR .. 'spotify-indicator.svg',
+ widget = wibox.widget.imagebox
}
local artwork_widget = wibox.widget {
@@ -140,6 +137,10 @@ local function worker(args)
local update_widget = function(widget, stdout, stderr, _, _)
for i = 0, #rows do rows[i]=nil end
+ if string.find(stdout, 'Error: Spotify is not running.') ~= nil then
+ return
+ end
+
local track_id, length, art_url, album, album_artist, artist, auto_rating, disc_number, title, track_number, url =
string.match(stdout, 'trackid|(.*)\nlength|(.*)\nartUrl|(.*)\nalbum|(.*)\nalbumArtist|(.*)\nartist|(.*)\nautoRating|(.*)\ndiscNumber|(.*)\ntitle|(.*)\ntrackNumber|(.*)\nurl|(.*)')
@@ -147,6 +148,7 @@ local function worker(args)
artist_w:set_artist(artist)
title_w:set_title(title)
+ -- spotify client bug: https://community.spotify.com/t5/Desktop-Linux/MPRIS-cover-art-url-file-not-found/td-p/4920104
art_url = art_url:gsub('https://open.spotify.com', 'https://i.scdn.co')
if ((art_url ~= nil or art_url ~='') and not gfs.file_readable('/tmp/' .. track_id)) then
spawn.easy_async('touch /tmp/' .. track_id, function()
@@ -163,7 +165,7 @@ local function worker(args)
end
end
- function spotify_playerr:tog()
+ function spotify_player:tog()
if popup.visible then
popup.visible = not popup.visible
else
@@ -171,9 +173,9 @@ local function worker(args)
end
end
- spotify_playerr.widget:buttons(
+ spotify_player.widget:buttons(
awful.util.table.join(
- awful.button({}, 1, function() spotify_playerr:tog() end)
+ awful.button({}, 1, function() spotify_player:tog() end)
)
)
@@ -184,7 +186,7 @@ local function worker(args)
play_pause_btn:set_icon(stdout == 'Playing' and 'pause' or 'play')
end)
- return spotify_playerr
+ return spotify_player
end
-return setmetatable(spotify_playerr, { __call = function(_, ...) return worker(...) end })
+return setmetatable(spotify_player, { __call = function(_, ...) return worker(...) end })