dotties

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

backweb (938B)


      1 #!/bin/sh
      2 
      3 # Backweb: Set the BACKground image from a WEBcam!
      4 
      5 # Defaults before reading from the config file.
      6 url=""
      7 name=""
      8 blurlvl="2"
      9 convert_opt=""
     10 minutes="60"
     11 
     12 config_file="$XDG_CONFIG_HOME/backweb.conf"
     13 dir="$XDG_DATA_HOME/backweb"
     14 file_name="$dir/img-$name"
     15 
     16 [ -f "$config_file" ] && . "$config_file" || [ -f "$HOME/.config/backweb.conf" ] && . "$HOME/.config/backweb.conf" || exit
     17 [ ! -d "$dir" ] && mkdir -p "$dir"
     18 
     19 convert_opt="$convert_opt -resize x768 -blur x$blurlvl -paint $blurlvl"
     20 
     21 update() {
     22 	[ -f "$file_name.png" ] && feh --bg-fill "$file_name.png"
     23 	[ "$INTERNET_IS_PRECIOUS" = "true" ] && [ "$1" != "force" ] && exit
     24 	curl -s "$url" > "$file_name.jpg"
     25 	[ "$?" = 0 ] && convert "$file_name.jpg" $convert_opt "$file_name.png" && feh --bg-fill "$file_name.png"
     26 	cp "$file_name.png" "$dir/img.png"
     27 }
     28 
     29 while :; do
     30 	[ "$1" = "force" ] && update force && break
     31 	update
     32 	[ "$1" = "once" ] && break
     33 	sleep "${minutes}m"
     34 done