You are not logged in.
Pages: 1
Here's a lua script I've been working on. It fetches the album cover art, best guess, from the albumart.org. The script uses album & artist info to get the album cover art. Works with moc, audacious, gmusicbrowser, clementine, exaile, quodlibet, clementine, guayadeque, decibel, qmmp.
You need to install imagemagick to create the round images. This is the debian, and variations of debian, command.
sudo apt-get install imagemagick
Add these lines to your conky config section, above TEXT.
lua_load /where/the/script/is/albumart-v2.7.lua
lua_draw_hook_pre main
Download this file for the script and other important files.
--[[#################################
--Version 2.7
--By: Tony Kernan
--ackernan@gmail.com
--
-- 1.1 -Combined capability to play moc and audacious and added gmusicbrowser. Changed url for album cover art.
-- 1.2 - Added selection for indicator bar, ring, or no indicator. You can change the shape, size, and color of the indicator by going to the progress_indicator function at around line 287
-- 2.0 - Added round cover art image for ring progress bar. Image size & placement can be changed in setup section, about line 47. Bar indicator parameters start about line 260. Ring indicator parameters start about line 333.
-- 2.5 - Added other players
-- 2.6 - Changed place for album art & way to make round pictures.
-- 2.7 - Fixed memory leak.
--#################################
]]
require 'cairo'
require 'imlib2'
-- start of main() function
function conky_main()
--#####################################################
--SETTINGS
-- #####################################################
bar_x=50-- x = picture horizontal position
bar_y=40-- y = picture vertical position
ring_x=40-- x = picture horizontal position
ring_y=62-- y = picture vertical position
bar_h=100-- h = bar picture height
bar_w=100-- w = bar picture width
ring_h=120-- h = ring picture height
ring_w=120-- w = ring picture width
player="audacious" --can be moc, audacious, gmusicbrowser, clementine, exaile, quodlibet, clementine, guayadeque, decibel, qmmp
progress_bar="ring" --can be bar, ring, or none
font="santana-black" -- font name
font_size=12 -- font size
xpos,ypos=5,15 -- text position
red,green,blue,alpha=1,1,0,1 --font color
font_slant=CAIRO_FONT_SLANT_NORMAL
font_face=CAIRO_FONT_WEIGHT_NORMAL
--###########################################
-- End setup section
--##########################################
--##########################################
---check player type
--##########################################
currenttimecmd,currenttimesecscmd,totaltimecmd,totaltimesecscmd,songcmd,artistcmd,albumcmd,musicfilecmd=playertype()
--#########################################
if conky_window == nil then return end
local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
cr = cairo_create(cs)
local update_num=tonumber(conky_parse('${updates}'))
--################################################################
--song info if player is running ####################################
--################################################################
playerrunning=conky_parse(playercmd)
player2running=conky_parse(player2cmd)
if tonumber(playerrunning) or tonumber(player2running)==1 then
if currenttimecmd == 0 then
if player=="clementine" or player=="quodlibet" or player=="guayadeque" or player=="decibel" or player=="qmmp" then
dividebyonek()
currenttimesecs=newtimesecs
else
local f = io.popen(currenttimesecscmd)
currenttimesecs = f:read("*a")
f:close()
end --end if currenttimesecs divide by 1000
myMinutes=secs2mins(currenttimesecs)
currenttime=myMinutes
else
local f = io.popen(currenttimecmd)
currenttime= f:read("*a")
f:close()
currenttime=string.gsub(currenttime,"[\n]","")
end --end currenttime if
--get current time in seconds
if currenttimesecscmd ==0 then
mySeconds=min2secs(currenttime)
currenttimesecs=mySeconds
else
if player=="clementine"or player=="quodlibet" or player=="guayadeque" or player=="decibel" or player=="qmmp" then
dividebyonek()
currenttimesecs=newtimesecs
else
local f = io.popen(currenttimesecscmd)
currenttimesecs = f:read("*a")
f:close()
end -- end if currenttimesecs divide by 1000
end --end above current time secs if
---##############################
--[[ if current time is 0 ie start of new song
if conky starts while moc is running you want to activate the function
so im using a one off check on update_num also
]]
if tonumber(currenttimesecs)==0 or update_num==1 then
totaltime,totaltimesecs,song,artist,album,albumart=newsong(update_num)
end --end of above tonumber
--progress_indictor function call
progress_bar=progress_indicator()
end--end if playerrunning
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
end--end function
-----------------
function newsong()
local f = io.popen(albumcmd)
local album= f:read("*a")
f:close()
album=string.gsub(album,"[\n]","")
local f = io.popen(artistcmd)
local artist= f:read("*a")
f:close()
artist=string.gsub(artist,"[\n]","")
local f = io.popen(songcmd)
local song= f:read("*a")
f:close()
song=string.gsub(song,"[\n]","")
if totaltimecmd==0 then
local f = io.popen(totaltimesecscmd)
totaltimesecs= f:read("*a")
f:close()
totaltimesecs=string.gsub(totaltimesecs,"[\n]","")
myMinutes=secs2mins(totaltimesecs)
totaltime=myMinutes
else
local f = io.popen(totaltimecmd)
totaltime= f:read("*a")
f:close()
totaltime=string.gsub(totaltime,"[\n]","")
end --end totaltime if
if totaltimesecscmd==0 then
local f = io.popen(totaltimecmd)
totaltime= f:read("*a")
f:close()
totaltime=string.gsub(totaltime,"[\n]","")
mySeconds=min2secs(totaltime)
totaltimesecs=mySeconds
else
local f = io.popen(totaltimesecscmd)
totaltimesecs= f:read("*a")
f:close()
totaltimesecs=string.gsub(totaltimesecs,"[\n]","")
end --end totaltimesecs if
--end of song info gathering
--image art fetching code
local f = io.popen(musicfilecmd)
local musicfile= f:read("*a")
f:close()
musicfile=string.gsub(musicfile,"[\n]","")
musicfile=string.gsub(musicfile,"%%20","\ ")
musicfile='\"'..musicfile..'\"'
local f = io.popen("dirname "..musicfile)
local musicdir= f:read("*a")
f:close()
musicdir=string.gsub(musicdir,"[\n]","")
local f=io.open(musicdir.."/cover.png","r") --does cover.png exist
if f~=nil then
f:close()
albumart=musicdir..'/cover.png'
else
--Get cover
local newalbum=string.gsub(album,"\ &","")
newalbum=string.gsub(newalbum,",","")
newalbum=string.gsub(newalbum,"\!","")
newalbum=string.gsub(newalbum,"\'","")
newalbum=string.gsub(newalbum,'[[]',"")
newalbum=string.gsub(newalbum,'[]]',"")
newalbum=string.gsub(newalbum,"-\ ","")
newalbum=string.gsub(newalbum,"-","")
newalbum=string.gsub(newalbum,"[(]","")
newalbum=string.gsub(newalbum,"[)]","")
newalbum=string.gsub(newalbum,"\ ","+")
newalbum=string.gsub(newalbum,"%.","+")
local newartist=string.gsub(artist,"\ &","")
newartist=string.gsub(newartist,",","")
newartist=string.gsub(newartist,"\!","")
newartist=string.gsub(newartist,"\'","")
newartist=string.gsub(newartist,"\ ","+")
local f= io.popen("curl -s 'http://www.albumart.org/index.php?srchkey="..newalbum.."+"..newartist.."&itempage=1&newsearch=1&searchindex=Music' |grep -o 'http://ecx.images-amazon.com/images/I/[^\"]*.jpg'|sed -n 1p")
local searchresults= f:read("*a")
f:close()
if not string.match(searchresults, "\n")
then
albumart=os.getenv("HOME")..'/Pictures/No_Cover_.jpg'
else
os.execute('wget -O \"'..musicdir..'/cover.png\" '..searchresults..'')
albumart=musicdir..'/cover.png'
end --end empty searchresluts check
end --end cover.png exist check
local f=io.open(musicdir.."/rnd_cover.png","r") --does rnd-cover.png exist
if f~=nil then
f:close()
rndalbumart=musicdir..'/rnd_cover.png'
else
local rnd_mask=os.getenv("HOME")..'/rnd_mask.png'
os.execute('convert -resize 80x80 -alpha set \"'..musicdir..'/cover.png\" -gravity center -extent 80x80 '..rnd_mask..' -compose DstIn -composite \"'..musicdir..'/rnd_cover.png\"')
rndalbumart=musicdir..'/rnd_cover.png'
end -- end if for round album art
return totaltime,totaltimesecs,song,artist,album,albumart
end--function
function playertype()
player=string.lower(player)
if player=="moc" then
---------------------moc/mocp----------------------------
playercmd="${if_running mocp}1${else}0${endif}"
player2cmd=""
currenttimecmd="mocp -Q %ct"
currenttimesecscmd="mocp -Q %cs"
albumcmd="mocp -Q %album"
artistcmd="mocp -Q %artist"
songcmd="mocp -Q %song"
totaltimecmd="mocp -Q %tt"
totaltimesecscmd="mocp -Q %ts"
musicfilecmd="mocp -Q %file"
elseif player=="audacious" then
---------------------audacious---------------------------
playercmd="${if_running audacious}1${else}0${endif}"
player2cmd="${if_running audacious2}1${else}0${endif}"
currenttimecmd="audtool current-song-output-length"
currenttimesecscmd="audtool current-song-output-length-seconds"
albumcmd="audtool current-song-tuple-data album"
artistcmd="audtool current-song-tuple-data artist"
songcmd="audtool current-song-tuple-data title"
totaltimecmd="audtool current-song-length"
totaltimesecscmd="audtool current-song-length-seconds"
musicfilecmd="audtool current-song-filename"
elseif player=="gmusicbrowser" then
------------------------------gmusicbrowser------------------------
playercmd="${if_running gmusicbrowser.pl}0${else}1${endif}"
player2cmd=""
currenttimecmd=0
currenttimesecscmd="dbus-send --print-reply --session --dest=org.gmusicbrowser /org/gmusicbrowser org.gmusicbrowser.GetPosition |grep double |awk '{print $2}'"
albumcmd="dbus-send --print-reply --session --dest=org.gmusicbrowser /org/gmusicbrowser org.gmusicbrowser.CurrentSong |grep -A 1 album|sed -n 5p|awk -F '\"' '{print $2}'"
artistcmd="dbus-send --print-reply --session --dest=org.gmusicbrowser /org/gmusicbrowser org.gmusicbrowser.CurrentSong |grep -A 1 album_artist|sed -n 2p |awk -F '\"' '{print $2}'"
songcmd="dbus-send --print-reply --session --dest=org.gmusicbrowser /org/gmusicbrowser org.gmusicbrowser.CurrentSong |grep -A 1 title|sed -n 2p|awk -F '\"' '{print $2}'"
totaltimecmd=0
totaltimesecscmd="dbus-send --print-reply --session --dest=org.gmusicbrowser /org/gmusicbrowser org.gmusicbrowser.CurrentSong |grep -A 1 length|sed -n 2p|awk -F '\"' '{print $2}'"
musicfilecmd="dbus-send --print-reply --session --dest=org.gmusicbrowser /org/gmusicbrowser org.gmusicbrowser.CurrentSong |grep -A 1 uri|sed -n 2p|awk -F '\"' '{print $2}'|cut -c8-"
-------------clementine----------------------divide by 1000
elseif player == "clementine" then
playercmd="${if_running clementine}1${else}0${endif}"
player2cmd=""
currenttimecmd=0
currenttimesecscmd="dbus-send --print-reply --session --dest=org.mpris.clementine /Player org.freedesktop.MediaPlayer.PositionGet|grep int32| awk '{print $2}'"
albumcmd="dbus-send --print-reply --session --dest=org.mpris.clementine /Player org.freedesktop.MediaPlayer.GetMetadata |grep -A 1 album|sed -n 2p|awk -F '\"' '{print $2}'"
artistcmd="dbus-send --print-reply --session --dest=org.mpris.clementine /Player org.freedesktop.MediaPlayer.GetMetadata |grep -A 1 artist|sed -n 2p|awk -F '\"' '{print $2}'"
songcmd="dbus-send --print-reply --session --dest=org.mpris.clementine /Player org.freedesktop.MediaPlayer.GetMetadata |grep -A 1 title|sed -n 2p|awk -F '\"' '{print $2}'"
totaltimecmd=0
totaltimesecscmd="dbus-send --print-reply --session --dest=org.mpris.clementine /Player org.freedesktop.MediaPlayer.GetMetadata |grep -A 1 '\"time'|sed -n 2p|awk '{print $3}'"
musicfilecmd="dbus-send --print-reply --session --dest=org.mpris.clementine /Player org.freedesktop.MediaPlayer.GetMetadata |grep -A 1 location|sed -n 2p|awk -F '\"' '{print $2}'|cut -c8-"
------------------------exaile--------------------------
elseif player == "exaile" then
playercmd="${if_running exaile}1${else}0${endif}"
player2cmd=""
currenttimecmd="exaile --current-position"
currenttimesecscmd=0
albumcmd="exaile -q|awk -F ',' '{print $4}'|awk -F ':' '{print $2}'"
artistcmd="exaile -q|awk -F ',' '{print $2}'|awk -F ':' '{print $2}'"
songcmd="exaile -q|awk -F ',' '{print $2}'|awk -F ':' '{print $2}'"
totaltimecmd=0
totaltimesecscmd="dbus-send --print-reply --dest=org.exaile.Exaile /Player org.freedesktop.MediaPlayer.GetMetadata|grep -A 1 time|sed -n 2p|awk '{print $3}'"
musicfilecmd="dbus-send --print-reply --dest=org.exaile.Exaile /Player org.freedesktop.MediaPlayer.GetMetadata|grep -A 1 location|sed -n 2p|awk -F'\"' '{print $2}'|cut -c8-"
-----------------Quodlibet------------------------ divide by 1000
elseif player == "quodlibet" then
playercmd="${if_running quodlibet}1${else}0${endif}"
player2cmd=""
currenttimecmd=0
currenttimesecscmd="dbus-send --print-reply --dest=net.sacredchao.QuodLibet /net/sacredchao/QuodLibet net.sacredchao.QuodLibet.GetPosition|sed -n 2p|awk '{print $2}'"
albumcmd="quodlibet --print-playing|awk -F '-' '{print $2}'"
artistcmd="quodlibet --print-playing|awk -F '-' '{print $1}'"
songcmd="quodlibet --print-playing|awk -F '-' '{print $4}'"
totaltimecmd=0
totaltimesecscmd="dbus-send --print-reply --dest=net.sacredchao.QuodLibet /net/sacredchao/QuodLibet net.sacredchao.QuodLibet.CurrentSong|grep -A 1 length|sed -n 2p|awk -F '\"' '{print $2}'"
musicfilecmd="grep -i 'filename' ~/.quodlibet/current |awk -F '=' '{print $2}'"
-----------------guayadeque------------------------ divide by 1000
elseif player == "guayadeque" then
playercmd="${if_running guayadeque}1${else}0${endif}"
player2cmd=""
currenttimecmd=0
currenttimesecscmd="dbus-send --print-reply --dest=org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.PositionGet|grep int|awk '{print $2}'"
albumcmd="dbus-send --print-reply --dest=org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.GetMetadata |grep -A 1 album|sed -n 2p|awk -F '\"' '{print $2}'"
artistcmd="dbus-send --print-reply --dest=org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.GetMetadata |grep -A 1 artist|sed -n 2p|awk -F '\"' '{print $2}'"
songcmd="dbus-send --print-reply --dest=org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.GetMetadata |grep -A 1 title|sed -n 2p|awk -F '\"' '{print $2}'"
totaltimecmd=0
totaltimesecscmd="dbus-send --print-reply --dest=org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.GetMetadata |grep -A1 '\"time'|sed -n 2p|awk '{print $3}'"
musicfilecmd="dbus-send --print-reply --dest=org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.GetMetadata| grep -A1 location|sed -n 2p|awk -F'\"' '{print $2}'|cut -c8-"
-----------------decibel------------------------ divide by 1000
elseif player == "decibel" then
playercmd="${if_running decibel-audio-player.py}0${else}1${endif}"
player2cmd=""
currenttimecmd=0
currenttimesecscmd="dbus-send --print-reply --dest=org.mpris.dap /Player org.freedesktop.MediaPlayer.PositionGet|grep int|awk '{print $2}'"
albumcmd="dbus-send --print-reply --dest=org.mpris.dap /Player org.freedesktop.MediaPlayer.GetMetadata |grep -A 1 album|sed -n 2p|awk -F '\"' '{print $2}'"
artistcmd="dbus-send --print-reply --dest=org.mpris.dap /Player org.freedesktop.MediaPlayer.GetMetadata |grep -A 1 artist|sed -n 2p|awk -F '\"' '{print $2}'"
songcmd="dbus-send --print-reply --dest=org.mpris.dap /Player org.freedesktop.MediaPlayer.GetMetadata |grep -A 1 title|sed -n 2p|awk -F '\"' '{print $2}'"
totaltimecmd=0
totaltimesecscmd="dbus-send --print-reply --dest=org.mpris.dap /Player org.freedesktop.MediaPlayer.GetMetadata |grep -A1 '\"time'|sed -n 2p|awk '{print $3}'"
musicfilecmd="dbus-send --print-reply --dest=org.mpris.dap /Player org.freedesktop.MediaPlayer.GetMetadata| grep -A1 location|sed -n 2p|awk -F'\"' '{print $2}'|cut -c8-"
---------------------------qmmp---------------------divide by 1000
elseif player == "qmmp" then
playercmd="${if_running qmmp}1${else}0${endif}"
player2cmd=""
currenttimecmd=0
currenttimesecscmd="dbus-send --print-reply --dest=org.mpris.qmmp /Player org.freedesktop.MediaPlayer.PositionGet|grep int|awk '{print $2}'"
albumcmd="dbus-send --print-reply --dest=org.mpris.qmmp /Player org.freedesktop.MediaPlayer.GetMetadata |grep -A 1 album|sed -n 2p|awk -F '\"' '{print $2}'"
artistcmd="dbus-send --print-reply --dest=org.mpris.qmmp /Player org.freedesktop.MediaPlayer.GetMetadata |grep -A 1 artist|sed -n 2p|awk -F '\"' '{print $2}'"
songcmd="dbus-send --print-reply --dest=org.mpris.qmmp /Player org.freedesktop.MediaPlayer.GetMetadata |grep -A 1 title|sed -n 2p|awk -F '\"' '{print $2}'"
totaltimecmd=0
totaltimesecscmd="dbus-send --print-reply --dest=org.mpris.qmmp /Player org.freedesktop.MediaPlayer.GetMetadata |grep -A1 '\"time'|sed -n 2p|awk '{print $3}'"
musicfilecmd="dbus-send --print-reply --dest=org.mpris.qmmp /Player org.freedesktop.MediaPlayer.GetMetadata| grep -A1 location|sed -n 2p|awk -F'\"' '{print $2}'|cut -c8-"
end --end if statement
return currenttimecmd,currenttimesecscmd,totaltimecmd,totaltimesecscmd,songcmd,artistcmd,albumcmd,musicfilecmd
end ---end playertype function
--divide by 1000 function
function dividebyonek()
local f = io.popen(currenttimesecscmd)
newtimesecs = f:read("*a")
f:close()
newtimesecs=string.gsub(newtimesecs,"L","")
newtimesecs=newtimesecs/1000
if math.abs(newtimesecs) < 1 then newtimesecs=0
end --end newtimesecs if
return newtimesecs
end --end function
--function to change seconds to minutes
function secs2mins(a)
local nSeconds = tonumber(a)
if nSeconds == 0 then
else
nMins = string.format("%02.f", math.floor(nSeconds/60));
nSecs = string.format("%02.f", math.floor(nSeconds - nMins *60));
myMinutes=nMins..":"..nSecs
return myMinutes
end --end if
end -- end secs2mins function
--function to change minutes to seconds
function min2secs(a)
local minutes2secs=tonumber(a)
if minutes2secs==0 then
else
local f = io.popen("echo "..(a).."|awk -F ':' '{print $1}'")
minutes = f:read("*a")
f:close()
local f = io.popen("echo "..(a).."|awk -F ':' '{print $2}'")
seconds = f:read("*a")
f:close()
mySeconds=(minutes*60)+seconds
return mySeconds
end --end if
end -- end minute2secs function
function progress_indicator()
--make progress_bar lower case
progress_bar=string.lower(progress_bar)
if progress_bar == "bar" then
--Music progress bar
bar_bottom_left_x= 5
bar_bottom_left_y= 175
bar_width= 15
bar_height= 190
--set bar background colors, 0,0,0,1 = fully opaque black
bar_bg_red=0
bar_bg_green=0
bar_bg_blue=0
bar_bg_alpha=1
--set bar indicator colors, 1,1,1,1 = fully opaque white
bar_in_red=1
bar_in_green=1
bar_in_blue=1
bar_in_alpha=1
--draw progress bar background
cairo_set_source_rgba (cr,bar_bg_red,bar_bg_green,bar_bg_blue,bar_bg_alpha)
cairo_rectangle (cr,bar_bottom_left_x,bar_bottom_left_y,bar_height,bar_width)
cairo_fill (cr)
--draw progress bar indicator
cairo_set_source_rgba (cr,bar_in_red,bar_in_green,bar_in_blue,bar_in_alpha)--set indicator color
local value=currenttimesecs
local max_value=totaltimesecs
scale=bar_height/max_value
indicator_height=scale*value
cairo_rectangle (cr,bar_bottom_left_x,bar_bottom_left_y,indicator_height,bar_width)
cairo_fill (cr)
--################
--display info code
----------------
cairo_select_font_face (cr, font, font_slant, font_face);
cairo_set_font_size (cr, font_size)
cairo_set_source_rgba (cr,red,green,blue,alpha)
cairo_move_to (cr,xpos,ypos)
cairo_show_text (cr,'Album: '..(album))
cairo_move_to (cr,xpos,ypos+10)
cairo_show_text (cr, 'Artist: ' ..(artist))
cairo_move_to (cr,xpos,ypos+20)
cairo_show_text (cr, 'Song: ' ..(song))
cairo_move_to (cr,xpos,ypos+140)
cairo_show_text (cr, "Current Time")
cairo_move_to (cr,xpos+15,ypos+150)
cairo_show_text (cr, (currenttime))
cairo_move_to (cr,xpos+125,ypos+140)
cairo_show_text (cr, "Total Time")
cairo_move_to (cr,xpos+140,ypos+150)
cairo_show_text (cr, (totaltime))
cairo_stroke (cr)
--image display code
local show = imlib_load_image(albumart)
if show == nil then return end
imlib_context_set_image(show)
if tonumber(bar_w)==0 then
width=imlib_image_get_width()
else
width=tonumber(bar_w)
end -- end width tonumber
if tonumber(bar_h)==0 then
height=imlib_image_get_height()
else
height=tonumber(bar_h)
end -- end height tonumber
imlib_context_set_image(show)
local scaled=imlib_create_cropped_scaled_image(0, 0, imlib_image_get_width(), imlib_image_get_height(), width, height)
imlib_free_image()
imlib_context_set_image(scaled)
imlib_render_image_on_drawable(bar_x, bar_y)
imlib_free_image()
show=nil
elseif
progress_bar == "ring" then
--SETTINGS for ring progress bar
--rings size
ring_center_x=100 --ring center side/side
ring_center_y=120 --ring center up/down
ring_radius=70
ring_width=20
--colors
--set background colors, 0,0,0,1 = fully opaque black
ring_bg_red=0
ring_bg_green=0
ring_bg_blue=0
ring_bg_alpha=1
--set indicator colors, 1,1,1,1 = fully opaque white
ring_in_red=1
ring_in_green=1
ring_in_blue=1
ring_in_alpha=1
--indicator value settings
local value=currenttimesecs
local max_value=totaltimesecs
--draw background
cairo_set_line_width (cr,ring_width)
cairo_set_source_rgba (cr,ring_bg_red,ring_bg_green,ring_bg_blue,ring_bg_alpha)
cairo_arc (cr,ring_center_x,ring_center_y,ring_radius,0,2*math.pi)
cairo_stroke (cr)
end_angle=value*(360/max_value)
--draw indicator
cairo_set_line_width (cr,ring_width)
end_angle=value*(360/max_value)
cairo_set_source_rgba (cr,ring_in_red,ring_in_green,ring_in_blue,ring_in_alpha)
cairo_arc (cr,ring_center_x,ring_center_y,ring_radius,(-90)*(math.pi/180),(end_angle-90)*(math.pi/180))
cairo_stroke (cr)
--################
--display info code
----------------
cairo_select_font_face (cr, font, font_slant, font_face);
cairo_set_font_size (cr, font_size)
cairo_set_source_rgba (cr,red,green,blue,alpha)
cairo_move_to (cr,xpos,ypos)
cairo_show_text (cr,'Album: '..(album))
cairo_move_to (cr,xpos,ypos+10)
cairo_show_text (cr, 'Artist: ' ..(artist))
cairo_move_to (cr,xpos,ypos+20)
cairo_show_text (cr, 'Song: ' ..(song))
cairo_move_to (cr,xpos,ypos+190)
cairo_show_text (cr, "Current Time")
cairo_move_to (cr,xpos+15,ypos+200)
cairo_show_text (cr, (currenttime))
cairo_move_to (cr,xpos+125,ypos+190)
cairo_show_text (cr, "Total Time")
cairo_move_to (cr,xpos+140,ypos+200)
cairo_show_text (cr, (totaltime))
cairo_stroke (cr)
--image display code
--display_round(albumart,ring_x,ring_y,radius,angle,radius_crop)
--image display code
local show = imlib_load_image(rndalbumart)
if show == nil then return end
imlib_context_set_image(show)
if tonumber(ring_w)==0 then
width=imlib_image_get_width()
else
width=tonumber(ring_w)
end -- end width tonumber
if tonumber(ring_h)==0 then
height=imlib_image_get_height()
else
height=tonumber(ring_h)
end -- end height tonumber
imlib_context_set_image(show)
local scaled=imlib_create_cropped_scaled_image(0, 0, imlib_image_get_width(), imlib_image_get_height(), width, height)
imlib_free_image()
imlib_context_set_image(scaled)
imlib_render_image_on_drawable(ring_x, ring_y)
imlib_free_image()
show=nil
elseif
progress_bar == "none" then
cairo_select_font_face (cr, font, font_slant, font_face);
cairo_set_font_size (cr, font_size)
cairo_set_source_rgba (cr,red,green,blue,alpha)
cairo_move_to (cr,xpos,ypos)
cairo_show_text (cr,'Album: '..(album))
cairo_move_to (cr,xpos,ypos+10)
cairo_show_text (cr, 'Artist: ' ..(artist))
cairo_move_to (cr,xpos,ypos+20)
cairo_show_text (cr, 'Song: ' ..(song))
cairo_move_to (cr,xpos,ypos+140)
cairo_show_text (cr, "Current Time")
cairo_move_to (cr,xpos+15,ypos+150)
cairo_show_text (cr, (currenttime))
cairo_move_to (cr,xpos+125,ypos+140)
cairo_show_text (cr, "Total Time")
cairo_move_to (cr,xpos+140,ypos+150)
cairo_show_text (cr, (totaltime))
cairo_stroke (cr)
--image display code
local show = imlib_load_image(albumart)
if show == nil then return end
imlib_context_set_image(show)
if tonumber(bar_w)==0 then
width=imlib_image_get_width()
else
width=tonumber(bar_w)
end -- end width tonumber
if tonumber(bar_h)==0 then
height=imlib_image_get_height()
else
height=tonumber(bar_h)
end -- end height tonumber
imlib_context_set_image(show)
local scaled=imlib_create_cropped_scaled_image(0, 0, imlib_image_get_width(), imlib_image_get_height(), width, height)
imlib_free_image()
imlib_context_set_image(scaled)
imlib_render_image_on_drawable(bar_x, bar_y)
imlib_free_image()
show=nil
end --end progress_bar if statement
return progress_bar
end --end progress function
Last edited by ackernan (2012-03-05 00:32:34)
Offline
Look's good. When my stereo dies I'll have a while bunch to try.
Might take it for a test run though ... time, I need more time... too many things to try.
· ↓ ↓ ↓ ↓ ↓ ↓ ·
BunsenLabs Forums now Open for Registration
· ↑ ↑ ↑ ↑ ↑ ↑ · BL ModSquad
Offline
Thanks guys, it's just a start with me and lua. A learning experience. Thinking of improvements, can they be done, and if I can implement them.
Last edited by ackernan (2012-03-04 12:19:34)
Offline
Memory leak in script has been fixed, thanks to help from Sector11 and MrPeachy. The first post of this thread has been updated.
Offline
Pages: 1
Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.
Server: acrobat