You are not logged in.

#1 2014-03-26 18:39:22

Dexxt
Member
From: ES, FR, IT
Registered: 2014-02-25
Posts: 26
Website

Spotify script for Conky

Hi all!
I made a bash script that reads informations on the current track from dbus and displays them on conky.
I will let you take a look at it with a screenshot.
It works pretty fine, I would like to share it with you, and I would like that someone gave me some hints for letting it work better.

Criticities I noticed:
- I have to read every 1 second from dbus even if the song doesn't change.
- I have to download the album cover from the spotify album URL, but I suppose I already have it somewhere in cache.

I uploaded the code on github, so that you can see it here.

If you have any other suggestion, let me know.

Thank you in advance.

Last edited by Dexxt (2014-03-26 18:40:26)

Offline

#2 2014-03-26 18:43:08

Inxsible
Forum Fellow
From: Chicago
Registered: 2008-06-09
Posts: 9,183

Re: Spotify script for Conky

Moving to Community Contribs...


Forum Rules

There's no such thing as a stupid question, but there sure are a lot of inquisitive idiots !

Offline

#3 2014-09-15 13:48:21

mystyfly
Member
Registered: 2013-03-25
Posts: 30

Re: Spotify script for Conky

@Dexxt: Are you still running your script? I made something similar for clementine some time ago. I've been without archlinux for some time and am setting up a fresh install. However, running the bash script that gathers the music information doesn't work when executed by conky since the dbus queries yield no result. Running them from the terminal works fine. Maybe I forgot to install/configure something, or did you encounter something similar?

Offline

#4 2014-10-18 10:22:59

Dexxt
Member
From: ES, FR, IT
Registered: 2014-02-25
Posts: 26
Website

Re: Spotify script for Conky

Hey! It's nice to hear from you.
What Desktop Environment are you using? - I use Gnome!

If you have troubles with permissions do the following further steps:

#: chmod -R 777 ~/.conkycolors/spotify

I tried it on a fresh install and it seems to work, but first I had to install wget.

#: pacman -S wget

then everything went fine.

How do you run spotify? I just use:

$: conky -c ~/.conkycolors/conkyrc

Offline

#5 2014-10-19 08:54:33

mystyfly
Member
Registered: 2013-03-25
Posts: 30

Re: Spotify script for Conky

Hi Dexxt,

I doubt it was a problem with permissions in my case. To be honest, I don't really know why it wasn't working back then or why it is working again now. My WM is Awesome, I think I tried running it with dbus-launch in .xinitrc, maybe that fixed it. However, checking my .xinitrc now, I see that I'm just running plain "exec awesome" :s

I run conky from .xinitrc. However, I added a delay before starting conky so that it would only be launched after an Internet connection could be established (since a few sections require it), that might have helped as well... my .xinitrc entry looks like this:

sleep 90 && conky -c $HOME/git/linux-scripts/conky/.conkyrc &

Offline

#6 2014-11-01 11:59:06

vanderlaars
Member
Registered: 2014-11-01
Posts: 7

Re: Spotify script for Conky

