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
use_xft yes
xftfont Ubuntu:size=8
# Force using utf-8?
#override_utf8_locale yes
alignment top_right
minimum_size 250,200
TEXT
${alignc}${font Ubuntu Titling}Music${font}
${execp amarok_infos song}Questo problema rimane con tutti i font(compreso il font di default usando use_xft no), e permane usando override_ut8_locale.
Tutti i file sono in utf-8 con newline in stile unix.
Da terminale conky non da alcun tipo di messaggio d'errore.
Ho provato a cercare su google, ho trovato 2-3 post in dei forum riguardo a questo problema, ma in un caso non è stato risolto, negli altri casi era un problema di encoding nei file(io ho già provato ad usare newline in stile windows e mac ma o non cambia niente oppure al posto di 1 quadratino ne mette 2).
Dove "amarok_infos" è questo script:
Spoiler
Mostra
Codice: Seleziona tutto
#!/usr/bin/env python
import sys
import argparse
import subprocess
try:
from cStringIO import StringIO
except ImportError:
from StringIO import StringIO
TEMPLATE_CURRENT_PIECE = '''\
${{alignc}}${{font Ubuntu:size=10:style=bold Titling}}{title}${{font}}
${{alignc}}{artist}'''
parser = argparse.ArgumentParser()
parser.add_argument('action', help='The action to be executed.',
choices=('song', 'playlist',
'collection', 'stats'))
TEMPLATE_TRACKLIST_LINE = '''\
${{alignc}}{title}
${{alignc}}{artist}'''
PLAYER = 'Player'
TRACKLIST = 'TrackList'
GET_METADATA = 'GetMetadata'
GET_LENGTH = 'GetLength'
GET_CURRENT_TRACK = 'GetCurrentTrack'
DEFAULT_RETURN_VALUES = {
GET_METADATA: '',
GET_LENGTH: 0,
GET_CURRENT_TRACK: ''
}
def main(argv=None):
if argv is None:
argv = sys.argv[1:]
options = parser.parse_args(argv)
ACTION_DICT[options.action]()
def _parse_song_infos(s):
'''Parses the song information'''
return dict(line.rstrip().split(':', 1) for line in s.split('\n')
if line.count(':') > 0)
def run_qdbus(obj, meth, args=(), url='org.kde.amarok'):
'''Return the result of running qdbus to call meth.'''
args = ' '.join(str(arg) for arg in args)
try:
# Using PIPE for stderr is discouraged, but I don't want
# to show output from stderr, and this seems the only way.
res = subprocess.check_output('qdbus {url} /{obj} {meth} {args}'
.format(**locals()).split(),
stderr=subprocess.PIPE)
except subprocess.CalledProcessError:
res = DEFAULT_RETURN_VALUES.get(meth)
return res
def song():
output = run_qdbus(PLAYER, GET_METADATA)
if not output:
print('${alignc}No song being played.')
return
infos = _parse_song_infos(output)
info_names = ('title', 'artist')
print(TEMPLATE_CURRENT_PIECE.format(**dict((name, infos[name])
for name in info_names)))
def playlist():
length = int(run_qdbus(TRACKLIST, GET_LENGTH))
if length < 1:
print('${alignc}No playlist avaiable.')
return
cur_song_num = int(run_qdbus(TRACKLIST, GET_CURRENT_TRACK))
song_infos = [_parse_song_infos(
run_qdbus(TRACKLIST, GET_METADATA, (i,)))
for i in range(min(5, length))]
info_names = ('title', 'artist')
print('%d/%d\n' % (cur_song_num+1, length))
for song in song_infos:
print(TEMPLATE_TRACKLIST_LINE.format(title=song['title'],
artist=song['artist']))
def collection():
print('Currently no information avaiable.')
def stats():
print('Currently no statistics avaiable.')
ACTION_DICT = {
'song': song,
'playlist': playlist,
'collection': collection,
'stats': stats,
}
if __name__ == '__main__':
main()Tra parentesi gli altri 2 conky che utilizzo non mostrano questo rettangolino.
EDIT2:
Ho appurato che è l'alignc a essere trasformato nel rettangolino. Effettivamente la seconda linea non è centrata.
Qualcuno riesce a capire perchè fa questa cosa? Togliendo l'alignc il rettangolino non si vede ma la linea non è centrata.
Credo che potrei risolvere settando il testo centrato di default, ma non mi pare esista tale opzione...
EDIT3:
Aggiungere uno spazio bianco prima dell'alignc ha risolto tutto
