| View previous topic :: View next topic |
| Author |
Message |
Aynjell Veteran


Joined: 28 Jun 2004 Posts: 1116
|
Posted: Fri Oct 28, 2005 10:18 pm Post subject: Command to alter volumes? |
|
|
Is there a command that can be used to alter volumes? I need to be able to alter the volume entirely with a single command. No fudging with a UI, just something like:
<command> <device> <mixer> -5
or
<command> <device> <mixer> +5
Mainly, so I can bind commands to alter volumes. Using stuff like kmix is always a painful process. _________________ CPU: 3800+ X2 (2.5Ghz)
GPU: eVGA 7600GT (640/1700)
MOBO: DFI SLI-DR (Surprisingly good!)
RAM: 2 x OCZ Gold 1024 DDR500 3-4-3-7 (2048)
HDD: Western Digital Raptor |
|
| Back to top |
|
 |
yabbadabbadont Veteran


Joined: 13 Mar 2003 Posts: 4311 Location: Ozark Plateau
|
Posted: Fri Oct 28, 2005 11:17 pm Post subject: |
|
|
setmixer
smixer
cmix
I think all of these will do what you want. |
|
| Back to top |
|
 |
Aynjell Veteran


Joined: 28 Jun 2004 Posts: 1116
|
Posted: Fri Oct 28, 2005 11:20 pm Post subject: |
|
|
Awesome, I appreciate the response. if it works, kudos, man! _________________ CPU: 3800+ X2 (2.5Ghz)
GPU: eVGA 7600GT (640/1700)
MOBO: DFI SLI-DR (Surprisingly good!)
RAM: 2 x OCZ Gold 1024 DDR500 3-4-3-7 (2048)
HDD: Western Digital Raptor |
|
| Back to top |
|
 |
ppurka Veteran

Joined: 26 Dec 2004 Posts: 1124
|
Posted: Sat Oct 29, 2005 3:36 am Post subject: |
|
|
If you are using alsa then try something similar: | Code: | amixer sset 'PCM' 2%+
amixer sset 'PCM' 2%-
amixer sset 'PCM' mute
amixer sset 'PCM' unmute
| You could have other options such as 'Surround', 'Center', 'LFE', etc. instead of 'PCM'.
amixer is provided by the alsa-utils package, i think. |
|
| Back to top |
|
 |
Aynjell Veteran


Joined: 28 Jun 2004 Posts: 1116
|
Posted: Sat Oct 29, 2005 12:40 pm Post subject: |
|
|
ppurka, I love you. _________________ CPU: 3800+ X2 (2.5Ghz)
GPU: eVGA 7600GT (640/1700)
MOBO: DFI SLI-DR (Surprisingly good!)
RAM: 2 x OCZ Gold 1024 DDR500 3-4-3-7 (2048)
HDD: Western Digital Raptor |
|
| Back to top |
|
 |
ppurka Veteran

Joined: 26 Dec 2004 Posts: 1124
|
Posted: Sat Oct 29, 2005 4:20 pm Post subject: |
|
|
| Aynjell wrote: | | ppurka, I love you. |  |
|
| Back to top |
|
 |
Aynjell Veteran


Joined: 28 Jun 2004 Posts: 1116
|
Posted: Sat Oct 29, 2005 4:29 pm Post subject: |
|
|
Hrm, not much of a script writer, but is there a way to check if it's muted, and if it is, unmute it, otherwise just mute? So I can apply that to my mute key. Going through kmix can be painful.  _________________ CPU: 3800+ X2 (2.5Ghz)
GPU: eVGA 7600GT (640/1700)
MOBO: DFI SLI-DR (Surprisingly good!)
RAM: 2 x OCZ Gold 1024 DDR500 3-4-3-7 (2048)
HDD: Western Digital Raptor |
|
| Back to top |
|
 |
yabbadabbadont Veteran


Joined: 13 Mar 2003 Posts: 4311 Location: Ozark Plateau
|
Posted: Sat Oct 29, 2005 5:20 pm Post subject: |
|
|
| Code: | /home/yoiks $ amixer get PCM | grep -q "\[on\]"
/home/yoiks $ echo $?
0
|
This is if the PCM device is unmuted. The exit status ($?) will be 1 if it is muted. |
|
| Back to top |
|
 |
