Skip to content

Instantly share code, notes, and snippets.

@f-r00t
Created October 21, 2018 17:37
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save f-r00t/8b20e43ce0ddb176e2aef8808a60a84e to your computer and use it in GitHub Desktop.
Script that automatically starts mining cryptocurrency when you go AFK
# Set time in milliseconds to wait before turning on miner.
# Change the "5" to a value to set in minutes.
# Example 1: 1 minute
# IDLE_TIME=$((1*60*1000))
# Example 2: 500 milliseconds
# IDLE_TIME=$((500)) or IDLE_TIME=500
IDLE_TIME=$((5*60*1000))
# Get pid of miner software.
# Change <MINER EXECUTABLE> to the name of your miner's binary.
# Example: ethdcrminer64
pid=$(pidof <MINER EXECUTABLE>)
# Set this to the path to your script, or miner executable.
# Example 1:
# script="/home/user/mine.sh"
# Example 2:
# script="/home/user/ethdcrminer64"
script="/path/to/script.sh"
# Needs to be set for xprintidle to work correctly
export DISPLAY=:0
# Get time since last user interaction with computer
idle=$(xprintidle)
# Print current time (for logging purposes)
t=$(date)
printf "$t "
if [ "$pid" -a "$idle" -lt "$IDLE_TIME" ]
then
echo "Not idle anymore, and miner is running. Turning off mining.."
kill "$pid"
elif [ ! "$pid" -a "$idle" -ge "$IDLE_TIME" ]
then
echo "Miner not running, and user is idle. Turning on mining.."
sh "$script"
else
echo "Do nothing"
fi
@Nagaraju143123
Copy link

AFK

@Nagaraju143123
Copy link


@maraka21
Copy link

AFk

@f-r00t
Copy link
Author

f-r00t commented Nov 17, 2022

What?

@GloobB
Copy link

GloobB commented Nov 24, 2022

AFK

@BuddhasLady
Copy link

AFK

@KayGeeM21
Copy link

AFK

@StarScream6
Copy link

AFK

@Sneha821997
Copy link

AFK

@Nathankipkip
Copy link

AFK

@accessoryace
Copy link

AFK

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