Multimedia Keys
Using a multimedia keyboard in FreeBSD with X isn't as straightforward as it in in GNU/Linux or OpenBSD, but it's not bad.
Some of this is cargo-cult, but this is that I've gleaned from the nice folks on EFnet/#freebsd-xorg, and in particular from dumbbell.
First, in /boot/loader.conf:
hw.usb.usbhid.enable=1
Then, in /etc/rc.conf:
kld_list="iichid hcons hms hmt uhid"
This was recommended, but has some unpleasant side effects. As an example, it prevents my Logitech C505 HD Webcam from attaching to uaudio, which means it can't be used as a microphone. I'll have to ask what it accomplishes.
devmatch_enable="NO"
OpenBox volume control example
With this in place, actually using the keys is going to be something you configure in whatever windowing environment you use.
Here's what I do in OpenBox. You probably don't need this.
In ~/.config/openbox/rc.xml:
<keyboard>
<keybind key="S-XF86AudioLowerVolume">
<action name="Execute">
<command>~/bin/volume -1</command>
</action>
</keybind>
<keybind key="S-XF86AudioRaiseVolume">
<action name="Execute">
<command>~/bin/volume +1</command>
</action>
</keybind>
<keybind key="XF86AudioLowerVolume">
<action name="Execute">
<command>~/bin/volume -5</command>
</action>
</keybind>
<keybind key="XF86AudioRaiseVolume">
<action name="Execute">
<command>~/bin/volume +5</command>
</action>
</keybind>
</keyboard>These raise or lower the volume by 5% when I press the volume keys, or by 1% when I hold shift and press the volume keys.
Here's the aforementioned ~/bin/volume:
1 #!/bin/sh
2
3 VOL=$(cat ~/.volume)
4
5 if [ "X$1" = "X+5" -o "X$1" = "X-5" -o "X$1" = "X+1" -o "X$1" = "X-1" ]; then
6 VOL=$(($VOL $1))
7 if [ $VOL -gt 100 ]; then
8 VOL=100
9 fi
10 if [ $VOL -lt 0 ]; then
11 VOL=0
12 fi
13 echo $VOL > ~/.volume
14 mixer vol=${VOL}%
15 else
16 echo "¿Que?"
17 exit 1
18 fi
19
20 echo "${VOL}%" | dzen2 -p 1 -x 910 -y 515 -w 120 -h 50 -fn -adobe-courier-*-r-*-*-34-*-*-*-*-*-*-* &
(If I were a good person I'd make sure ~/.volume existed before reading from it.)