Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
dwm volume control
/**
* config.h
* ALT + F11 | F12
*/
static const char *upvol[] = { "amixer", "set", "Master", "3+", NULL };
static const char *downvol[] = { "amixer", "set", "Master", "3-", NULL };
static const char *mutevol[] = { "amixer", "set", "Master", "toggle", NULL };
static Key keys[] = {
{ MODKEY, XK_F12, spawn, {.v = upvol } },
{ MODKEY, XK_F11, spawn, {.v = downvol } },
{ MODKEY, XK_F9, spawn, {.v = mutevol } },
};
@elbaulp
Copy link

elbaulp commented Jan 2, 2015

Just what I was looking for. Thank you! I've also added an option to mute/unmute:

static const char *mutevol[] = { "amixer", "set", "Master", "toggle", NULL};

@neuro-sys
Copy link
Author

neuro-sys commented Jan 23, 2015

Haha, I didn't realize people would check github gists.

Also thanks algui91, I've added yours.

@peko
Copy link

peko commented Aug 12, 2015

Спасибо братан!

@Sukonnik-Illia
Copy link

Sukonnik-Illia commented Jun 17, 2017

Great thanks.

Copy link

ghost commented Feb 18, 2018

@jcrcx
Copy link

jcrcx commented May 15, 2018

Thanks brooo !!!! Nice work!

@ratfactor
Copy link

ratfactor commented Apr 19, 2019

This is exactly what I was looking for. On my system, the numeric range for the Master volume is large:

Limits: Capture 0 - 65536

So I needed to explicitly user percentages instead:

static const char *upvol[]   = { "amixer", "set", "Master", "10%+",     NULL };
static const char *downvol[] = { "amixer", "set", "Master", "10%-",     NULL };

(And with 10% increments, it's really speedy to adjust.)

Thanks for this!

@elycastellano
Copy link

elycastellano commented Jun 1, 2020

Thanks for share!

Copy link

ghost commented Jul 6, 2020

Thanks a lot for this!

A totally seperate issue,
my keys from F1 to F12 don't work in dwm, work in every other window manager/desktop environment

@neuro-sys
Copy link
Author

neuro-sys commented Jul 6, 2020

I find it very surprising when people find seemingly simple things very useful. I'm happy that it's useful for others.

@BakedSnake
Copy link

BakedSnake commented Nov 30, 2020

Sick!

@agung-satria
Copy link

agung-satria commented Jul 3, 2021

what if i login as non root user, the upvol and downvol didn't work for me
if i try sudo amixer set Master 3+ null, on terminal it worked,

@kurth4cker
Copy link

kurth4cker commented Oct 15, 2021

Great

@gssasank
Copy link

gssasank commented Jan 1, 2022

If anyone's wondering why the vol up and down aren't working for them, just use sudo amixer in place of amixer

@jumps-are-op
Copy link

jumps-are-op commented Jan 24, 2022

for people that use pamixer instead of amixer

 static const char *upvol[]   = { "pamixer", "--increase", "3", NULL };
 static const char *downvol[] = { "pamixer", "--decrease", "3", NULL };
 static const char *mutevol[] = { "pamixer", "-t",              NULL };

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment