annotate contrib/g15_audacious.py @ 3226:db3983f423f3 trunk

show fileinfopopup only when mouse is over playlistwin_list
author Tomasz Mon <desowin@gmail.com>
date Thu, 02 Aug 2007 17:42:38 +0200
parents 59b84ca1b09c
children 3c3a3f3c2269
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3212
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
1 #!/usr/bin/env python
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
2 """g15_audacious.py
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
3 By: Stephan Sokolow (deitarion/SSokolow)
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
4
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
5 Audacious Media Player Monitor applet for the Logitech G15 Gaming Keyboard's LCD (via g15composer)
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
6
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
7 Requires Audacious 1.4 or newer. (Uses the D-Bus API)
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
8
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
9 TODO:
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
10 - Every second update should skip the D-Bus calls. They are the biggest CPU drain.
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
11 (I also only use a half-second update interval for the scroller. Feel free to
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
12 turn it off and use a 1-second interval.
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
13 - Clean up this quick hack of a script.
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
14
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
15 Notes for people hacking this script:
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
16 - The LCD is 160px wide and 43px tall
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
17 - The Large (2 or L) font is 7 pixels tall.
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
18 - The Medium (1 or M) font is 6 pixels tall.
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
19 - The Small (0 or S) font is 5 pixels tall.
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
20 - When using the small font, the screen is 40 characters wide.
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
21 """
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
22
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
23 control_pipe = "/var/run/g15composer"
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
24
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
25 ICON_DIMS = (7,7)
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
26 ICN_STOP = "1" * ICON_DIMS[0] * ICON_DIMS[1]
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
27 ICN_PAUSE = "0110110" * ICON_DIMS[1]
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
28 ICN_PLAY = (
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
29 "0100000" +
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
30 "0110000" +
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
31 "0111000" +
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
32 "0111100" +
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
33 "0111000" +
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
34 "0110000" +
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
35 "0100000" )
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
36
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
37 # I prefer no icon when it's playing, so overwrite the play icon with a blank.
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
38 ICN_PLAY = '0' * ICON_DIMS[0] * ICON_DIMS[1]
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
39
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
40
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
41 import os, sys, time
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
42 from dbus import Bus, DBusException
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
43
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
44 message_pipe = os.path.join(os.environ["HOME"], ".g15_audacious_pipe")
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
45
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
46 def get_aud():
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
47 try: return session_bus.get_object('org.atheme.audacious', '/org/atheme/audacious')
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
48 except DBusException: return None
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
49
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
50 def draw_state(icon):
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
51 msg_handle.write('PO 0 0 %d %d "%s"\n' % (ICON_DIMS[0], ICON_DIMS[1], icon))
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
52
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
53 session_bus = Bus(Bus.TYPE_SESSION)
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
54
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
55 if not os.path.exists(control_pipe) and not (os.path.isfile(control_pipe) and os.path.isdir(control_pipe)):
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
56 print "ERROR: Not a g15composer control pipe: %s" % control_pipe
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
57 sys.exit(1)
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
58
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
59 if os.path.exists(message_pipe) and not (os.path.isfile(control_pipe) and os.path.isdir(control_pipe)):
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
60 os.remove(message_pipe)
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
61
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
62 try:
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
63 file(control_pipe, 'w').write('SN "%s"\n' % message_pipe)
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
64 time.sleep(0.5)
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
65 msg_handle = file(message_pipe,'w')
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
66
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
67 oldTitleString = ''
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
68 while True:
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
69 aud = get_aud()
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
70 if aud:
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
71 pos = aud.Position()
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
72
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
73 lengthSecs = aud.SongLength(pos)
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
74 length = (lengthSecs > 0) and ("%d:%02d" % (lengthSecs / 60, lengthSecs % 60)) or "stream"
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
75
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
76 songTitle = aud.SongTitle(pos).encode("latin1", "replace")
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
77 titleString = "%d. %s" % (pos, songTitle)
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
78
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
79 playSecs = aud.Time() / 1000
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
80 played = "%d:%02d" % (playSecs / 60, playSecs % 60)
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
81
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
82 volume = aud.Volume()
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
83
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
84 # Cache changes until I'm done making them
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
85 msg_handle.write('MC 1\n')
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
86
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
87 # Set up the static elements
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
88 msg_handle.write('TO 0 0 2 1 "Now Playing"\n')
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
89 msg_handle.write('TO 0 26 0 0 "Volume:"\n')
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
90
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
91 # State Indicator
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
92 if aud.Paused():
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
93 draw_state(ICN_PAUSE)
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
94 elif aud.Playing():
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
95 draw_state(ICN_PLAY)
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
96 else:
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
97 draw_state(ICN_STOP)
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
98
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
99 # Scroll the title string
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
100 if len(titleString) > 40 and oldTitleString == titleString:
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
101 tsTemp = titleString + ' '
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
102 titleString = tsTemp[scrollPivot:] + tsTemp[:scrollPivot]
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
103 scrollPivot = (scrollPivot < len(tsTemp)) and (scrollPivot + 1) or 0
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
104 else:
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
105 scrollPivot = 0
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
106 oldTitleString = titleString
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
107
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
108 # Title
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
109 msg_handle.write('PB 0 9 160 14 0 1 1\n') # Wipe away any remnants of the old title that wouldn't be overwritten.
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
110 msg_handle.write('TO 0 9 0 0 "%s"\n' % titleString)
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
111
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
112 # Volume bar
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
113 msg_handle.write('DB 29 28 159 29 1 %d 100 1\n' % ((volume[0] + volume[1])/2))
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
114
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
115 # Progress Bar
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
116 msg_handle.write('DB 0 33 159 41 1 %d %d 1\n' % (playSecs, lengthSecs)) # Progress Bar
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
117 msg_handle.write('MX 1\n')
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
118 msg_handle.write('TO 0 34 2 1 "Position: %s/%s"\n' % (played, length)) # Progress Text
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
119 msg_handle.write('MX 0\n')
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
120
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
121 # Push changes to the display and sleep for a second.
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
122 msg_handle.write('MC 0\n')
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
123 msg_handle.flush()
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
124 time.sleep(0.5)
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
125 else:
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
126 msg_handle.write('PC 0\nTL "D-Bus Exception:" "Can\'t find Audacious"\n"')
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
127 finally:
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
128 msg_handle.write("SC\n")
59b84ca1b09c Added my g15composer-based Python script for displaying Now Playing info on the LCD of the Logitech G15 Gaming Keyboard.
ssokolow@localhost.localdomain
parents:
diff changeset
129 msg_handle.close()