Is there any way?
How to script in /usr/lib/pm-utils/sleep.d
to check ${downspeed eth0}
, ${upspeed wlan0}
, ${upspeed eth0}
and ${downspeed wlan0}
and to set the system not to suspend while a download in progress but only turn screen off?
My OS is Ubuntu 15.04.
Best Answer
Inspired by @ByteCommanders second comment, the script below does what you describe: assuming the downloads folder is the directory you download into, it disables suspend during download, and subsequently waits for five minutes (arbitrary to set) before re- enabling suspend, to make sure the download is really finished.
You can set any other directory to be watched as download folder.
How it works
In a loop (once per 20 seconds), the script checks the size of the targeted folder with the command:
The script compares each check with the last one, to check for download activity (increase of size). If there is no activity for more then five minutes (but you can set any other "wait" time), the script assumes no download is going in, and "normal" suspend is (re-) enabled.
The other way around: if the script sees increasing size of the
~/Downloads
directory, it disables suspend, until no activity was detected for more then five minutes.Low on juice
The script's commands are extremely low on resources. Since the cycle runs only once per 20 seconds (as it is), The processor load is practically none.
The script
How to use
no_suspend.py
In the head section of the script, set the desired "normal" suspend time (since the script will re- enable suspend):
If you want, you can set other values:
Test- run the script with the command:
If all works fine, add it to your startup applications: Dash > Startup Applications > add the command: