[Freedom-misc] Re : Looking for an autoclicker

lcerf at dcc.ufmg.br lcerf at dcc.ufmg.br
Thu Mar 19 01:53:20 CET 2020


WAIT is always a number in chaosmonk's script: the quotes are useless (and so  
are the curly brackets).  I prefer "while true" to "while [ 1 ]" but that is  
merely a stylistic point.

More interestingly, $RANDOM (which is Bash specific) would make the script  
simpler:

#!/bin/bash
MIN=1
MAX=2
while true
do
     xdotool click 1
     sleep $(echo "$MIN + ($MAX - $MIN) * $RANDOM / 32767" | bc -l)
done

For a script that is portable across shells, one can read /dev/urandom with  
'od':

#!/bin/sh
MIN=1
MAX=2
while true
do
     xdotool click 1
     sleep $(echo "$MIN + ($MAX - $MIN) * $(od -A n -N 2 -d /dev/urandom) /  
65535" | bc -l)
done


More information about the Freedom-misc mailing list