dots

Personal dotfiles
git clone git://git.gormless.xyz/dots.git
Log | Files | Refs

wal (826B)


      1 
      2 #!/bin/sh
      3 
      4 # This script does the following:
      5 #	Run by itself, set the wallpaper (at X start).
      6 #	If given a file, set that as the new wallpaper.
      7 #	If given a directory, choose random file in it.
      8 #	If wal is installed, also generates a colorscheme.
      9 
     10 # Location of link to wallpaper link.
     11 bgloc="${XDG_DATA_HOME:-$HOME/.local/share/}/bg"
     12 
     13 trueloc="$(readlink -f "$1")" &&
     14 case "$(file --mime-type -b "$trueloc")" in
     15 	image/* ) ln -sf "$(readlink -f "$1")" "$bgloc" && notify-send -i "$bgloc" "Changing wallpaper..." ;;
     16 	application/x-not-regular-file ) ln -sf "$(find "$trueloc" -name *.jpg -o -name *.jpeg -o -name '*.png' -o -name '*.gif' -type f | sort -R | head -n 1)" "$bgloc" && notify-send -i "$bgloc" "Random Wallpaper chosen." ;;
     17 	*) notify-send "Error" "Not a valid image." ; exit 1;;
     18 esac
     19 
     20 xwallpaper --zoom "$bgloc"