You are not logged in.

#1 2012-07-15 15:14:06

ephan
Member
Registered: 2011-11-02
Posts: 171

[SOLVED] Change volume with terminal

I want to know how I can lower or increase volume in the terminal.

amixer set Master 2+

I tried that, it gives:

avid@davidarch:~$ amixer set Master 2+
Simple mixer control 'Master',0
  Capabilities: pvolume pswitch pswitch-joined penum
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 65536
  Mono:
  Front Left: Playback 24540 [37%] [on]
  Front Right: Playback 24540 [37%] [on]
david@davidarch:~$ 

But it doesn't work :S

Any ideas? Thank you.

Last edited by ephan (2012-07-16 21:55:43)

Offline

#2 2012-07-15 15:17:19

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,595
Website

Re: [SOLVED] Change volume with terminal

ALSA or pulse audio or...


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#3 2012-07-15 15:20:28

ephan
Member
Registered: 2011-11-02
Posts: 171

Re: [SOLVED] Change volume with terminal

graysky wrote:

ALSA or pulse audio or...

Honestly, I'm not even sure which I'm using, I can't recall. But alsamixer works, so it should be alsa.

Offline

#4 2012-07-15 15:21:13

stlarch
Member
From: hell
Registered: 2010-12-25
Posts: 1,265

Re: [SOLVED] Change volume with terminal

Try

amixer set Master playback 1+
amixer set Master playback -1
amixer set Master toggle

Offline

#5 2012-07-15 15:24:06

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,595
Website

Re: [SOLVED] Change volume with terminal

$ ps aux | grep pulse

If it is pulse, https://aur.archlinux.org/packages.php?ID=51529

Last edited by graysky (2012-07-15 18:41:08)


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#6 2012-07-15 18:38:13

ephan
Member
Registered: 2011-11-02
Posts: 171

Re: [SOLVED] Change volume with terminal

None of those worked, except for "amixer set Master toggle" to toggle the sound. "amixer -c 0 set PCM 3dB+" worked though. Thank you!

Also, how can I get the sound percentage? Thank you.

Offline

#7 2012-07-15 18:41:23

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,595
Website

Re: [SOLVED] Change volume with terminal

...are you using pulse?


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#8 2012-07-15 19:19:45

ephan
Member
Registered: 2011-11-02
Posts: 171

Re: [SOLVED] Change volume with terminal

graysky wrote:

...are you using pulse?

No.

Offline

#9 2012-07-15 19:39:29

bohoomil
Member
Registered: 2010-09-04
Posts: 2,376
Website

Re: [SOLVED] Change volume with terminal

ephan wrote:

None of those worked, except for "amixer set Master toggle" to toggle the sound. "amixer -c 0 set PCM 3dB+" worked though. Thank you!

Try using

amixer -q sset PCM 1+
amixer -q sset PCM 1-

then.


:: Registered Linux User No. 223384

:: github
:: infinality-bundle+fonts: good looking fonts made easy

Offline

#10 2012-07-15 20:18:48

ephan
Member
Registered: 2011-11-02
Posts: 171

Re: [SOLVED] Change volume with terminal

I already found a way, but for the record: "amixer: Unable to find simple control 'PCM'" is the output.

Offline

#11 2012-07-16 04:49:37

x33a
Forum Fellow
Registered: 2009-08-15
Posts: 4,587

Re: [SOLVED] Change volume with terminal

ephan wrote:

Also, how can I get the sound percentage? Thank you.

Maybe this will work.

$ amixer get Master | tail -1 | awk '{print$4}'

Offline

#12 2012-07-16 04:55:20

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: [SOLVED] Change volume with terminal

x33a wrote:
ephan wrote:

Also, how can I get the sound percentage? Thank you.

Maybe this will work.

$ amixer get Master | tail -1 | awk '{print$4}'

or just awk smile

awk '/%/ {gsub(/[\[\]]/,""); print $4}' <(amixer sget Master)

Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#13 2012-07-16 09:58:14

ephan
Member
Registered: 2011-11-02
Posts: 171

Re: [SOLVED] Change volume with terminal

jasonwryan wrote:
x33a wrote:
ephan wrote:

Also, how can I get the sound percentage? Thank you.

Maybe this will work.

$ amixer get Master | tail -1 | awk '{print$4}'

or just awk smile

awk '/%/ {gsub(/[\[\]]/,""); print $4}' <(amixer sget Master)

That little snippet is returning the value, not the percentage:


david@davidarch:~$ awk '/%/ {gsub(/[\[\]]/,""); print $4}' <(amixer sget Master)
65536
65536
david@davidarch:~$ awk '/%/ {gsub(/[\[\]]/,""); print $4}' <(amixer sget Master)
7202
7202
david@davidarch:~$ awk '/%/ {gsub(/[\[\]]/,""); print $4}' <(amixer sget Master)
0
0
david@davidarch:~$ 

Since I don't know bash, I'll just cook some Perl magic to get the percentage.

The first one is also a value:

david@davidarch:~$ amixer get Master | tail -1 | awk '{print$4}'
0
david@davidarch:~$ amixer get Master | tail -1 | awk '{print$4}'
391
david@davidarch:~$ amixer get Master | tail -1 | awk '{print$4}'
521
david@davidarch:~$ amixer get Master | tail -1 | awk '{print$4}'
48972
david@davidarch:~$ 

Is there a way to get percentage using bash? If there isn't, no problem, but if there is, that'd be even simpler.

