È un po' troppo verso destra(come potete vedere nell'allegato).
conky:
Codice: Seleziona tutto
background no
update_interval 5.0
double_buffer yes
no_buffers yes
own_window yes
own_window_type normal
own_window_transparent yes
own_window_argb_visual yes
own_window_class conky-semi
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
draw_shades no
draw_borders yes
use_xft yes
xftfont Ubuntu:size=8
# Force using utf-8?
override_utf8_locale yes
alignment top_right
minimum_size 300,300
TEXT
${alignc}${font Ubuntu:size=12:style=bold Titling}Music${font}
${execp amarok_infos song}Spoiler
Mostra
Codice: Seleziona tutto
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import argparse
import subprocess
try:
from cStringIO import StringIO
except ImportError:
from StringIO import StringIO
TEMPLATE_SONG = '''\
${{alignc}}${{font Ubuntu:size=10:style=bold Titling}}{title}${{font}}
${{alignc}}{artist}'''
TEMPLATE_TRACKLIST_LINE = '''\
${{alignc}}{title}
${{alignc}}{artist}'''
# objects
PLAYER = 'Player'
TRACKLIST = 'TrackList'
# methods
GET_METADATA = 'GetMetadata'
GET_LENGTH = 'GetLength'
GET_CURRENT_TRACK = 'GetCurrentTrack'
DEFAULT_RETURN_VALUES = {
GET_METADATA: '',
GET_LENGTH: 0,
GET_CURRENT_TRACK: '',
}
def _make_parser():
'''Return a parser object.'''
parser = argparse.ArgumentParser()
parser.add_argument('action', help='The action to be executed.',
choices=('song', 'playlist', 'collection', 'stats'))
return parser
def _parse_song_infos(text):
'''Parses the informations in *text*.'''
return dict(line.rstrip().split(':',1) for line in text.split('\n')
if ':' in line)
def dbus(obj, meth, args=(), url='org.kde.amarok'):
'''Executes a method call over d-bus.'''
args = ' '.join(str(arg) for arg in args)
try:
res = subprocess.check_output('qdbus {url} /{obj} {meth} {args}'
.format(**locals()).split())
except subprocess.CalledProcessError:
res = DEFAULT_RETURN_VALUES.get(meth)
return res
def song():
'''Prints information about the current song being played.'''
output = dbus(PLAYER, GET_METADATA)
if not output:
print('${alignc}No song being played.')
return
infos = _parse_song_infos(output)
info_names = ('title', 'artist')
print(TEMPLATE_SONG.format(**dict((name, infos[name])
for name in info_names)))
def playlist():
'''Prints information about the current playlist.'''
length = int(dbus(TRACKLIST, GET_LENGTH))
if length < 1:
print('No playlist avaiable.')
return
cur_song_num = int(dbus(TRACKLIST, GET_CURRENT_TRACK))
song_infos = [_parse_song_infos(
dbus(TRACKLIST, GET_METADATA, (i,)))
for i in range(min(5, length))]
info_names = ('title', 'artist')
print('%d/%d' % (cur_song_num+1, length))
for infos in song_infos:
print(TEMPLATE_TRACKLIST_LINE.format(title=infos['title'],
artist=infos['artist']))
ACTION_DICT = {
'song' : song,
'playlist': playlist,
}
def main(argv=None):
if argv is None:
argv = sys.argv[1:]
parser = _make_parser()
options = parser.parse_args(argv)
ACTION_DICT[options.action]()
if __name__ == '__main__':
main()