Just a short script I wrote to disable my mouse to get me into better workflow habits - General Shell Scripting
Wildefyr
Got mad at myself for constantly using the mouse for certain tasks when I can just use the keyboard for it. Wrote this little script to find my mouse and disable me completely from using it. Touched it up a little after to make it auto detect the mouse device and the screen resolution:

Code:
#!/bin/bash

while :; do
    case $1 in
        -e|--enable)
            xinput set-int-prop $(xinput | awk '/Mouse/ {printf "%s",$9}' | sed 's/id=//') "Device Enabled" 8 1
            break
            ;;
        -d|--disable)
            xdotool mousemove $(xrandr | awk '/Screen 0/ {printf "%s",$8 " " $10}' | sed 's/,$//')
            xinput set-int-prop $(xinput | awk '/Mouse/ {printf "%s",$9}' | sed 's/id=//') "Device Enabled" 8 0
            break
            ;;
        *)
            echo "Usage: ./mouse [option]:

-e | --enable: Enable Mouse
-d | --disable: Disable Mouse"
            break
    esac
done
venam
Quite useful. Thanks for the script.
bsdkeith
Why didn't you just unplug it?! ;)
Wildefyr
(05-05-2015, 07:58 AM)bsdkeith Wrote: Why didn't you just unplug it?! ;)

Too much effort (:
Webtm
(05-05-2015, 11:41 AM)Wildefyr Wrote:
(05-05-2015, 07:58 AM)bsdkeith Wrote: Why didn't you just unplug it?! ;)

Too much effort (:
More effort than the amount of finger movements to write the script? :p
Wildefyr
Well it means I have to get off my chair so most certainly yes. :p
S1cK94
(05-05-2015, 07:58 AM)bsdkeith Wrote: Why didn't you just unplug it?! ;)
Also, it's quite hard to unplug a touchpad
bsdkeith
Agree, but he did say mouse. ;)
xero
here's my toggle touch pad script:

Code:
#!/bin/sh
#
# enable/disable touchpad
# find your touchpad name:
# egrep -i 'synap|alps|etps' /proc/bus/input/devices
PAD='SynPS/2 Synaptics TouchPad'
A=`xinput list-props "$PAD" | sed -n -e 's/.*Device Enabled ([0-9][0-9]*):\t\(.*\)/\1/p' `
if [ $A -eq 1 ]; then
xinput set-int-prop "$PAD" "Device Enabled" 8 0
notify-send -t 5000 \
'   touchpad
░░▒▒▓▓██▓▓▒▒░░' \
'   disabled'
else
xinput set-int-prop "$PAD" "Device Enabled" 8 1
notify-send -t 5000 \
'   touchpad
░░▒▒▓▓██▓▓▒▒░░' \
'   enabled'
fi
bsdkeith
Now that could be handy when you don't want an accidental brushing of the touchpad to interupt your keyboarding on a laptop. (Thanks for posting.)




Members  |  Stats  |  Night Mode