View Full Version : Making a VolumeControl widget
DeathCarrot
July 18th, 2007, 10:54 PM
VolumeControl is a screenlet for controlling audio volume.
Newest version:
-- 0.1.7 --
http://users.ecs.soton.ac.uk/jsk105/VolumeControl-0.1.7.tar.gz
Changelog: Complete redesign of how commands are handled internally
Preferences simplified (now all you need to do is select a control from a combo box)
Added a step option to specify how quickly the volume goes up with the mousewheel
Added the ability to launch a mixer from the context menu
Took out the theme.conf files for the time being
-- 0.1.6 --
http://users.ecs.soton.ac.uk/jsk105/VolumeControl-0.1.6.png
http://users.ecs.soton.ac.uk/jsk105/VolumeControl-0.1.6.tar.gz
Changelog Got rid of the previous theme (I kind of used an Xfce icon in that one)
Added 3 new themes which are all my own
Changed the way coordinates are handled
Themes now use config files to specify where the bar is
Issues Theme config not loaded properly when changing themes
In the screengrab you can see the issue, the bar's mask isn't over the bar.
-- 0.1.5 --
http://users.ecs.soton.ac.uk/jsk105/VolumeControl-0.1.5.png
http://users.ecs.soton.ac.uk/jsk105/VolumeControl-0.1.5.tar.gz
Changelog: Added ability to click on the bar to set the volume
Changed the bar .svg to clash less with the colour scheme
Ensured screenlets-0.0.8 compatibility
Comment and indentation overhaul
-- original message --
I'm currently making my first widget - a simple volume controller you interact with using the mouse wheel.
http://users.ecs.soton.ac.uk/jsk105/VolumeControl.png
download: http://ecs.soton.ac.uk/~jsk105/VolumeControl.tar.gz
The functionality is there, it's currently a bit hacky - you need to specify your own commands for changing the volumes, but that will probably be sorted in time.
Any comments or suggestions?
edit: [snip]
-nevermind, problem was fixed by restarting the daemon-
edit: added 0.1.5 on 19/07/07 (http://forum.compiz.org/viewtopic.php?t=1518#10021)
edit: added 0.1.6 on 20/07/07 (http://forum.compiz.org/viewtopic.php?t=1518#10074)
edit: added 0.1.7 on 21/07/07 (http://forum.compiz.org/viewtopic.php?t=1518#10095)
RYX
July 19th, 2007, 01:40 AM
Hi DeathCarrot!
Really nice work. Keep it up!
If you want to make your screenlet compatible with version 0.0.8, you should replace the last few lines with this:if __name__ == "__main__":
# create new session
import screenlets.session
screenlets.session.create_session(VolumeControlScr eenlet)
:)
DeathCarrot
July 19th, 2007, 07:20 AM
Thanks! :D Will make the changes once I get back home (at work now).
TODO: Add checks to make sure cmdValue actually returns a number
.. or think of a more versatile way of getting the volume data
Clicking the left mouse button over the bar should set the volume
Add a menu item to open a mixer app
Move size/offset information into theme-specific config files
Make some more themesAnything else a volume controller might include?
DeathCarrot
July 19th, 2007, 04:35 PM
Some updates:
http://users.ecs.soton.ac.uk/jsk105/VolumeControl-0.1.5.png
http://users.ecs.soton.ac.uk/jsk105/VolumeControl-0.1.5.tar.gz
Added ability to click on the bar to set the volume
Changed the bar .svg to clash less with the colour scheme
Ensured screenlets-0.0.8 compatibility
Comment and indentation overhaul
RYX
July 20th, 2007, 04:41 PM
I really like it :) ... But there is one small thing: if I click into the middle of the bar the music is already VERY loud. I don't want to imagine what happens if I accidentally hit the top position :D ... either my ears or my speakers explode (and my speakers are quite big). It must be at least 5 times louder than the maximum value I can set using any other volume-control ... Can you add some check or limitation for that?
(Not that I dislike loud music, but it really may kill someone's speakers or headphones or even ears :D ...)
btw: Thanks for pointing me at the scroll-event - I desperately tried to catch button4/5 events ... (should go into core as well) :)
:)
DeathCarrot
July 20th, 2007, 09:15 PM
Could you post the results of 'amixer scontents', the I guess the limits may be different for different cards.
Also, do I have to anything special to load override variables through config files? I have a theme.conf in each of my theme directories and they basically contain:
# Configuration file for theme 'cone'
# VolumeControlScreenlet (c) 2007 DeathCarrot <jsk105@ecs.soton.ac.uk>
bar_x = 59
bar_y = 7
bar_width = 12
bar_height = 75
I have the 4 variables defined in the script.
When I run it, I get this output:
[~/.screenlets/VolumeControl] ./VolumeControlScreenlet.py
CachingBackend: Loading instances from cache
CachingBackend: Loading <VolumeControl1>
Loading instances in: /home/deathcarrot/.config/Screenlets/VolumeControl/default/
File: VolumeControl1.ini
Creating new instance:
theme.conf found! Loading option-overrides.
bar_x = 59
bar_y = 7
bar_width = 12
bar_height = 75
CachingBackend.save_option: x=10
CachingBackend.save_option: y=8
Override: bar_width
Override: bar_y
Override: bar_x
Override: bar_height
Set options in VolumeControlScreenlet
Restored instances from session 'default' ...
CachingBackend: Saving <#VolumeControl1> :) ...
OK
But the values don't change, they remain whatever I defined them as.
Here's version 0.1.6:
http://users.ecs.soton.ac.uk/jsk105/VolumeControl-0.1.6.png
http://users.ecs.soton.ac.uk/jsk105/VolumeControl-0.1.6.tar.gz
Changelog Got rid of the previous theme (I kind of used an Xfce icon in that one)
Added 3 new themes which are all my own
Changed the way coordinates are handled
Themes now use config files to specify where the bar is
Issues Theme config not loaded properly when changing themes
In the screengrab you can see the issue, the bar's mask isn't over the bar.
RYX
July 20th, 2007, 11:52 PM
Looks all very cool :D ... really nice graphics, cool style ...
The problem with overriding options through the theme is related to a problem in the load_conf-function in the ScreenletTheme-class. I think if you set the values without spaces between varname/value/"=" it should work. I have just corrected that and made it a bit more like common ini-files (will be fixed in the next version). The annoying confirmation-dialog when applying a theme containing overrides will become optional, too :)
And here is the (quite huge) output of "amixer scontents":Simple mixer control 'Master',0
Capabilities: pvolume pswitch pswitch-joined
Playback channels: Front Left - Front Right
Limits: Playback 0 - 31
Mono:
Front Left: Playback 18 [58%] [-19.50dB] [on]
Front Right: Playback 18 [58%] [-19.50dB] [on]
Simple mixer control 'Headphone LFE',1
Capabilities: pswitch pswitch-joined
Playback channels: Mono
Mono: Playback [off]
Simple mixer control 'Headphone',1
Capabilities: pvolume
Playback channels: Front Left - Front Right
Limits: Playback 0 - 100
Mono:
Front Left: Playback 0 [0%] [-99999.99dB]
Front Right: Playback 0 [0%] [-99999.99dB]
Simple mixer control 'Headphone Center',1
Capabilities: pswitch pswitch-joined
Playback channels: Mono
Mono: Playback [off]
Simple mixer control 'Tone',0
Capabilities: pswitch
Playback channels: Front Left - Front Right
Mono:
Front Left: Playback [off]
Front Right: Playback [off]
Simple mixer control 'Bass',0
Capabilities: volume
Playback channels: Front Left - Front Right
Capture channels: Front Left - Front Right
Limits: 0 - 40
Front Left: 20 [50%]
Front Right: 20 [50%]
Simple mixer control 'Treble',0
Capabilities: volume
Playback channels: Front Left - Front Right
Capture channels: Front Left - Front Right
Limits: 0 - 40
Front Left: 20 [50%]
Front Right: 20 [50%]
Simple mixer control '3D Control - Switch',0
Capabilities: pswitch pswitch-joined
Playback channels: Mono
Mono: Playback [off]
Simple mixer control '3D Control Sigmatel - Depth',0
Capabilities: volume volume-joined
Playback channels: Mono
Capture channels: Mono
Limits: 0 - 3
Mono: 0 [0%]
Simple mixer control 'PCM',0
Capabilities: pvolume pswitch pswitch-joined
Playback channels: Front Left - Front Right
Limits: Playback 0 - 31
Mono:
Front Left: Playback 25 [81%] [3.00dB] [on]
Front Right: Playback 25 [81%] [3.00dB] [on]
Simple mixer control 'Front',0
Capabilities: cvolume cswitch cswitch-joined
Capture channels: Front Left - Front Right
Limits: Capture 0 - 100
Front Left: Capture 80 [80%] [-8.00dB] [off]
Front Right: Capture 80 [80%] [-8.00dB] [off]
Simple mixer control 'Surround',0
Capabilities: pvolume cvolume cswitch
Playback channels: Front Left - Front Right
Capture channels: Front Left - Front Right
Limits: Playback 0 - 100 Capture 0 - 100
Front Left: Playback 100 [100%] [0.00dB] Capture 0 [0%] [-99999.99dB] [off]
Front Right: Playback 100 [100%] [0.00dB] Capture 0 [0%] [-99999.99dB] [off]
Simple mixer control 'Center',0
Capabilities: pvolume pvolume-joined
Playback channels: Mono
Limits: Playback 0 - 100
Mono: Playback 100 [100%] [0.00dB]
Simple mixer control 'LFE',0
Capabilities: pvolume pvolume-joined
Playback channels: Mono
Limits: Playback 0 - 100
Mono: Playback 100 [100%] [0.00dB]
Simple mixer control 'Synth',0
Capabilities: pvolume cvolume cswitch
Playback channels: Front Left - Front Right
Capture channels: Front Left - Front Right
Limits: Playback 0 - 100 Capture 0 - 100
Front Left: Playback 80 [80%] [-8.00dB] Capture 80 [80%] [-8.00dB] [off]
Front Right: Playback 80 [80%] [-8.00dB] Capture 80 [80%] [-8.00dB] [off]
Simple mixer control 'Wave',0
Capabilities: pvolume cvolume cswitch
Playback channels: Front Left - Front Right
Capture channels: Front Left - Front Right
Limits: Playback 0 - 100 Capture 0 - 100
Front Left: Playback 80 [80%] [-8.00dB] Capture 80 [80%] [-8.00dB] [off]
Front Right: Playback 80 [80%] [-8.00dB] Capture 80 [80%] [-8.00dB] [off]
Simple mixer control 'Wave Center',0
Capabilities: pvolume pvolume-joined
Playback channels: Mono
Limits: Playback 0 - 100
Mono: Playback 0 [0%] [-99999.99dB]
Simple mixer control 'Wave LFE',0
Capabilities: pvolume pvolume-joined
Playback channels: Mono
Limits: Playback 0 - 100
Mono: Playback 0 [0%] [-99999.99dB]
Simple mixer control 'Wave Surround',0
Capabilities: pvolume
Playback channels: Front Left - Front Right
Limits: Playback 0 - 100
Mono:
Front Left: Playback 0 [0%] [-99999.99dB]
Front Right: Playback 0 [0%] [-99999.99dB]
Simple mixer control 'Line',0
Capabilities: pvolume pswitch pswitch-joined cswitch cswitch-exclusive
Capture exclusive group: 0
Playback channels: Front Left - Front Right
Capture channels: Front Left - Front Right
Limits: Playback 0 - 31
Front Left: Playback 0 [0%] [-34.50dB] [off] Capture [off]
Front Right: Playback 0 [0%] [-34.50dB] [off] Capture [off]
Simple mixer control 'Line LiveDrive',0
Capabilities: pvolume cvolume cswitch
Playback channels: Front Left - Front Right
Capture channels: Front Left - Front Right
Limits: Playback 0 - 100 Capture 0 - 100
Front Left: Playback 0 [0%] [-99999.99dB] Capture 0 [0%] [-99999.99dB] [off]
Front Right: Playback 0 [0%] [-99999.99dB] Capture 0 [0%] [-99999.99dB] [off]
Simple mixer control 'Line2 LiveDrive',1
Capabilities: pvolume cvolume cswitch
Playback channels: Front Left - Front Right
Capture channels: Front Left - Front Right
Limits: Playback 0 - 100 Capture 0 - 100
Front Left: Playback 0 [0%] [-99999.99dB] Capture 0 [0%] [-99999.99dB] [off]
Front Right: Playback 0 [0%] [-99999.99dB] Capture 0 [0%] [-99999.99dB] [off]
Simple mixer control 'CD',0
Capabilities: pvolume pswitch pswitch-joined cswitch cswitch-exclusive
Capture exclusive group: 0
Playback channels: Front Left - Front Right
Capture channels: Front Left - Front Right
Limits: Playback 0 - 31
Front Left: Playback 25 [81%] [3.00dB] [on] Capture [off]
Front Right: Playback 25 [81%] [3.00dB] [on] Capture [off]
Simple mixer control 'Mic',0
Capabilities: pvolume pvolume-joined pswitch pswitch-joined cswitch cswitch-exclusive
Capture exclusive group: 0
Playback channels: Mono
Capture channels: Front Left - Front Right
Limits: Playback 0 - 31
Mono: Playback 0 [0%] [-34.50dB] [off]
Front Left: Capture [on]
Front Right: Capture [on]
Simple mixer control 'Mic Boost (+20dB)',0
Capabilities: pswitch pswitch-joined
Playback channels: Mono
Mono: Playback [off]
Simple mixer control 'Mic Select',0
Capabilities: enum
Items: 'Mic1' 'Mic2'
Item0: 'Mic1'
Simple mixer control 'Video',0
Capabilities: pvolume pswitch pswitch-joined cswitch cswitch-exclusive
Capture exclusive group: 0
Playback channels: Front Left - Front Right
Capture channels: Front Left - Front Right
Limits: Playback 0 - 31
Front Left: Playback 0 [0%] [-34.50dB] [off] Capture [off]
Front Right: Playback 0 [0%] [-34.50dB] [off] Capture [off]
Simple mixer control 'Phone',0
Capabilities: pvolume pvolume-joined pswitch pswitch-joined cswitch cswitch-exclusive
Capture exclusive group: 0
Playback channels: Mono
Capture channels: Front Left - Front Right
Limits: Playback 0 - 31
Mono: Playback 0 [0%] [-34.50dB] [off]
Front Left: Capture [off]
Front Right: Capture [off]
Simple mixer control 'IEC958 Coaxial',0
Capabilities: pvolume cvolume cswitch
Playback channels: Front Left - Front Right
Capture channels: Front Left - Front Right
Limits: Playback 0 - 100 Capture 0 - 100
Front Left: Playback 0 [0%] [-99999.99dB] Capture 0 [0%] [-99999.99dB] [off]
Front Right: Playback 0 [0%] [-99999.99dB] Capture 0 [0%] [-99999.99dB] [off]
Simple mixer control 'IEC958 LiveDrive',0
Capabilities: pvolume cvolume cswitch
Playback channels: Front Left - Front Right
Capture channels: Front Left - Front Right
Limits: Playback 0 - 100 Capture 0 - 100
Front Left: Playback 0 [0%] [-99999.99dB] Capture 0 [0%] [-99999.99dB] [off]
Front Right: Playback 0 [0%] [-99999.99dB] Capture 0 [0%] [-99999.99dB] [off]
Simple mixer control 'IEC958 Optical Raw',0
Capabilities: pswitch
Playback channels: Front Left - Front Right
Mono:
Front Left: Playback [off]
Front Right: Playback [off]
Simple mixer control 'IEC958 TTL',0
Capabilities: pvolume cvolume cswitch
Playback channels: Front Left - Front Right
Capture channels: Front Left - Front Right
Limits: Playback 0 - 100 Capture 0 - 100
Front Left: Playback 0 [0%] [-99999.99dB] Capture 0 [0%] [-99999.99dB] [off]
Front Right: Playback 0 [0%] [-99999.99dB] Capture 0 [0%] [-99999.99dB] [off]
Simple mixer control 'PC Speaker',0
Capabilities: pvolume pvolume-joined pswitch pswitch-joined
Playback channels: Mono
Limits: Playback 0 - 15
Mono: Playback 0 [0%] [-45.00dB] [off]
Simple mixer control 'Aux',0
Capabilities: pvolume pswitch pswitch-joined cswitch cswitch-exclusive
Capture exclusive group: 0
Playback channels: Front Left - Front Right
Capture channels: Front Left - Front Right
Limits: Playback 0 - 31
Front Left: Playback 0 [0%] [-34.50dB] [off] Capture [off]
Front Right: Playback 0 [0%] [-34.50dB] [off] Capture [off]
Simple mixer control 'Capture',0
Capabilities: cvolume cswitch cswitch-joined
Capture channels: Front Left - Front Right
Limits: Capture 0 - 15
Front Left: Capture 0 [0%] [0.00dB] [on]
Front Right: Capture 0 [0%] [0.00dB] [on]
Simple mixer control 'Mix',0
Capabilities: cswitch cswitch-exclusive
Capture exclusive group: 0
Capture channels: Front Left - Front Right
Front Left: Capture [off]
Front Right: Capture [off]
Simple mixer control 'Mix Mono',0
Capabilities: cswitch cswitch-exclusive
Capture exclusive group: 0
Capture channels: Front Left - Front Right
Front Left: Capture [off]
Front Right: Capture [off]
Simple mixer control 'AC97',0
Capabilities: pvolume cvolume
Playback channels: Front Left - Front Right
Capture channels: Front Left - Front Right
Limits: Playback 0 - 100 Capture 0 - 100
Front Left: Playback 80 [80%] [-8.00dB] Capture 80 [80%] [-8.00dB]
Front Right: Playback 80 [80%] [-8.00dB] Capture 80 [80%] [-8.00dB]
Simple mixer control 'External Amplifier',0
Capabilities: pswitch pswitch-joined
Playback channels: Mono
Mono: Playback [on]
Simple mixer control 'SB Live Analog/Digital Output Jack',0
Capabilities: pswitch pswitch-joined
Playback channels: Mono
Mono: Playback [on]
Simple mixer control 'Sigmatel 4-Speaker Stereo',0
Capabilities: pswitch pswitch-joined
Playback channels: Mono
Mono: Playback [off]
Simple mixer control 'Sigmatel Surround Phase Inversion Playback ',0
Capabilities: pswitch pswitch-joined
Playback channels: Mono
Mono: Playback [off]
:)
DeathCarrot
July 21st, 2007, 10:38 AM
Thanks :)
I originally wrote the theme.conf files without spaces, but that didn't work either (in the 0.1.6 tarball the config file for the speaker theme doesn't have any spaces in, but still doesn't load the data). Making the dialogue optional is definitely a plus :)
Thanks for the output, it confirms what I thought the problem was was, yours says:
Limits: Playback 0 - 31
whereas mine says:
Limits: Playback 0 - 64
DeathCarrot
July 21st, 2007, 12:20 PM
Version 0.1.7
http://users.ecs.soton.ac.uk/jsk105/VolumeControl-0.1.7.tar.gz
Changelog: Complete redesign of how commands are handled internally
Preferences simplified (now all you need to do is select a control from a combo box)
Added a step option to specify how quickly the volume goes up with the mousewheel
Added the ability to launch a mixer from the context menu
Took out the theme.conf files for the time being
adimac
April 9th, 2008, 01:35 AM
I have a problem, I tried this screenlet only for a moment in my ubuntu and switched it off, but now when I move my mouse wheel it controls the volume instead of scrolling the documents. what must I do to restore the original configuration for the mouse wheel?
vBulletin® v3.7.1, Copyright ©2000-2008, Jelsoft Enterprises Ltd.