Author |
Message |
alexandrion

Joined: 19 Feb 2011 Posts: 105
|
Posted: Sun 24 Apr 2011, 04:41 Post subject:
keyboard volume changer Subject description: change volume levels and display them |
|
here's a script i made to change the volume from the keyboard
it uses amixer to change the volume and yaf-splash to display the status
here's how it looks
here's the script
Code: | #! /bin/bash
if [[ $1 -eq 1 ]]
then
P=`amixer sset 'Master Front' 1+ | grep 'Front Left:' | awk '{print $5}' | sed 's/\[/Master Front: /g' | sed 's/\]//g'`
M=`amixer sset 'PCM' 2+ | grep 'Front Left:' | awk '{print $5}' | sed 's/\[/PCM: /g' | sed 's/\]//g'`
yaf-splash -text "$P $M" -timeout 1
else if [[ $1 -eq 2 ]]
then
P=`amixer sset 'Master Front' 1- | grep 'Front Left:' | awk '{print $5}' | sed 's/\[/Master Front: /g' | sed 's/\]//g'`
M=`amixer sset 'PCM' 2- | grep 'Front Left:' | awk '{print $5}' | sed 's/\[/PCM: /g' | sed 's/\]//g'`
yaf-splash -text "$P $M" -timeout 1
else if [[ $1 -eq 3 ]]
then
P=`amixer sset 'Master Front',0 toggle | grep "Front Left:" | awk '{print $7}'`
if [[ ''$P'' == '[off]' ]]
then
P="Volume is off"
else
P="Volume is on"
fi
yaf-splash -text "$P" -timeout 1
fi
fi
fi |
as you can see in my case master front and pcm control the volume so that's what i'm changing
not all cards have the same channels so you might want to check which controls change the volume by running alsamixer in a terminal and messing around there for a while, then make the changes in the script
after you're done changing what's relevant you your sound card save the script somewhere in /usr/bin and chmod +x it. mine is called ali-vol
now to bind that to the keyboad.
assuming you are running openbox go to your ~/.config/openbox/rc.xml
and in the keyboard bindings add
Code: | <keybind key="XF86AudioRaiseVolume">
<action name="Execute">
<command>ali-vol 1</command>
</action>
</keybind>
<keybind key="XF86AudioLowerVolume">
<action name="Execute">
<command>ali-vol 2</command>
</action>
</keybind>
<keybind key="XF86AudioMute">
<action name="Execute">
<command>ali-vol 3</command>
</action>
</keybind> |
i couldn't figure out how to get the media keys working on mine so instead of the XF86 audio keys i use control-alt-shift-up for volume up, down for volume down and left / right for mute/unmute
Code: | <keybind key="C-A-S-Up">
<action name="Execute">
<command>ali-vol 1</command>
</action>
</keybind>
<keybind key="C-A-S-Down">
<action name="Execute">
<command>ali-vol 2</command>
</action>
</keybind>
<keybind key="C-A-S-Left">
<action name="Execute">
<command>ali-vol 3</command>
</action>
</keybind>
<keybind key="C-A-S-Right">
<action name="Execute">
<command>ali-vol 3</command>
</action>
</keybind> |
after you modified your rc.xml run
Code: | openbox --reconfigure |
in a terminal and assuming you didn't mess anything up while adding that the script should work and properly display changes
if anyone manages to get the media keys working please let me know
|
Back to top
|
|
 |
disciple
Joined: 20 May 2006 Posts: 6995 Location: Auckland, New Zealand
|
Posted: Sun 24 Apr 2011, 07:42 Post subject:
|
|
Quote: | if anyone manages to get the media keys working please let me know |
Usually I think people use Sven for this (search the forum for a package). At least they used to, anyway.
_________________ Do you know a good gtkdialog program? Please post a link here
Classic Puppy quotes
ROOT FOREVER
GTK2 FOREVER
|
Back to top
|
|
 |
alexandrion

Joined: 19 Feb 2011 Posts: 105
|
Posted: Sun 24 Apr 2011, 08:40 Post subject:
|
|
upon reading your post i decided to give sven a try but unfortunately it failed to detect the buttons (just like xev)
thanks anyway
|
Back to top
|
|
 |
8-bit

Joined: 03 Apr 2007 Posts: 3425 Location: Oregon
|
Posted: Sun 24 Apr 2011, 13:37 Post subject:
|
|
I have a Compaq PC with volume adjustment keys on the keyboard and they work in Lupu 520.
If you have the tray volume slider up, the display does not change when the keyboard associated keys are pressed.
But if you exit the volume slider adjustment and reopen it, the volume will have been changed as per the keyboard volume keys.
|
Back to top
|
|
 |
alexandrion

Joined: 19 Feb 2011 Posts: 105
|
Posted: Sun 24 Apr 2011, 13:51 Post subject:
|
|
actually retrovol was the first thing i removed when i got here,
my problem is that xev doesn't notice when i press the media keys, anyway,i can live without them
this thread is more about the script anyway
|
Back to top
|
|
 |
CatDude

Joined: 03 Jan 2007 Posts: 1573 Location: UK
|
Posted: Sun 24 Apr 2011, 15:30 Post subject:
|
|
Hello alexandrion
alexandrion wrote: | ...my problem is that xev doesn't notice when i press the media keys, |
Maybe this will help, it describes how i got all 23 keys working on my keyboard.
CatDude
P.S
If you cannot get hold of a copy of setkeycodes
let me know and i will post the one i am using.
.
Description |
Updated because i noticed a typo
|

Download |
Filename |
keys.pdf.gz |
Filesize |
45.14 KB |
Downloaded |
572 Time(s) |
_________________

Last edited by CatDude on Tue 26 Apr 2011, 11:37; edited 1 time in total
|
Back to top
|
|
 |
alexandrion

Joined: 19 Feb 2011 Posts: 105
|
Posted: Sun 24 Apr 2011, 17:09 Post subject:
|
|
the keys don't get logged as inexistent ...
|
Back to top
|
|
 |
|