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 } },
};
@yalin

This comment has been minimized.

Copy link

@yalin yalin commented May 2, 2012

nice work bro

@jimcadden

This comment has been minimized.

Copy link

@jimcadden jimcadden commented May 3, 2012

thanks for sharing

@daninjah

This comment has been minimized.

Copy link

@daninjah daninjah commented Aug 22, 2014

this is nice

@elbaulp

This comment has been minimized.

Copy link

@elbaulp 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

This comment has been minimized.

Copy link
Owner Author

@neuro-sys neuro-sys commented Jan 23, 2015

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

Also thanks algui91, I've added yours.

@peko

This comment has been minimized.

Copy link

@peko peko commented Aug 12, 2015

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

@Sukonnik-Illia

This comment has been minimized.

Copy link

@Sukonnik-Illia Sukonnik-Illia commented Jun 17, 2017

Great thanks.

@ghost

This comment has been minimized.

@jcrcx

This comment has been minimized.

Copy link

@jcrcx jcrcx commented May 15, 2018

Thanks brooo !!!! Nice work!

@ratfactor

This comment has been minimized.

Copy link

@ratfactor 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

This comment has been minimized.

Copy link

@elycastellano elycastellano commented Jun 1, 2020

Thanks for share!

@hamzashahid-blit

This comment has been minimized.

Copy link

@hamzashahid-blit hamzashahid-blit 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

This comment has been minimized.

Copy link
Owner Author

@neuro-sys 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

This comment has been minimized.

Copy link

@BakedSnake BakedSnake commented Nov 30, 2020

Sick!

@agung-satria

This comment has been minimized.

Copy link

@agung-satria 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,

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