Thank you smile

Offline

#14 2012-07-16 10:25:55

skanky
Member
From: WAIS
Registered: 2009-10-23
Posts: 1,847

Re: [SOLVED] Change volume with terminal

Try changing $4 to $5 in the above commands.
EDIT: if that doesn't work post the output of

amixer get Master

Here's mine (shows [off] for muted, which could be changed to whatever by replacing $7 with the required string):

amixer get Master | awk '/^ *Front Left.*/ {print $7=="[off]"?$7:$5}'

Last edited by skanky (2012-07-16 10:26:53)


"...one cannot be angry when one looks at a penguin."  - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle

Offline

#15 2012-07-16 12:32:00

ANOKNUSA
Member
Registered: 2010-10-22
Posts: 2,141

Re: [SOLVED] Change volume with terminal

ephan wrote:

None of those worked, except for "amixer set Master toggle" to toggle the sound. "amixer -c 0 set PCM 3dB+" worked though. Thank you!

Also, how can I get the sound percentage? Thank you.

Just curious, is it possible that none of the suggestions work because they involve the Master channel, while the PCM channel is turned very far/all the way down?  Turn PCM all  the way up, then try the earlier commands; there's no reason they shouldn't work if you have functioning sound on your system.

Offline

#16 2012-07-16 14:01:24

ephan
Member
Registered: 2011-11-02
Posts: 171

Re: [SOLVED] Change volume with terminal

skanky wrote:

Try changing $4 to $5 in the above commands.
EDIT: if that doesn't work post the output of

amixer get Master

Here's mine (shows [off] for muted, which could be changed to whatever by replacing $7 with the required string):

amixer get Master | awk '/^ *Front Left.*/ {print $7=="[off]"?$7:$5}'

That was, erm, perfect? Thanks a ton.

Offline

#17 2012-07-16 15:35:52

skanky
Member
From: WAIS
Registered: 2009-10-23
Posts: 1,847

Re: [SOLVED] Change volume with terminal

No problem - can you mark the thread as solved, please? smile

Just for future reference, I'd find a simple beginner's guide to awk (and sed, maybe). You don't need to know much, but $4 is the fourth field, with default delimiter as a space. If that's all you're doing, then cut will do the job fine, but awk can do so much more. The manual for both is useful, but with awk a guide is better at first go. If you can understand perl, then it won't be difficult. wink


"...one cannot be angry when one looks at a penguin."  - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle

Offline

#18 2012-07-16 16:26:20

DSpider
Member
From: Romania
Registered: 2009-08-23
Posts: 2,273

Re: [SOLVED] Change volume with terminal

Limits: Playback 0 - 65536

If you use "amixer set Master 2+", you have to press it a few hundred times to notice any effect.


From the Openbox wiki:

$ amixer set Master 5%+
$ amixer set Master 5%-

"How to Succeed with Linux"

I have made a personal commitment not to reply in topics that start with a lowercase letter. Proper grammar and punctuation is a sign of respect, and if you do not show any, you will NOT receive any help (at least not from me).

Offline

#19 2012-07-16 17:44:38

x33a
Forum Fellow
Registered: 2009-08-15
Posts: 4,587

Re: [SOLVED] Change volume with terminal

jasonwryan wrote:
x33a wrote:
ephan wrote:

Also, how can I get the sound percentage? Thank you.

Maybe this will work.

$ amixer get Master | tail -1 | awk '{print$4}'

or just awk smile

awk '/%/ {gsub(/[\[\]]/,""); print $4}' <(amixer sget Master)

That's much better. My awk knowledge is just limited to printing stuff tongue

Offline

#20 2012-07-16 20:03:18

Terminator
Member
From: Belgium
Registered: 2012-05-07
Posts: 265

Re: [SOLVED] Change volume with terminal

ephan wrote:

I want to know how I can lower or increase volume in the terminal.

amixer set Master 2+

I tried that, it gives:

avid@davidarch:~$ amixer set Master 2+
Simple mixer control 'Master',0
  Capabilities: pvolume pswitch pswitch-joined penum
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 65536
  Mono:
  Front Left: Playback 24540 [37%] [on]
  Front Right: Playback 24540 [37%] [on]
david@davidarch:~$ 

But it doesn't work :S

Any ideas? Thank you.

That does work, but you are changing it by 2 on a scale of 65536. Try amixer set Master 2%+ (or 5%+ whatever you want smile).

Offline

#21 2012-07-17 10:06:06

ephan
Member
Registered: 2011-11-02
Posts: 171

Re: [SOLVED] Change volume with terminal

Woo! Changing the percentage worked much better, thank you!

Offline

#22 2019-06-25 04:07:32

dirtydan
Member
Registered: 2019-06-22
Posts: 1

Re: [SOLVED] Change volume with terminal

Pulse audio lets you adjust the volume like so:

pactl set-sink-volume 0 30%
pactl set-sink-volume 0 -30%
pactl set-sink-volume 0 +30%

You might need to edit the '0' param depending on the device your using. '1' worked for me, I'm using the PCM channel

https://wiki.archlinux.org/index.php/Pu … o/Examples

Last edited by dirtydan (2019-06-25 04:08:57)

Offline

#23 2019-06-25 04:21:21

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: [SOLVED] Change volume with terminal

Six year old thread and you are just pasting from the wiki? Don't do that:

https://wiki.archlinux.org/index.php/Co … bumping.22

Closing


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

Board footer

Powered by FluxBB