Skip to content

Instantly share code, notes, and snippets.

@ryanzabcik
Last active December 26, 2015 04:39
Show Gist options
  • Save ryanzabcik/7095256 to your computer and use it in GitHub Desktop.
Save ryanzabcik/7095256 to your computer and use it in GitHub Desktop.
This script runs cudaminer only if the main display :0 is off. Uses polling every ~10 seconds.
#!/bin/sh
export DISPLAY=:0
while true; do
# check to see if cudaminer is still alive, (possibly stopped)
if pgrep cudaminer; then
#if the monitor is on
if xset -q | grep -q 'Monitor is On'; then
pkill -STP cudaminer
else
pkill -CONT cudaminer
fi
else
nohup cudaminer # user-specific arguments
fi
# poll every 10 seconds
sleep 10
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment