nixers
Just a short script I wrote to disable my mouse to get me into better workflow habits - Printable Version
+- nixers (https://nixers.net)
+-- Forum: Development & Graphics (https://nixers.net/Forum-Development-Graphics)
+--- Forum: Programming On Unix (https://nixers.net/Forum-Programming-On-Unix)
+--- Thread: Just a short script I wrote to disable my mouse to get me into better workflow habits (/Thread-Just-a-short-script-I-wrote-to-disable-my-mouse-to-get-me-into-better-workflow-habits)


Just a short script I wrote to disable my mouse to get me into better workflow habits - Wildefyr - 04-05-2015

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



RE: Just a short script I wrote to disable my mouse to get me into better workflow habits - venam - 05-05-2015

Quite useful. Thanks for the script.


RE: Just a short script I wrote to disable my mouse to get me into better workflow habits - bsdkeith - 05-05-2015

Why didn't you just unplug it?! ;)


RE: Just a short script I wrote to disable my mouse to get me into better workflow habits - Wildefyr - 05-05-2015

(05-05-2015, 07:58 AM)bsdkeith Wrote: Why didn't you just unplug it?! ;)

Too much effort (:


RE: Just a short script I wrote to disable my mouse to get me into better workflow habits - Webtm - 05-05-2015

(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


RE: Just a short script I wrote to disable my mouse to get me into better workflow habits - Wildefyr - 05-05-2015

Well it means I have to get off my chair so most certainly yes. :p


RE: Just a short script I wrote to disable my mouse to get me into better workflow habits - S1cK94 - 06-05-2015

(05-05-2015, 07:58 AM)bsdkeith Wrote: Why didn't you just unplug it?! ;)
Also, it's quite hard to unplug a touchpad


RE: Just a short script I wrote to disable my mouse to get me into better workflow habits - bsdkeith - 06-05-2015

Agree, but he did say mouse. ;)


RE: Just a short script I wrote to disable my mouse to get me into better workflow habits - xero - 06-05-2015

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



RE: Just a short script I wrote to disable my mouse to get me into better workflow habits - bsdkeith - 07-05-2015

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.)


RE: Just a short script I wrote to disable my mouse to get me into better workflow habits - xero - 07-05-2015

(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.


RE: Just a short script I wrote to disable my mouse to get me into better workflow habits - Wildefyr - 11-05-2015

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



RE: Just a short script I wrote to disable my mouse to get me into better workflow habits - Wildefyr - 30-06-2015

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



RE: Just a short script I wrote to disable my mouse to get me into better workflow habits - October - 01-07-2015

Interesting, will have to try it later. I am guilty of sometimes using the arrows keys in vim.


RE: Just a short script I wrote to disable my mouse to get me into better workflow habits - bsdkeith - 02-07-2015

(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! :)


RE: Just a short script I wrote to disable my mouse to get me into better workflow habits - Wildefyr - 20-01-2016

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.