setbg 343 B

123456789101112
  1. #!/bin/sh
  2. bgloc="${XDG_DATA_HOME:-$HOME/.local/share/}/bg.png"
  3. trueloc="$(readlink -f "$1")" &&
  4. case "$(file --mime-type -b "$trueloc")" in
  5. image/* ) ln -sf "$(readlink -f "$1")" "$bgloc" ;;
  6. inode/directory ) ln -sf "$(find "$trueloc" -iregex '.*.\(jpg\|jpeg\|png\|gif\)' -type f | shuf -n 1)" "$bgloc" ;;
  7. esac
  8. xwallpaper --zoom "$bgloc"