Volume Buttons in Ubuntu


The volume buttons do not seem to do anything in the current 15.07 release. Nor does the power one.

How would I go about re-purposing these buttons to do something else?


The vol+ button is just a regular old gpio. Treat it as such and you can do whatever you like with it.

The power button is a special signal that feeds the PMIC. I think there are different ways to handle a power button “event”, but I think it will always be just that. Try HOLDING the power button down. I think it will eventually do something. Also watch the kmsg when you press it, if you’re lucky, it might say something to you. This signal is also attached to pin 4 of the low speed expansion header. See page 15 and 17 of the hardware manual. Note that the manual describes this button as being able to trigger wake/sleep states, but NOT power the board off. This is mainly because the board doesn’t actually have an “off” mode.

The vol- button is another that is tied into the PMIC. Odd thing about this one is that it is actually the RESET signal of the PMIC, which has been dual purposed to serve as vol- for presses lasting under 10 seconds. Holding it for 10+ seconds will cause the board to reset. This signal is also connected to pin 6 of the low speed expansion header.

So… you can do whatever you like with the vol+ button, but the other two are pretty much set in stone.


Thanks. I found vol+ is GPIO 107. It also looks like release 15.07 enabled sysfs interface for GPIO. It was not enabled in 15.06. Looks like I’ll go that route.

If others are interested here is what I did to make it available in sysfs:
sudo sh -c 'echo 107 > /sys/class/gpio/export'
Then you can read the value:
cat /sys/class/gpio/gpio107/value
If you want to set it to generate an interrupt:
sudo sh -c 'echo both > /sys/class/gpio/gpio107/edge'
That will trigger on press AND release. You can also use falling or rising instead of both.

You can then use poll to wait for the gpio to trigger.

I also took a look at gpio_keys driver but that seems like more of a hassle as I would need to create/install a new/updated device tree.