noisybox blog
https://noisybox.net/images/favicon.ico
https://noisybox.net/images/profile_pic_200.png
© 2017 jason plumb / noisybox / infiltration lab.
2009-04-02T06:38:20.000Z
Jason Plumb
jason@noisybox.net
urn:uuid:75392340-704d-463f-9dc0-98b78c24a4bc
Make sound on Fluxbox volume changes.
https://noisybox.net/blog/2009/04/make_sound_on_fluxbox_volume_changes
2009-04-02T06:38:20.000Z
<p><img src="http://noisybox.net/blog/images/scream_that_one_sound.jpg" alt="scream that sound"></p>
<p>I recently acquired a <a href="http://msiwind.net/">certain netbook</a> so that I could be frugal but still have the ability to hack while mobile. Of course, I have to run <a href="http://debian.org">Debian</a>...it's a curse...but it rules.</p>
<p>Surprisingly, things work altogether very very well. I still don't think I'm that savvy, but I've gotten things to play together quite nicely. I will create a real page and post my results/settings/findings soon....but I made a stupid simple hack tonight that I thought I'd share.</p>
<p>So I'm running <a href="http://www.fluxbox.org">Fluxbox</a> again. It's clean, simple, and takes up very little screen real-estate. It's been a few years, but it's as elegant and non-intrusive as I remember it.</p>
<p>The default keys file for fluxbox has commands that grok asla (via alsactl) and are able to nudge the volume up/down based on the magical function modifier keys (like Fn+F7 or Fn+F8 on the Wind). That's all great...but at least with the sound apps I run (including <em>Flash</em>!), the defaults aren't enough because this "Front" control keeps stomping on things (eg. it apparently needs to be massaged after the Master is massaged). I wish this wasn't the case, it's stupid, I should complain...Whatever.</p>
<p>Scripts to the rescue.</p>
<p>For the MSI Wind, I made three scripts, one does muting, the other two do volume up/down. They look something like this:</p>
<pre><tt>#!/bin/bash
for control in Master Front ; do
amixer sset ${control},0 1+
done
aplay ~/media/sounds/volume_change.wav</tt>
</pre>
<p>The 1+ indicates volume up, change to 1- for volume down.</p>
<p>And then in ~/.fluxbox/keys we can map things like:</p>
<pre><tt>176 :Exec ~/bin/volume_up
174 :Exec ~/bin/volume_down
160 :Exec ~/bin/volume_mute</tt>
</pre>
<p>What this provides is two things. First, when you press Fn+F7, for example, the Master and Front volume levels will both decrement. The Front is changed last, so that the actual volume output level is applied. Secondly, the 'aplay' line gives a little chime to audibly indicate the volume level...something akin to the sound that those $2000 Macintoshes make.</p>
<p>I found <a href="http://www.freesound.org/samplesViewSingle.php?id=5297">this bink sound</a> on <a href="http://freesound.org">freesound</a> and think it works quite well.</p>
<p>Until I can create a real page for my Wind setup, scream loud and enjoy the hack.</p>