Created
May 7, 2012 09:06
-
-
Save deanet/2626830 to your computer and use it in GitHub Desktop.
download something when screensaver is active with xprintidle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
while [ 1 ]; | |
do | |
if [ `xprintidle` -gt 300000 ]; | |
then | |
pid=`gnome-screensaver-command -q | head -n 1 | awk '{print $4}'` | |
if [ "$pid" == "inactive" ];then | |
gnome-screensaver-command -l; | |
count=$(ping -c4 mirror.switch.ch | grep 'received' | awk -F',' '{ print $1}' | awk '{ print $1}') | |
if [ "$count" -ne "0" ]; then | |
wget -b -c http://mirror.switch.ch/ftp/pool/2/mirror/backtrack/BT5R2-KDE-32.iso -O /media/sdb2/img/ISO/BT5R2-KDE-32.iso -o /media/sdb2/img/ISO/BT5R2-KDE-32.log; | |
fi | |
else | |
echo "gnome-screensaver is $pid"; | |
fi | |
fi | |
if [ `xprintidle` -lt 300000 ];then | |
pget=`pgrep wget` | |
if [ "$pget" != "" ];then | |
echo "kill $pget";pkill wget; | |
size=$(tail /media/sdb2/img/ISO/BT5R2-KDE-32.log -n 1 | awk '{print $1}') | |
DISPLAY=:0.0 /usr/bin/xmessage "size download BT5R2: $size " & | |
fi | |
fi | |
sleep 1 | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
while [ 1 ]; | |
do | |
if [ `xprintidle` -gt 300000 ]; | |
then | |
pid=`gnome-screensaver-command -q | head -n 1 | awk '{print $4}'` | |
if [ "$pid" == "inactive" ];then | |
gnome-screensaver-command -l; | |
fi | |
else | |
echo "gnome-screensaver was $pid"; | |
fi | |
fi | |
sleep 1 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment