Dynamic icons for volume control
(Sorry for any mistake - I'm a complete launchpad-no0b! Just mailed with Pavel, one of the developers of volume-control, and he told me to use launchpad for my matter.)
I needed a more accurate display of the actual volume level. So I modified the existing applet to deal with SVG including placeholders with expressions to be replaced by a calculated value. Placeholders might look like this:
<rect
height=
... />
...or something like this:
<rect
style=
Placeholders are not limited to one per SVG, you can have some to rotate, some to resize (and so on) in one file.
An extra icon has to be created to display muted status.
Pavel wanted to look at diff, so here comes the output:
--- usr/lib/
+++ home/markus/
@@ -31,6 +31,9 @@
# Listing theme directories and showing icons
import os
+# Search and replace on SVG
+import re, math
+
# Drawing the GUI
import gtk
@@ -73,8 +76,8 @@
try:
except:
- self.theme = "Tango"
- self.awn.
+ self.theme = "oRainge"
+ self.awn.
# Backend
@@ -88,24 +91,33 @@
themepath = os.path.
return self.awn.
- "audio-
+ "audio-volume.svg" % name))
def setIcon(self):
+ regex = re.compile(
volume = self.backend.
- if volume == self.__lastVolume :
- return
-
- for i in [100, 93, 86, 79, 71, 64, 57, 50, 43, 36, 29, 21, 14, 7]:
- if volume >= i:
- icon = str(i)
- break
-
themepath = os.path.
- self.awn.
- "audio-
-
+
+ #Main changes for dynamic display
+ if volume > 0:
+ infile = open(os.
+ icon = infile.read()
+ infile.close()
+ replace = regex.search(icon)
+ while replace != None:
+ value = 0.0
+ exec(replace.
+ icon = regex.sub("%f" % value, icon, count=1)
+ replace = regex.search(icon)
+ iconfile = open(os.
+ iconfile.
+ iconfile.close()
+ self.awn.
+ else:
+ self.awn.
+
def wheel(self, widget=None, event=None):
I made some themes for this one too. This version of volume-control is published on my blog, you can get the tarball including those themes here: http://
The shipped ones are a demonstration of different changes, values and if-statements. Images are all drawn by myself so there can't be any copyright related problems in the future with those icons. If you like 'em - use 'em :)
(my fav is the marshall button [goes to 11!] that rips off on mute...)
Blueprint information
- Status:
- Complete
- Approver:
- None
- Priority:
- Not
- Drafter:
- None
- Direction:
- Needs approval
- Assignee:
- None
- Definition:
- Obsolete
- Series goal:
- None
- Implementation:
- Unknown
- Milestone target:
- None
- Started by
- Completed by
- onox
Related branches
Related bugs
Sprints
Whiteboard
Rejected. Pasted diff based on old applet and makes the applet more complex.