Hello, great job but I'm facing some issues and I wonder if you could help me.
If the bash script files are changed to executable conky won't load. If I remove the x attribute it loads but the scripts won't work (as expected). The weirdest thing is that the scripts work separately (they can be run in on a terminal) but the output is not presented on conky (cause conky won't load).
Has anyone faced something similar?
Thank you

Last edited by vanderlaars (2014-11-01 11:59:24)

Offline

#7 2014-11-01 12:23:55

mystyfly
Member
Registered: 2013-03-25
Posts: 30

Re: Spotify script for Conky

Hi vanderlaars, bash scripts executed by conky should be executable (like all bash scripts). How does .conkyrc look like? Have you checked whether the bash scripts are actually being executed? And whether they produce errors?

Offline

#8 2014-11-01 14:18:12

vanderlaars
Member
Registered: 2014-11-01
Posts: 7

Re: Spotify script for Conky

Hello Mystyfly, thank you for your answer.
I'm no newbie to Linux. I'm not a bash expert but I know about the file "properties". wink
It was (like I wrote) expected that the bash scripts wouldn't be run after I removed the execution property of them. I just wanted to check if it was this that kept my conky from loading. And it was that.
My conkyrc (conky.conf) is somewhat large but it's the spotify part (copied from the code that Dexxt published) that's causing the problem. Here it is:

${voffset 4}${font DroidSans:bold:size=8}${color4}SPOTIFY${offset 8}${color8}${voffset -2}${hr 2}${font}
${if_running spotify}${voffset -2}${font Liberation Sans:style=Bold:size=8}
${voffset -10}${goto 73}Title:
${goto 73}${color2}${exec ~/conkyscripts/.spotify/spotify_info_title}${color}
${goto 73}Artist:
${goto 73}${color2}${exec ~/conkyscripts/.spotify/spotify_info_artist}${color}
${goto 73}Album:
${goto 73}${color2}${exec ~/conkyscripts/.spotify/spotify_info_album}${color}
${voffset -20}
${exec ~/conkyscripts/.spotify/spotify_album_cover}
${image ~/conkyscripts/.spotify/last_album_pic.png -p 0,604 -s 60x60}
${else}${voffset -5}${color0}${font ConkyColors:size=16}G${font}${color}${voffset -10}${goto 32}Spotify: ${color2}off${color}${voffset 7}
${endif}

It's the same code only adapted to my system (directories).

Offline

#9 2014-11-01 15:21:31

mystyfly
Member
Registered: 2013-03-25
Posts: 30

Re: Spotify script for Conky

If it's a code-specific problem then you should probably wait from a response from Dexxt, I don't use his script myself. I can't really tell why conky wouldn't load without seeing any error message or something similar.

FWIW, I created a similar script that reads dbus information about clementine (since that's the music player I use) and displays the data on conky. However, I put all the scripting into the bash script, so it's clearer and easier to use and also that all data is retrieved by one single call (rather than calling for each attribute separately). My bash script outputs "conky code" that is added to conky with "execpi". You can have a look at it here.

Offline

#10 2014-11-01 15:21:45

vanderlaars
Member
Registered: 2014-11-01
Posts: 7

Re: Spotify script for Conky

Does conky need special permission to run exec? Cause this is what seems to be the problem.

Offline

#11 2014-11-01 15:24:32

vanderlaars
Member
Registered: 2014-11-01
Posts: 7

Re: Spotify script for Conky

Hello again Mystyfly, thank you once again for your answer.
Will have a look at your script now. And yeah, I agree that calling three bashscripts and I've seen a few spotify examples around but Dexxts was the one that looked better. wink
I will look now at your solution. smile
Thank you once again.

Offline

#12 2014-11-01 15:42:59

mystyfly
Member
Registered: 2013-03-25
Posts: 30

Re: Spotify script for Conky

No, conky shouldn't require special permissions, if the user that started conky is the same user that owns the scripts. Have you tried running other scripts (like "echo foo") from conky? That could help tell you where the problem lies... Is there no output from conky that points you in that direction?

Offline

#13 2014-11-01 17:34:13

Dexxt
Member
From: ES, FR, IT
Registered: 2014-02-25
Posts: 26
Website

Re: Spotify script for Conky

Hi @mystyfly!

Could you please paste here the output of:

ls -la ~/.conkycolors/spotify

that could be fast to understand your problem!

Offline

#14 2014-11-01 17:50:41

mystyfly
Member
Registered: 2013-03-25
Posts: 30

Re: Spotify script for Conky

You probably meant vanderlaars wink

Offline

#15 2014-11-01 18:02:15

vanderlaars
Member
Registered: 2014-11-01
Posts: 7

Re: Spotify script for Conky

Hello Dexxt, it was actually me who's having issues.
Here's my result:

-rw-rw-r-- 1 olivju olivju 20761 Nov  1 16:40 last_album_pic.png
-rwxrwxrwx 1 olivju olivju   953 Oct 31 21:16 spotify_album_cover
-rwxrwxrwx 1 olivju olivju   924 Oct 31 21:09 spotify_info_album
-rwxrwxrwx 1 olivju olivju   951 Oct 31 21:09 spotify_info_artist
-rwxrwxrwx 1 olivju olivju   925 Oct 31 21:09 spotify_info_title
olivju@4MO-R4V1-A016:~/conkyscripts/.spotify$ ls -al > result.txt

As you can see, all bash files are executable and I changed the permissions so everyone can read/write and execute. It shouldn't be a problem but conky won't load if the files exe executable.

Offline

#16 2014-11-01 19:04:42

vanderlaars
Member
Registered: 2014-11-01
Posts: 7

Re: Spotify script for Conky

Hey Mystyfly, could you please publish some screenshot with your conky???? PLZ???? big_smile

Offline

#17 2014-11-01 20:07:45

mystyfly
Member
Registered: 2013-03-25
Posts: 30

Re: Spotify script for Conky

2014-11-01-195828_1600x900_scrot.png

It is slightly different when playing internet radio or when playback is paused.

edit: relevant conky code:

# MUSIC
${execpi 5 $HOME/git/linux-scripts/conky/clementine-dbus $HOME/git/linux-scripts/conky/rp.png}

Last edited by mystyfly (2014-11-01 20:09:43)

Offline

#18 2014-11-02 14:30:29

Dexxt
Member
From: ES, FR, IT
Registered: 2014-02-25
Posts: 26
Website

Re: Spotify script for Conky

vanderlaars,
have you tried moving the .spotify folder inside ./conkycolors?

cp -r ~/conkyscripts/.spotify ~/.conkycolors/spotify

because the script  may need a common root.

Last edited by Dexxt (2014-11-02 14:31:34)

Offline

#19 2014-11-02 20:45:13

vanderlaars
Member
Registered: 2014-11-01
Posts: 7

Re: Spotify script for Conky

Hey Mystyfly, thank you for your answer. Busy day today but I finally had time to test your code:

FluxBB bbcode test

Now I need to tweak a little more to get the rest done.PS: I also had to install Clementine and teh spotify plugin but I'm happy I did it. smile
Thank you very much!!!

Offline

Board footer

Powered by FluxBB