momonster.de

spiele, web develop, linux, news …

Conky Systemmonitor

2. April 2008 – 10:04

Conky ist ein Systemmonitor für Linux, wer torsmo kennt wird sich sofort heimisch fühlen. Sogar die Konfigurationsdateien von torsmo funktionieren. Ich habe mir ein kleines Python-Script gebastelt um mir den aktuell von Juk gespielten Titel anzeigen zu lassen.

Installation

wget http://www.momonster.de/linux/juk.py -O ~/bin/juk.py
chmod +x ~/bin/juk.py

Quellcode

#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
#	2005.09.12.01
#		erste Version
#	2005.09.13.01
#		Sekunden werden jetzt zweistellig ausgegeben
#		Länge der Titelanzeige auf 40 Zeichen begrenzt
#	2005.09.13.02
#		kosmetische Änderung (Zeitanzeige)
#		Länge der Titelanzeige muß als Argument übergeben werden (z.B. juk4.py titel 40)
 
import pydcop
import sys
import string
 
input = sys.argv[1]
app = pydcop.anyAppCalled("juk")
 
def titel():
	if app == None:
		print "Player nicht gestartet..."
	else:
		if app.Player.playing() == 1:
			if app.Player.paused() == 1:
				print "Player pausiert..."
			else:
				if not sys.argv[2:]:
					userlen = 80
				else:
					userlen = int(sys.argv[2])
				if len(app.Player.playingString()) >= userlen:
					print app.Player.playingString()[0:userlen - 3] + "..."
				else:
					print app.Player.playingString()
		else:
			print "Player gestoppt..."
 
def bar():
	if app == None:
		bs = 0
	else:
		if app.Player.playing() == 1:
			bs = 100 * app.Player.currentTime() / app.Player.totalTime()
			print bs
 
def zeit():
	if app == None:
		print "0:00"
	else:
		if app.Player.playing() == 1:
			ma,sa = divmod(app.Player.currentTime(),60)
			current = str(ma) + ":" + string.zfill(str(sa),2)
			m,s = divmod(app.Player.totalTime(),60)
			total = str(m) + ":" + string.zfill(str(s),2)
			print current + " / " + total
		else:
			print "0:00"
 
if input == "titel":
	titel()
if input == "bar":
	bar()
if input == "zeit":
	zeit()

Conky

Das Script in die .conkyrc einbauen:

${execi 9 ~/bin/juk.py titel 40}

Wenn man dann noch eine Fortschrittsanzeige für seine Titel haben möchte:

${execibar 9 ~/bin/juk.py bar}

Für eine Zeitanzeige dann noch folgendes:

${execi 9 ~/bin/juk.py zeit}

Wenn man möchte das die Anzeige nur erscheint wenn Juk auch läuft, das ganze noch in ein

{if_running juk}
$endif

packen und glücklich sein.

Das Ergebnis könnte folgendermaßen aussehen:

Conky Sytemmonitor

Conky Sytemmonitor

1 Kommentar

  1. [...] Conky Systemmonitor [...]

Kommentar schreiben

» momonster.de « spiele, web develop, linux, news …» Impressum «