Created
August 1, 2018 08:37
-
-
Save bwindels/e7512e037a49f11914567df5277b9017 to your computer and use it in GitHub Desktop.
Insert 10 counted messages anywhere
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
| //use as: sh -c 'sleep 0.3; xdotool type "$(node counted_msg.js)"; xdotool key KP_Enter' | |
| const fs = require('fs'); | |
| const counterPath = '/home/bwindels/Temp/counter'; | |
| function getCounter() { | |
| const str = fs.readFileSync(counterPath, 'utf8'); | |
| return parseInt(str, 10); | |
| } | |
| function setCounter(n) { | |
| fs.writeFileSync(counterPath, n.toString(), {flag: 'w'}); | |
| } | |
| if (!fs.existsSync(counterPath)) { | |
| setCounter(0); | |
| } | |
| let n = getCounter(); | |
| n = n + 1; | |
| setCounter(n); | |
| process.stdout.write('event number '+n); |
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/sh | |
| # Insert global shortcut (e.g. Ctrl + Super + M) in gnome keyboard settings with command: | |
| # sh -c <location>/counted_msg.sh | |
| LOCATION=$(readlink -f $(dirname $0)) | |
| node counted_msg.js | xclip -selection clipboardse | |
| sleep 0.3 | |
| for i in {1..10} | |
| do | |
| # | |
| xdotool type "$(node $LOCATION/counted_msg.js)" | |
| xdotool key --delay 300 KP_Enter | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Linux only and you'll need nodejs installed