Guess what, I want to display the tracks I'm listening on my desktop in a conky ;-)
But as there are more radios than "FIP radio" and because the script was not difficult to write, the conky came more "universal" (sorry, a big word for a little thing).
You need conky 1.8.0 because the script use cairo_text_extents_t structure for text alignment.
The script can be downloaded from ubuntu forums : here.
First, I said I don't want a ugly player, so I use vlc with the http interface, like this :
vlc --intf=http http://www.tv-radio.com/station/fip_mp3/fip_mp3-128k.m3u
there are others interfaces or others methods to hide a player but I like vlc!
I can control volume with my keyboard or with my browser at this address :
http://localhost:8080/
The conky itself doesn't get the track information. This is done by a bash script, (I made one for FIP here but for others radios, you have to work a little bit ...) which write the information in a text file.
So, the conky needs only this text file in input with at least one of the lines bellow (order doesn't matter):
radio:__FIP radio__
artist:Sonny Rollins
title:Come, Gone
album:Way out West
label:Contemporary
year:1957
cover:/tmp/radio-cover
I will call this file :
/tmp/radio.txt
In the conkyrc, as usual, call the Lua script :
lua_load ~/scripts/radio-box.lua
lua_draw_hook_post main_radio_box /tmp/radio.txt
TEXT
${execi 15 ~/scripts/generate-track-information.sh}
You can see that the
main_radio_box
function needs one parameter : the track information file generated by the generate-track-information.sh
.In fact, the function can have 17 parameters but only the first one is mandatory.
If you run the script with only the first parameter, you get that :
useless, isn't it ?
Now, let's add some parameters on the main function :
The x, y coordinates of the top-left corner, to move the box :
lua_draw_hook_post main_radio_box /tmp/radio.txt 100 25
The font and the font size, to change the display :
lua_draw_hook_post main_radio_box /tmp/radio.txt 10 10 Purisa 15
The informations to display, in the form ATBLYR where :
A=Artist
T=Track
B=Album
L=Label
Y=Year
R=Radio
Example :
lua_draw_hook_post main_radio_box /tmp/radio.txt 10 10 Japan 15 RATBLY
Here you can see that the box auto-fit the text, both in height and width.
The cover.
If your script get the cover, you can display it, just set the path in the file
/tmp/radio.txt
. To display, the cover use 1
, other caracter to not display.lua_draw_hook_post main_radio_box /tmp/radio.txt 10 10 Japan 15 RATBLY 1
If there is less text to dispaly, the cover will resize to the height of the text frame, like this
lua_draw_hook_post main_radio_box /tmp/radio.txt 10 10 Japan 15 ATB 1
The border size :
(In a reel conky, you should write all the parameters on one single line)
lua_draw_hook_post main_radio_box /tmp/radio.txt 10 10 Japan 15 ATBY
1 7
The radius of the corners:
lua_draw_hook_post main_radio_box /tmp/radio.txt 10 10 Japan 15 ATBY
1 3 15
lua_draw_hook_post main_radio_box /tmp/radio.txt 10 10 Japan 15 ATB
1 0 0
Bye, Sonny...
The gap between the two frames:
lua_draw_hook_post main_radio_box /tmp/radio.txt 10 10 Japan 15 ATB
1 3 3 60
The light effect source, possibles values are :
nw : Nord-West (default)
nn : North-North
ne : North-East
ee : East-East
se : South-East
ss : South-South
sw : South-West
ww : West-West
Example for North-North :
lua_draw_hook_post main_radio_box /tmp/radio.txt 10 10 Japan 15 ATB
1 3 3 10 nn
The colors of the frame (it's a linear gradient but if the two values are the same, there is no more gradient):
lua_draw_hook_post main_radio_box /tmp/radio.txt 10 10 Japan 15 ATB
1 3 3 10 ee
FF0000 FFFF00 1 1
The colors of the text :
lua_draw_hook_post main_radio_box /tmp/radio.txt 10 10 Japan 15
ATB 1 3 3 10 ee
F00F00 FCFFC0 1 1 00FF00 00FFFF 1 1
The colors of the border (the same of the main frame if they are not defined, but inversed)
lua_draw_hook_post main_radio_box /tmp/radio.txt 10 10 Japan 15 ATB
1 5 5 10 sw
CCCCCC 000000 1 1 FFFF00 FFFFFF 1 1 000000 DDDDDD 1 1
More classical :
lua_draw_hook_post main_radio_box /tmp/radio.txt 10 10 Japan 15 ATB
1 2 0 10 ww
CCCCCC CCCCCC 1 1 000000 000000 1 1 000000 000000 1 1
While writing this note I add parameters for transparancy:
lua_draw_hook_post main_radio_box /tmp/radio.txt 10 10 Japan 15 ATBLY
1 5 5 10 nw
000000 FFFFFF 0.3 0.3 FF0000 FF0000 0.5 0.5 000000 000000 1 0.2
I think I will add some effects on the cover if I can in the future.