You are not logged in.
Pages: 1
Yes, I know about volwheel and gvolwheel.
My main reason for writing this was to allow me to control the volume using my keyboard's volume wheel without spawning a dozen new processes when I scrolled it. (Which is what happens when I bind the keys to amixer, etc.) Anyway...
Description
pyvolwheel is a python application that puts an icon in your system tray from
which you can control the volume using your mouse wheel or optional hot-keys.
It is compatible with both ALSA and OSS and supports muting for controls that
don't natively support it. pyvolwheel can also remember the volume level when
it quits and restore it the next time it starts.
Dependencies
* pygtk (>=2.16)
Optional Dependencies
* pyalsaaudio: for ALSA mixer support
* python-xlib: for global hotkey support
Offline
Hey, I tried this and I get the following error:
Traceback (most recent call last):
File "/usr/bin/pyvolwheel", line 150, in <module>
m.run()
File "/usr/bin/pyvolwheel", line 39, in run
self.reload()
File "/usr/bin/pyvolwheel", line 125, in reload
self.config.mixer.control = mixer.get_controls(driver, device)[0]
IndexError: list index out of range
I am using OSS and I installed Pyvolwheel from the AUR.
Last edited by FSX (2010-02-10 11:16:16)
Offline
For oss volume control try this:
#!/usr/bin/env python
"A simple volume control applet."
import gtk
import subprocess
__author__ = "Joakim \"JockeTF\" Soderlund"
__date__ = "2008-08-22"
__license__ = "Public domain."
# Binaries to execute.
OSSMIX = "ossmix"
OSSXMIX = "ossxmix"
# The device to control.
DEVICE = "vmix0-outvol"
# The maximum outvol volume in decibels.
MAX_DB = 25.0
# Sets an icon for different volume levels.
LEVELS = (
(22, "audio-volume-high"),
(18, "audio-volume-medium"),
(0, "audio-volume-low"),
(-1, "audio-volume-muted"),
)
class StatusIcon():
"The status icon."
def __init__(self):
self.icon = gtk.StatusIcon()
self.icon.connect("scroll-event", self.scrollEvent)
self.icon.connect("activate", self.clickEvent)
self.set_visible = self.icon.set_visible
self.update()
def scrollEvent(self, widget, event, *args):
"Changes the volume when the user scrolls on the volume applet."
if event.direction == gtk.gdk.SCROLL_UP:
subprocess.call([OSSMIX, DEVICE, "--", "+%.1f" % self.getStep()])
elif event.direction == gtk.gdk.SCROLL_DOWN:
subprocess.call([OSSMIX, DEVICE, "--", "-%.1f" % self.getStep()])
self.update()
def clickEvent(self, widget, *args):
"Starts or closes ossxmix when the volume applet is clicked."
if not hasattr(self, "ossxmix"):
self.ossxmix = subprocess.Popen([OSSXMIX, "-S"])
else:
if self.ossxmix.poll() == None:
self.ossxmix.terminate()
else:
self.ossxmix = subprocess.Popen([OSSXMIX, "-S"])
self.update()
def getVolume(self):
"Returns the current volume in decibels as a float."
process = subprocess.Popen([OSSMIX, DEVICE], stdout=subprocess.PIPE)
volume = float(process.communicate()[0].split()[-2])
process.wait()
return volume
def getStep(self):
"Returns the next volume step to make in decibels as a float."
return (MAX_DB - self.getVolume() + 1) * 0.1
def getIconName(self):
"Returns the icon name for the current volume level."
volume = self.getVolume()
for level in LEVELS:
if level[0] < volume:
return level[1]
def update(self, *args):
"Updates the volume applet's tooltip and icon."
self.icon.set_tooltip("Volume: %.1f dB" % self.getVolume())
self.icon.set_from_icon_name(self.getIconName())
if __name__ == "__main__":
icon = StatusIcon()
icon.set_visible(True)
try:
gtk.main()
except KeyboardInterrupt:
print("")
Save it as python script, volume.py or something and run it. It works excellence. It isn't mine, found it at some thread on this forum
Offline
Hey, I tried this and I get the following error:
Traceback (most recent call last): File "/usr/bin/pyvolwheel", line 150, in <module> m.run() File "/usr/bin/pyvolwheel", line 39, in run self.reload() File "/usr/bin/pyvolwheel", line 125, in reload self.config.mixer.control = mixer.get_controls(driver, device)[0] IndexError: list index out of range
I am using OSS and I installed Pyvolwheel from the AUR.
Seems that it can find any controls to use. :S
Could you try creating a file in ~/.config/ called pyvolwheel and put this in it:
[mixer]
control = Vol
driver = OSS
device = /dev/mixer
See if that at least gets it running.
Also, would you mind posting the output of ossmix?
Thanks!
Offline
This is the output when I use the config you provided:
shinju% pyvolwheel
Traceback (most recent call last):
File "/usr/bin/pyvolwheel", line 150, in <module>
m.run()
File "/usr/bin/pyvolwheel", line 39, in run
self.reload()
File "/usr/bin/pyvolwheel", line 133, in reload
self.config.mixer.control)
File "/usr/lib/python2.6/site-packages/pyvolwheel/mixer.py", line 88, in open_mixer
return OSSMixer(device, control)
File "/usr/lib/python2.6/site-packages/pyvolwheel/mixer.py", line 217, in __init__
self._control_idx = self._control_to_idx(control)
File "/usr/lib/python2.6/site-packages/pyvolwheel/mixer.py", line 231, in _control_to_idx
raise MixerError("Invalid control '{0}'".format(str(control)))
pyvolwheel.mixer.MixerError: Invalid control 'Vol'
And the output of ossmix:
jack.fp-black.mode <front|rear|center/LFE|side|pcm4|input> (currently front)
jack.fp-black [<leftvol>:<rightvol>] (currently 19.9:19.9 dB)
jack.fp-black.mute ON|OFF (currently OFF)
jack.fp-pink.mode <front|rear|center/LFE|side|pcm4|input> (currently front)
jack.fp-pink [<leftvol>:<rightvol>] (currently 19.9:19.9 dB)
jack.fp-pink.mute ON|OFF (currently OFF)
jack.fp-blue.mode <front|rear|center/LFE|side|pcm4|input> (currently front)
jack.fp-blue [<leftvol>:<rightvol>] (currently 19.9:19.9 dB)
jack.fp-blue.mute ON|OFF (currently OFF)
record.mix.mute.fp-mic1 ON|OFF (currently OFF)
record.mix.mute.fp-linein1 ON|OFF (currently OFF)
record.mix.mute.fp-headphone1 ON|OFF (currently OFF)
record.mix.mute.input-mix1 ON|OFF (currently OFF)
record.mix1 [<leftvol>:<rightvol>] (currently 37.4:37.4 dB)
record.mix.mute.fp-mic2 ON|OFF (currently OFF)
record.mix.mute.fp-linein2 ON|OFF (currently OFF)
record.mix.mute.fp-headphone2 ON|OFF (currently OFF)
record.mix.mute.input-mix2 ON|OFF (currently OFF)
record.mix2 [<leftvol>:<rightvol>] (currently 38.9:38.9 dB)
misc.fp-mic [<leftvol>:<rightvol>] (currently 38.9:38.9 dB)
misc.fp-linein [<leftvol>:<rightvol>] (currently 38.9:38.9 dB)
misc.fp-headphone [<leftvol>:<rightvol>] (currently 38.9:38.9 dB)
misc.input-mix <fp-mic|fp-linein> (currently fp-mic)
misc.front-mute ON|OFF (currently OFF)
misc.input-mix-mute1 ON|OFF (currently OFF)
misc.front1 [<leftvol>:<rightvol>] (currently 37.4:37.4 dB)
misc.front2 <front|input-mix> (currently front)
misc.rear-mute ON|OFF (currently OFF)
misc.input-mix-mute2 ON|OFF (currently OFF)
misc.rear1 [<leftvol>:<rightvol>] (currently 37.4:37.4 dB)
misc.rear2 <rear|input-mix> (currently rear)
misc.center/lfe-mute ON|OFF (currently OFF)
misc.input-mix-mute3 ON|OFF (currently OFF)
misc.center/lfe1 [<leftvol>:<rightvol>] (currently 37.4:37.4 dB)
misc.center/lfe2 <center/LFE|input-mix> (currently center/LFE)
misc.side-mute ON|OFF (currently OFF)
misc.input-mix-mute4 ON|OFF (currently OFF)
misc.side1 [<leftvol>:<rightvol>] (currently 38.9:38.9 dB)
misc.side2 <side|input-mix> (currently side)
misc.pcm4-mute ON|OFF (currently OFF)
misc.input-mix-mute5 ON|OFF (currently OFF)
misc.pcm41 [<leftvol>:<rightvol>] (currently 38.9:38.9 dB)
misc.pcm42 <pcm4|input-mix> (currently pcm4)
vmix0-enable ON|OFF (currently ON)
vmix0-rate <decimal value> (currently 48000) (Read-only)
vmix0-channels <Stereo|Multich> (currently Stereo)
vmix0-src <Fast|High|OFF> (currently Fast)
vmix0-outvol <monovol> (currently 22.1 dB)
vmix0-invol <monovol> (currently 0.0 dB)
vmix0.pcm10 [<leftvol>:<rightvol>] (currently 25.0:25.0 dB) ("mplayer")
vmix0.pcm11 [<leftvol>:<rightvol>] (currently 25.0:25.0 dB)
vmix0.pcm12 [<leftvol>:<rightvol>] (currently 25.0:25.0 dB)
vmix0.pcm13 [<leftvol>:<rightvol>] (currently 25.0:25.0 dB)
Last edited by FSX (2010-02-11 22:32:10)
Offline
Thanks for the information, FSX.
This appears to be a problem with ossaudiodev (the Python module I use for OSS support), so I may just add a mixer that uses the ossmix binary.
Thanks for testing!
Offline
This is nice, ty.
Offline
Pages: 1