Guest User

Untitled

a guest
Oct 21st, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. # Set time in milliseconds to wait before turning on miner.
  2. # Change the "5" to a value to set in minutes.
  3.  
  4. # Example 1: 1 minute
  5. # IDLE_TIME=$((1*60*1000))
  6.  
  7. # Example 2: 500 milliseconds
  8. # IDLE_TIME=$((500)) or IDLE_TIME=500
  9.  
  10. IDLE_TIME=$((5*60*1000))
  11.  
  12.  
  13. # Get pid of miner software.
  14. # Change <MINER EXECUTABLE> to the name of your miner's binary.
  15. # Example: ethdcrminer64
  16.  
  17. pid=$(pidof <MINER EXECUTABLE>)
  18.  
  19. # Set this to the path to your script, or miner executable.
  20. # Example 1:
  21. # script="/home/user/mine.sh"
  22. # Example 2:
  23. # script="/home/user/ethdcrminer64"
  24. script="/path/to/script.sh"
  25.  
  26. # Needs to be set for xprintidle to work correctly
  27. export DISPLAY=:0
  28.  
  29. # Get time since last user interaction with computer
  30. idle=$(xprintidle)
  31.  
  32. # Print current time (for logging purposes)
  33. t=$(date)
  34. printf "$t "
  35.  
  36. if [ "$pid" -a "$idle" -lt "$IDLE_TIME" ]
  37. then
  38. echo "Not idle anymore, and miner is running. Turning off mining.."
  39. kill "$pid"
  40.  
  41. elif [ ! "$pid" -a "$idle" -ge "$IDLE_TIME" ]
  42. then
  43. echo "Miner not running, and user is idle. Turning on mining.."
  44. sh "$script"
  45. else
  46. echo "Do nothing"
  47. fi
Add Comment
Please, Sign In to add comment