2020-12-14 My volume control in AwesomeWM

Embrace yourselves, since a heresy is coming!

I sometimes am outside Emacs (gasp!), and getting to it is a bit uncomfortable. Well, you’ve probably guess that I mean being in a browser. That, too, but I’ve been watching one little show for a few months now, and I sometimes find myself being in vlc and wanting to adjust the system volume.

Well, it’s easy enough from within Emacs. However, pausing the video, going to Emacs, changing the volume and getting back to vlc just doesn’t work very well.

Now, a natural way would be to use vlc’s volume control. But I don’t like that solution – I really prefer to use the global, system settings. So, I decided to just add volume-changing keys to my window manager.

So, here is my addition to the ~/config/awesome/rc.lua file:

globalkeys = gears.table.join(
   -- volume control
   awful.key({ modkey, }, "Up",   function() awful.util.spawn("louder.sh") end),
   awful.key({ modkey, }, "Down", function() awful.util.spawn("quieter.sh") end),
   -- ...

The scripts louder.sh looks like this:

amixer set Master 5%+ > /dev/null
notify-send "$(awk -F"[][]" '/Left:/ { print $2 }' <(amixer sget Master))"

(I used this unix.stackexchange answer); quieter.sh is similar. As you can see, I enabled feedback via notify-send – it’s not the prettiest thing in the world, and pressing s-up or s-down a few times in a row makes the row of notifications look weird, but it does the job.

CategoryEnglish, CategoryBlog