Coucou,
Voilà un morceau de conkyrc pour une tranche de Clementine.
background yes
use_xft yes
xftalpha 0.8
xftfont Bitstream Vera Sans Mono:size=8
own_window yes
own_window_class conky
own_window_argb_visual yes
own_window_hints undecorate,sticky,skip_taskbar,skip_pager,below
own_window_transparent yes
double_buffer yes
no_buffers yes
minimum_size 356 700
alignment tr
override_utf8_locale yes
default_color slategrey
TEXT
${if_running clementine}${color lightgrey}Clementine ${execi 2 python ~/.conky/scripts/clementine.py -z}
${if_empty ${execi 2 python ~/.conky/scripts/clementine.py -z | grep arrêté}}
${voffset 220}${execi 2 python ~/.conky/scripts/clementine.py -a}
${color}Titre : ${color lightgrey}${execi 2 python ~/.conky/scripts/clementine.py -t}
${color}Album : ${color lightgrey}${execi 2 python ~/.conky/scripts/clementine.py -l}
${color}Année : ${color lightgrey}${execi 2 python ~/.conky/scripts/clementine.py -y}
${color}Débit : ${color lightgrey}${execi 2 python ~/.conky/scripts/clementine.py -b} kbit/s
${execi 2 python ~/.conky/scripts/clementine.py -c /tmp/cover.jpg}${image /tmp/cover.jpg -p 22,272 -s 200x200 -n}${endif}${endif}
Et le script clementine.py dérivé de anowplaying.py
#!/usr/bin/env python2
#-*- coding: utf-8 -*-
import dbus, optparse, shutil, commands
if __name__ == '__main__':
'''Check if clementine is running'''
output = commands.getoutput('ps -A')
if 'clementine' not in output:
raise SystemExit
'''Get system bus'''
bus = dbus.SessionBus()
clementine = bus.get_object('org.mpris.clementine', '/Player')
#print ("Introspection data:\n")
#print clementine.Introspect()
#print "\nSatut:\n"
stat = clementine.GetStatus()
#print stat[0]
clementinedict = clementine.GetMetadata()
'''Set up the command line parser'''
usage = 'usage: %prog [options]'
parser = optparse.OptionParser(usage=usage)
parser.add_option('-a', '--artist', action='store_true', help='artist name')
parser.add_option('-t', '--title', action='store_true', help='title of the track')
parser.add_option('-l', '--album', action='store_true', help='album name')
parser.add_option('-g', '--genre', action='store_true', help='genre of the current track')
parser.add_option('-y', '--year', action='store_true', help='year of the track')
parser.add_option('-m', '--mtime', action='store_true', help='time of the track')
parser.add_option('-r', '--rtime', action='store_true', help='remaining time for the track')
parser.add_option('-e', '--etime', action='store_true', help='elapsed time for the track')
parser.add_option('-p', '--progress', action='store_true', help='progress of the track')
parser.add_option('-n', '--track', action='store_true', help='track number')
parser.add_option('-b', '--bitrate', action='store_true', help='bitrate of the track')
parser.add_option('-s', '--sample', action='store_true', help='sample rate of the track')
parser.add_option('-c', '--cover', metavar='filename', help='copy cover art to destination file')
parser.add_option('-z', '--status', action='store_true', help='player status')
'''Get the parser options printed'''
(opts, args) = parser.parse_args()
if opts.artist and clementinedict.has_key('artist') :
print clementinedict['artist']
if opts.title and clementinedict.has_key('title'):
print clementinedict['title']
if opts.album and clementinedict.has_key('album'):
print clementinedict['album']
if opts.genre and clementinedict.has_key('genre'):
print clementinedict['genre']
if opts.year and clementinedict.has_key('year'):
print clementinedict['year']
if opts.track and clementinedict.has_key('tracknumber'):
print clementinedict['tracknumber']
if opts.bitrate and clementinedict.has_key('audio-bitrate'):
print clementinedict['audio-bitrate']
if opts.sample :
print clementinedict['audio-samplerate']
if opts.status :
if stat[0]==2:
print 'arrêté'
elif stat[0]==1:
print 'en pause'
else:
print ""
'''Manage time stuff'''
cpos = mt = mtime = etime = rtime = progress = None
if (opts.etime or opts.rtime or opts.mtime or opts.progress) and clementinedict.has_key('mtime'):
cpos = clementine.PositionGet()/1000
mt = clementinedict['mtime']/1000
mtime = str(mt/60)+":"+str(mt%60) if mt%60>9 else str(mt/60)+":0"+str(mt%60)
etime = str(cpos/60)+":"+str(cpos%60) if cpos%60>9 else str(cpos/60)+":0"+str(cpos%60)
rtime = str((mt-cpos)/60)+":"+str((mt-cpos)%60) if (mt-cpos)%60>9 else str((mt-cpos)/60)+":0"+str((mt-cpos)%60)
progress= float(cpos)/float(mt)*100
if opts.etime and etime is not None:
print etime
if opts.rtime and rtime is not None:
print rtime
if opts.mtime and mtime is not None:
print mtime
if opts.progress and progress is not None:
print progress
if opts.cover :
cover = clementinedict['arturl']
if cover != "" :
try :
shutil.copyfile(cover.replace('file://', ''), opts.cover)
print ""
except Exception, e:
print e
print ""
else :
print ""
Bonne écoute.
I'd love to change the world
But I don't know what to do
So I'll leave it up to you...