Skip to content

Instantly share code, notes, and snippets.

@seakintruth
Last active April 12, 2020 01:06
Show Gist options
  • Save seakintruth/7610cac5df7bfd1c9acc13794a01c59a to your computer and use it in GitHub Desktop.
Save seakintruth/7610cac5df7bfd1c9acc13794a01c59a to your computer and use it in GitHub Desktop.
Minecraft java linux script for AFK cobblestone generator --- Depends: xdotool
#!/usr/bin/env bash
echo "afkCobblestoneGenerator.sh::Run the most recent version with either of:"
echo "bash <(curl -s https://gist.githubusercontent.com/seakintruth/7610cac5df7bfd1c9acc13794a01c59a/raw)"
echo "bash <(wget -q -O - https://gist.githubusercontent.com/seakintruth/7610cac5df7bfd1c9acc13794a01c59a/raw)"
install_if_missing() {
# https://stackoverflow.com/a/22592801/1146659
local package_name=$1
if [ $(dpkg-query -W -f='${Status}' $package_name 2>/dev/null | grep -c "ok installed") -eq 0 ]; then
echo -n "Attempt to install package $package_name? [yes or no]: "
read yno
case $yno in
[yY] | [yY][Ee][Ss] )
printf "Missing $package_name. Setting up $package_name. \n"
sudo apt-get --yes install $package_name
;;
[nN] | [nN][oO] )
printf "Package $package_name is required \n"
exit 1;
;;
*)
printf "Invalid Input \n"
exit 1;
;;
esac
fi
}
install_if_missing xdotool
date1=$((`date +%s`));
i=0;
if [ -z "$*" ]; then
while [ $i == $i ]; do
xdotool click 1
echo -ne "Click $i of $1 $(date -u --date @$((`date +%s` - $date1)) +%H:%M:%S)\r";
sleep 0.02
let i=i+1
done
else
while [ $i -lt $1 ]; do
xdotool mousedown 1
echo -ne "Click for 25 second mouse down $i of $1 $(date -u --date @$((`date +%s` - $date1)) +%H:%M:%S)\r";
sleep 25
xdotool mouseup 1
sleep 0.02
xdotool click 4
sleep 0.02
let i=i+1
done
echo "$1 clicks in $(date -u --date @$((`date +%s` - $date1)) +%H:%M:%S)";
fi
@seakintruth
Copy link
Author

Added function install_if_missing for xdotool

@seakintruth
Copy link
Author

added comments on using wget instead of curl to run this bash from this gist

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