[alsa-devel] The volume buttons on Lenovo Thinkpad X61S (was: Re: [Alsa-user] Console beep on Lenovo Thinkpad X61S)
Jaroslav Kysela
perex at perex.cz
Fri Mar 26 17:18:22 CET 2010
On Fri, 26 Mar 2010, Lars Bjørndal wrote:
> The volume buttons up, down and mute, doesn't work from within the
> console. How could that be fixed? Please note that I use Fedora 12,
> and I don't use X.
It's a bit different thing. The ACPI events are translated as key-press
events to the /dev/input/event* interface. So you need an application
(daemon) watching for these key-press events and modifying the volume
using the ALSA mixer interface. The GUI programs do this.
Here is a short program in python reading input events and translating
them to amixer calls:
=========== cut here ===================
#!/usr/bin/python
import struct
import os
# use 'evtest' program to determine right /dev/input device and code
acpievents = "/dev/input/event1"
fmt = 'iihhi'
fd = open(acpievents, "rb")
event = fd.read(16)
while event:
(time1, time2, type, code, value) = struct.unpack(fmt, event)
if type == 1:
if code == 115: # keypress VOLUMEUP
os.system("amixer -q -c 0 set PCM 10%+")
elif code == 114: # keypress VOLUMEDOWN
os.system("amixer -q -c 0 set PCM 10%-")
event = fd.read(16)
fd.close()
================ cut here =============
Jaroslav
-----
Jaroslav Kysela <perex at perex.cz>
Linux Kernel Sound Maintainer
ALSA Project, Red Hat, Inc.
More information about the Alsa-devel
mailing list