I want to run some servers and whatnot on my machine but I don't want it to interfere with what I'm doing... Gaming, research, writing a paper, etc. My thought was to have a script run when the system idles as in when the screen is locked or no users are logged in. The stuff I would be running during idle would be things like a plex server, bitcoin miner or bittorrent. I can start and stop all of these things with something like "service plexd start/stop". Any ideas on how I can initiate these commands when the system goes into and comes out of idle?
Asked
Active
Viewed 1,516 times
1 Answers
2
I've created a new script to run a command upon locking and unlocking the screen because the others on the web don't work on 14.04. I set it as a startup program and added it to my sudoers file so that it can manage services on its own.
#!/bin/bash
while sleep 30s ; do
state=$(gnome-screensaver-command --query | grep -o "\w*active\w*" >> /dev/null)
if [[ $state == active ]]
then
./start.sh
else
./stop.sh
fi
done
leszakk
- 562
- 2
- 4
- 20