Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Fri 18 Apr 2014, 22:16
All times are UTC - 4
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Utilities
keyboard volume changer
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [7 Posts]  
Author Message
alexandrion


Joined: 19 Feb 2011
Posts: 105

PostPosted: 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
View user's profile Send private message 
disciple

Joined: 20 May 2006
Posts: 6378
Location: Auckland, New Zealand

PostPosted: 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.

_________________
DEATH TO SPREADSHEETS
- - -
Classic Puppy quotes
- - -
Beware the demented serfers!
Back to top
View user's profile Send private message 
alexandrion


Joined: 19 Feb 2011
Posts: 105

PostPosted: 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 Very Happy
Back to top
View user's profile Send private message 
8-bit


Joined: 03 Apr 2007
Posts: 3279
Location: Oregon

PostPosted: 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
View user's profile Send private message 
alexandrion


Joined: 19 Feb 2011
Posts: 105

PostPosted: 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 Smile
this thread is more about the script anyway
Back to top
View user's profile Send private message 
CatDude


Joined: 03 Jan 2007
Posts: 1432
Location: UK

PostPosted: 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.
.
keys.pdf.gz
Description  Updated because i noticed a typo
gz

 Download 
Filename  keys.pdf.gz 
Filesize  45.14 KB 
Downloaded  191 Time(s) 

_________________


Last edited by CatDude on Tue 26 Apr 2011, 11:37; edited 1 time in total
Back to top
View user's profile Send private message 
alexandrion


Joined: 19 Feb 2011
Posts: 105

PostPosted: Sun 24 Apr 2011, 17:09    Post subject:  

the keys don't get logged as inexistent ...
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [7 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Utilities
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0970s ][ Queries: 13 (0.0059s) ][ GZIP on ]