/Is_mouse_button_pressed

Python program to check if left mouse button pressed, if yes then reboot.

Primary LanguageShell

Is_mouse_button_pressed?

Cheap and simple solution to power off your linux box when usb left mouse button pressed.

http://mousebuttonshutdown.blogspot.hu/2015/02/cheap-and-simple-solution-to-power-off.html

Python program to check 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. Cheap and simple solution: use an usb mouse button to power off your linux box.

Connect a mouse to your linux box. If /dev/input/mouse is exist then run this program and when left mosue button pressed program will issue "poweroff" linux command.

Prerequsites:

1. Install Python.

apt-get install python

2. Download the python program.

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 defaults

4. Start first time manually

/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 LEFT mouse button pressed - shut down system

If RIGHT mouse button pressed - Reboots system

If MIDDLE mouse button pressed - run a midmousebutt.sh script in /usr/local/bin directory (actually plays music)