yabbadabbadont Veteran


Joined: 13 Mar 2003 Posts: 4311 Location: Ozark Plateau
|
Posted: Sat Oct 29, 2005 5:24 pm Post subject: |
|
|
| Code: | if amixer get PCM | grep -q "\[on\]"; then
amixer sset 'PCM' mute
else
amixer sset 'PCM' unmute
fi
|
This will toggle the muted state of the specified simple device.
EDIT: change the amixer sset commands to amixer -q sset if you don't want to see any console output. Don't change the line in the if statement though. |
|
| Back to top |
|
 |
ppurka Veteran

Joined: 26 Dec 2004 Posts: 1124
|
Posted: Sat Oct 29, 2005 8:42 pm Post subject: |
|
|
This is a script I use when I use alsa (currently I am using nvsound driver). The way to use it is:
| Code: | volmute increase --- to increase volume
volmute decrease --- to decrease volume
volmute mute --- to mute/unmute |
The script: | Code: | #!/bin/bash
volsetting=`amixer sget 'PCM' | grep off`
case "$1" in
mute)
if [[ x"$volsetting" = x"" ]]; then
amixer sset 'PCM' mute
amixer sset 'Surround' mute
amixer sset 'Center' mute
amixer sset 'LFE' mute
else
amixer sset 'PCM' unmute
amixer sset 'Surround' unmute
amixer sset 'Center' unmute
amixer sset 'LFE' unmute
fi
;;
increase)
amixer sset 'PCM' 2%+
amixer sset 'Surround' 2%+
amixer sset 'Center' 2%+
amixer sset 'LFE' 2%+
;;
decrease)
amixer sset 'PCM' 2%-
amixer sset 'Surround' 2%-
amixer sset 'Center' 2%-
amixer sset 'LFE' 2%-
;;
*)
echo "This is not an acceptable command!";
echo -e "Use \033[01;33mmute\033[01;00;0m, \033[01;33mincrease\033[01;00;0m or \033[01;33mdecrease\033[01;00;0m as options!";
echo;
esac
|
|
|
| Back to top |
|
 |
djlosch n00b


Joined: 27 Aug 2005 Posts: 67
|
Posted: Tue Nov 01, 2005 1:12 am Post subject: |
|
|
awesome script! thanks! _________________ I'm not your attorney. This post isn't legal advice. Always consult an attorney licensed to practice in your jurisdiction.
tapthehive - fakebillgates |
|
| Back to top |
|
 |
mnxAlpha Apprentice

Joined: 14 Sep 2004 Posts: 210
|
Posted: Tue Nov 01, 2005 1:28 am Post subject: |
|
|
| Possibly a simpler way. Kmix has an option somewhere to set global keyboard shortcuts. I can't check exactly where that is at the moment, because I'm in Gnome, but it's there somewhere. I think you right-click on the master volume slider and select "Global Shortcuts" or something like that. I had it set up using the volume up / down and mute buttons on my keyboard, but it works with normal keys and modifiers. Gnome has a similar option, configured from the keyboard options applet. |
|
| Back to top |
|
 |
soroh6 Apprentice


Joined: 06 Nov 2002 Posts: 227
|
Posted: Sat Jul 07, 2007 12:33 am Post subject: |
|
|
I guess this is terribly old thread, but that script above is working great for me
| Code: | #!/bin/bash
volsetting=`amixer sget 'PCM' | grep off`
case "$1" in
*)
if [[ x"$volsetting" = x"" ]]; then
amixer -q sset 'Master' mute
amixer -q sset 'PCM' mute
amixer -q sset 'Surround' mute
amixer -q sset 'Center' mute
amixer -q sset 'LFE' mute
else
amixer -q sset 'Master' unmute
amixer -q sset 'PCM' unmute
amixer -q sset 'Surround' unmute
amixer -q sset 'Center' unmute
amixer -q sset 'LFE' unmute
fi
esac |
I just needed the mute version of it for hotkeys, so I modified it to only do muting. Maybe this bump will be useful to someone else. Also added the -q's so theres no output. _________________ :: soroh -*~ |
|
| Back to top |
|
 |
|