Just a short script I wrote to disable my mouse to get me into better workflow habits - Programming On Unix

Users browsing this thread: 1 Guest(s)
Wildefyr
Long time nixers
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
Administrators
Quite useful. Thanks for the script.
bsdkeith
Long time nixers
Why didn't you just unplug it?! ;)
Wildefyr
Long time nixers
(05-05-2015, 07:58 AM)bsdkeith Wrote: Why didn't you just unplug it?! ;)

Too much effort (:
Webtm
Members
(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
Long time nixers
Well it means I have to get off my chair so most certainly yes. :p
S1cK94
Members
(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
Long time nixers
Agree, but he did say mouse. ;)
xero
Long time nixers
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
Long time nixers
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.)
xero
Long time nixers
(07-05-2015, 05:51 AM)bsdkeith Wrote: 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.)

that's it exactly for me. my touchpad is positioned in a way that this was very frequent. so i made the above script and bound it to MOD+M. so i just toggle it on when i need it, then toggle it back off again when i'm done.
Wildefyr
Long time nixers
Made the script use wmp (from wmutils) and it performs much better than using xdotool:

Code:
while :; do
    case $1 in
        -e|--enable)
            wmp 960 540
            xinput set-int-prop $(xinput | awk '/Mouse/ {printf "%s",$9}' | sed 's/id=//') "Device Enabled" 8 1
            break
            ;;
        -d|--disable)
            wmp $(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
Wildefyr
Long time nixers
Minor upgrade to make it not use xrandr and instead use the base 'root' window. Yay for wmutils!

Code:
#!/bin/sh

# File       : /home/wildefyr/.fyre/scripts/mouse
# Maintainer : Wildefyr | http://wildefyr.net
# Copyright  : Wildefyr | Licensed under the WTFPL license.

case $1 in
    -e|--enable)
        wmp 870 1040
        xinput set-int-prop $(xinput | awk '/Mouse/ {printf "%s",$9}' | sed 's/id=//') "Device Enabled" 8 1
        break
        ;;
    -d|--disable)
        ROOT=$(lsw -r); SW=$(wattr w $ROOT); SH=$(wattr h $ROOT); wmp $SW $SH
        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
Interesting, will have to try it later. I am guilty of sometimes using the arrows keys in vim.
bsdkeith
Long time nixers
(01-07-2015, 05:08 PM)October Wrote: Interesting, will have to try it later. I am guilty of sometimes using the arrows keys in vim.
Sacriledge! :)
Wildefyr
Long time nixers
Been thinking over mouse control recently more and used the remains of this script to help power my mouse control in fyre. Here's an example.