Compare commits
2 Commits
9ed6f63962
...
049a469659
Author | SHA1 | Date | |
---|---|---|---|
049a469659 | |||
4d12f43a7f |
@ -5,6 +5,7 @@ picdir=`realpath $(dirname "${BASH_SOURCE[0]}")`
|
||||
del="30m"
|
||||
sud=0
|
||||
lockfile=/tmp/updateWallpaper.lock
|
||||
kill_running=0
|
||||
|
||||
for i in "$@"; do
|
||||
case $i in
|
||||
@ -20,12 +21,16 @@ case $i in
|
||||
tags="${i#*=}"
|
||||
shift
|
||||
;;
|
||||
-k|--kill*)
|
||||
kill_running=1
|
||||
;;
|
||||
-h|--help*)
|
||||
echo "usage: $0 <options>"
|
||||
echo "Options:"
|
||||
echo " -s --start-up-delay=del Set time between start and first image request."
|
||||
echo " -d --delay=del Set delay between image requests."
|
||||
echo " -t --tags=tags The actual search string. Special fields allowed."
|
||||
echo " -k --kill Kill a previously running instance of the script."
|
||||
echo "Notes:"
|
||||
echo " All times need to be formatted for the sleep command."
|
||||
exit 1
|
||||
@ -37,13 +42,20 @@ esac
|
||||
done
|
||||
|
||||
if [ -e "$lockfile" ]; then
|
||||
echo "Error: Lock file $lockfile exists!"
|
||||
echo " This most likely means another instance of the script is already running."
|
||||
echo " Kill it and potentially delete the lock file after that using:"
|
||||
echo " rm $lockfile"
|
||||
exit 2;
|
||||
kill -0 $(cat $lockfile)
|
||||
if [ $? -eq 0 ]; then
|
||||
if [ $kill_running -eq 0 ]; then
|
||||
echo "Error: Lock file $lockfile exists!"
|
||||
echo " This most likely means another instance of the script is already running."
|
||||
echo " Use -k to kill the running process."
|
||||
exit 2;
|
||||
else
|
||||
echo "Warning: Killing old process..."
|
||||
kill $(cat $lockfile)
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
touch "$lockfile"
|
||||
echo $$ > "$lockfile"
|
||||
|
||||
if [ "$sud" != "0" ]; then
|
||||
sleep "$sud";
|
||||
@ -58,6 +70,7 @@ while [ 0 ]; do
|
||||
url=`echo $json | jq -r '.[0].file_url'`
|
||||
ext=`echo $url | sed "s/.*\.//g"`
|
||||
|
||||
url="http:$url"
|
||||
local_url="$picdir/$id.$ext"
|
||||
|
||||
echo "Updating wallpaper to $id..."
|
||||
|
Loading…
Reference in New Issue
Block a user