Skip to content

Instantly share code, notes, and snippets.

@bwindels
Created August 1, 2018 08:37
Show Gist options
  • Save bwindels/e7512e037a49f11914567df5277b9017 to your computer and use it in GitHub Desktop.
Save bwindels/e7512e037a49f11914567df5277b9017 to your computer and use it in GitHub Desktop.
Insert 10 counted messages anywhere
//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);
#!/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
@bwindels
Copy link
Author

bwindels commented Aug 1, 2018

Linux only and you'll need nodejs installed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment