LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-25-2008, 06:39 PM   #1
kinesis1
LQ Newbie
 
Registered: Feb 2008
Posts: 5

Rep: Reputation: 0
Trying to make a script to adjust my laptop volume.. help please


Ok I am trying to figure out 1) how to make a global alias in bash, these () functions dont work and 2) how to make it so the assigned keycodes from xev perform the desired alias, below is my script:

#######################################################
## COMPAQ MUSIC VOLUME CONTROLS ## #
## - WORKS FOR ANY LAPTOP IN GENERAL ## by #
## JUST USE 'xev' TO DETERMINE THE FN ## Kinetic Labs #
## KEYCODES. socalchronic@gmail.com ## (C) GNUPL #
###################################################################
# Brightness up and down should already work #
# So just define start/stop/play/forward/reverse/www/etc #
# pressing play w/o a media player open will open it #
# to do: research how to hook into your music player #
# we will use audacious the best X music player for #
# this example! For best results stick this in ~/kde/.Autostart/! #
########### edit to suit your FN keys #############################
# NOTE: This script assumes you run ALSA. #
###################################################################

MEDIA_PLAYER="/usr/local/bin/audacious"
VOL_UP="176"
VOL_DOWN="174"
MEDIA_PLAY="162"
MEDIA_STOP="164"
MEDIA_PREV="144"
MEDIA_FOWR="153"
WWW_BROWSER="/usr/bin/firefox"
ACCESS_WWW="178"

#amixer -c 0 -- sset Master playback -5dB|grep dB|head -1|cut -d' ' -f8
alias increase_vol() {
CURRENT_VOLUME=`amixer -c 0 -- get Master playback|grep dB|head -1|cut -d' ' -f8|cut -d'[' -f2|cut -d']' -f1|cut -d'd' -f1`
NEW_VOLUME=`expr $CURRENT_VOLUME + 1`
amixer -c 0 -- sset Master playback $NEW_VOLUMEdB
}
alias decrease_vol() {
CURRENT_VOLUME=`amixer -c 0 -- get Master playback|grep dB|head -1|cut -d' ' -f8|cut -d'[' -f2|cut -d']' -f1|cut -d'd' -f1`
NEW_VOLUME=`expr $CURRENT_VOLUME - 1`
amixer -c 0 -- sset Master playback $NEW_VOLUMEdB
}
#media_play() {}
#media_stop() {}
#media_prev() {}
#media_fowr() {}
#www_browser() {}
 
Old 02-25-2008, 11:21 PM   #2
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
I'm not sure if I understand. I enable multimedia keys in X by creating an ~/.xmodmap file that contains
Code:
...
keycode 174 = XF86AudioLowerVolume
keycode 160 = XF86AudioMute
keycode 176 = XF86AudioRaiseVolume

keycode 144 = XF86AudioPrev
keycode 164 = XF86AudioStop
keycode 162 = XF86AudioPlay
keycode 153 = XF86AudioNext
...
And then my ~/.xinitrc contains
Code:
...
# activate some weird keys
if [ -r ~/.xmodmap ]; then
    xmodmap ~/.xmodmap
fi
...
And then my ~/.fvwm/config contains
Code:
...
# Control the volume.
Key XF86AudioLowerVolume A N Exec exec amixer -q set PCM 5%-
Key XF86AudioMute A N Exec exec amixer -q set PCM toggle
Key XF86AudioRaiseVolume A N Exec exec amixer -q set PCM 5%+
# Control $MUSIC_DAEMON_APP
Key XF86AudioPrev A N Exec exec mocp -r
Key XF86AudioStop A N Exec exec mocp -s
Key XF86AudioPlay A N Exec exec mocp_toggle
Key XF86AudioNext A N Exec exec mocp -f
# Control XMMS/BMP/Audacious/LightningPanda.
Key XF86AudioPrev A 4 Exec exec audacious -r
Key XF86AudioStop A 4 Exec exec audacious -s
Key XF86AudioPlay A 4 Exec exec audacious -t
Key XF86AudioNext A 4 Exec exec audacious -f
...
If that's not what you're trying to do, sorry, but maybe you could restate the problem.
 
Old 02-26-2008, 12:30 AM   #3
kinesis1
LQ Newbie
 
Registered: Feb 2008
Posts: 5

Original Poster
Rep: Reputation: 0
keeping it simple, thanks ill just use that

but what's the kde equivalent of fvwm's .config where those key commands will actually work?

Last edited by kinesis1; 02-26-2008 at 12:34 AM.
 
Old 02-26-2008, 01:47 AM   #4
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
Sorry, I don't use KDE, so I don't remember. The key bindings gizmo somewhere in the control panel might work. As far as where the actual file is, I have no idea.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't adjust volume on AC97 Mojojo Linux - Hardware 8 05-04-2006 03:56 PM
Why does mplayer adjust system volume? wpg9210 Linux - Software 0 05-18-2004 11:25 AM
How to adjust sound volume? CodeWarrior Slackware 9 06-08-2003 12:51 PM
Sound Volume Won't Adjust in KDE 3.0.1 mackie_lin Linux - Software 3 12-28-2002 04:27 PM
Need to adjust volume amp2000 Linux - General 3 01-11-2002 01:54 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:52 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration