Cheap and simple solution to power off your Linux box when usb mouse button pressed.
I have PogoPlug V03.
It is a small NAS but has no Power on/off button.
I have some mouse from my garage. (USB kind...) :)
My NAS can handle usb mouse buttons.
What if I use Mouse Left Button for shutdown the system?
This is a cheap and simple solution to have power button.
I found a Python program which is checking if left mouse button pressed.
If yes then power off.
This is for embeded linux systems, without onboard buttons or keyboard, but you wants to shutdown with proper way.
My NAS has Debian with kernel 3.17.
USB mouse recognised by kernel and device is exist here:
/dev/input/mouse
When this program running and left mosue button pressed program will issue "poweroff" linux command.
Prerequsites:
1. Install Python.
apt-get install python
cd /usr/local/bin wget --no-check-certificate https://raw.githubusercontent.com/robertio/Is_mouse_button_pressed/master/mouse_pressed.py wget --no-check-certificate https://raw.githubusercontent.com/robertio/Is_mouse_button_pressed/master/midmousebutt.sh chmod 755 mouse_pressed.py midmousebutt.sh
3. Download shell script allow to run when system statup.
cd /etc/init.d wget --no-check-certificate https://raw.githubusercontent.com/robertio/Is_mouse_button_pressed/master/mouse_pressed.sh chmod 755 mouse_pressed.sh update-rc.d mouse_pressed.sh defaults4. Start first time manually
If LEFT mouse button pressed - shut down system/etc/init.d/mouse_pressed.sh status # first time will report error - 'casue not running. /etc/init.d/mouse_pressed.sh start # or reboot
If RIGHT mouse button pressed - Reboots system
(source of python mouse handling : http://stackoverflow.com/questions/4855823/get-mouse-deltas-using-python-in-linux )