Last active
May 10, 2019 21:32
-
-
Save TonyWhite/dbd39384fd762f5d962805e0bf4f80eb to your computer and use it in GitHub Desktop.
Auto-click when Caps Lock ON
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
| # Version 2, December 2004 | |
| # | |
| # Copyright (C) 2004 Sam Hocevar <sam@hocevar.net> | |
| # | |
| # Everyone is permitted to copy and distribute verbatim or modified | |
| # copies of this license document, and changing it is allowed as long | |
| # as the name is changed. | |
| # | |
| # DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
| # TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION | |
| # | |
| # 0. You just DO WHAT THE FUCK YOU WANT TO. | |
| # DEPENDENCY: xautomation x11-xserver-utils zenity | |
| # FIELD OF APPLICATION: whatever you want | |
| function main() | |
| { | |
| zenity --title="Autoclick" --info --text="CAPS-LOCK to start autoclick!" --ellipsize | |
| set_capslock_off | |
| (while true | |
| do | |
| if [[ `check_capslock` == "ON" ]]; then | |
| xte 'mousedown 1' 'mouseup 1' | |
| echo "# Autoclick ON" | |
| else | |
| echo "# Autoclick OFF" | |
| fi | |
| done) | zenity --title Autoclick --progress --pulsate | |
| } | |
| # Return Caps Lock status: ON or OFF | |
| function check_capslock | |
| { | |
| # Read caps lock status | |
| STATUS=`xset -q | grep "Caps Lock:"` | |
| # Delete trail spaces | |
| STATUS=`echo ${STATUS}` | |
| # Check Caps Lock status | |
| if [[ "$STATUS" == *"Caps Lock: on"* ]] | |
| then | |
| echo "ON" | |
| else | |
| echo "OFF" | |
| fi | |
| } | |
| # Turn Caps Lock OFF | |
| function set_capslock_off() | |
| { | |
| if [[ `check_capslock` == "ON" ]] | |
| then | |
| echo -e "Caps Lock is ON. Turning it OFF...\c" | |
| xte "key Caps_Lock" | |
| echo "OK" | |
| fi | |
| } | |
| main |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Zen Autoclick
Simple and lightweight utility to save the wrist from the carpal tunnel.