Mercurial > audlegacy
annotate contrib/g15_audacious.py @ 4765:b58b2617fe13
build fix
author | Yoshiki Yazawa <yaz@honeyplnaet.jp> |
---|---|
date | Sun, 10 Aug 2008 12:19:28 +0900 |
parents | 7a4fcf84a34f |
children |
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. |
3255
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
3212
diff
changeset
|
13 - Wipe and redraw the entire screen at songchange. I'm not sure why yet, but some songs can cause mess-ups. |
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
|
14 - 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
|
15 |
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 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
|
17 - 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
|
18 - 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
|
19 - 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
|
20 - 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
|
21 - 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
|
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 |
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 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
|
25 |
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 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
|
27 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
|
28 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
|
29 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
|
30 "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
|
31 "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
|
32 "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
|
33 "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
|
34 "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
|
35 "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
|
36 "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
|
37 |
3255
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
3212
diff
changeset
|
38 # 3x5 "Characters" (Icon glyphs sized to match the Small font) |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
3212
diff
changeset
|
39 CHAR_S_NOTE = "011010010110110" |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
3212
diff
changeset
|
40 CHAR_S_HALFTONE = "101010101010101" |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
3212
diff
changeset
|
41 CHAR_S_CROSS = "000010111010000" |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
3212
diff
changeset
|
42 |
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
|
43 # 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
|
44 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
|
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 |
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 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
|
48 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
|
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 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
|
51 |
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 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
|
53 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
|
54 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
|
55 |
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 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
|
57 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
|
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 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
|
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
|
61 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
|
62 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
|
63 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
|
64 |
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 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
|
66 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
|
67 |
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 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
|
69 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
|
70 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
|
71 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
|
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 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
|
74 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
|
75 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
|
76 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
|
77 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
|
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 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
|
80 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
|
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 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
|
83 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
|
84 |
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 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
|
86 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
|
87 |
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 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
|
89 |
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 # 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
|
91 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
|
92 |
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 # 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
|
94 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
|
95 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
|
96 |
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 # 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
|
98 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
|
99 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
|
100 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
|
101 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
|
102 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
|
103 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
|
104 |
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 # 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
|
106 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
|
107 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
|
108 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
|
109 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
|
110 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
|
111 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
|
112 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
|
113 |
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 # 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
|
115 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
|
116 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
|
117 |
3255
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
3212
diff
changeset
|
118 # Uncomment to place a note in the gap where the scroller wraps around |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
3212
diff
changeset
|
119 #notePos = (len(titleString) - scrollPivot - 1) * 4 |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
3212
diff
changeset
|
120 #if len(titleString) > 40 and notePos <= 156: |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
3212
diff
changeset
|
121 # msg_handle.write('PO %d 9 3 5 "%s"\n' % (notePos, CHAR_S_NOTE)) |
3c3a3f3c2269
- Added my "Locate and Play" script to contrib.
"Stephan Sokolow <http://www.ssokolow.com/ContactMe>"
parents:
3212
diff
changeset
|
122 |
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
|
123 # 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
|
124 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
|
125 |
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 # 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
|
127 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
|
128 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
|
129 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
|
130 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
|
131 |
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
|
132 # 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
|
133 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
|
134 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
|
135 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
|
136 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
|
137 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
|
138 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
|
139 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
|
140 msg_handle.close() |