dotfiles

My dotfiles: zsh, lf, sxiv, i3, ranger, mpd and more
Log | Files | Refs | Submodules | README | LICENSE

setbg (823B)


      1 #!/bin/sh
      2 
      3 # This script does the following:
      4 #	Run by itself, set the wallpaper (at X start).
      5 #	If given a file, set that as the new wallpaper.
      6 #	If given a directory, choose random file in it.
      7 #	If wal is installed, also generates a colorscheme.
      8 
      9 # Location of link to wallpaper link.
     10 bgloc="${XDG_DATA_HOME:-$HOME/.local/share/}/bg"
     11 
     12 [ -f "$1" ] && ln -sf "$(readlink -f "$1")" "$bgloc" && notify-send -i "$bgloc" "Changing wallpaper..."
     13 
     14 [ -d "$1" ] && ln -sf "$(find "$(readlink -f "$1")" -iregex '.*.\(jpg\|jpeg\|png\|gif\)' -type f | shuf -n 1)" "$bgloc" && notify-send -i "$bgloc" "Random Wallpaper chosen."
     15 
     16 # If pywal is installed, use it.
     17 wal -i "$(readlink -f "$bgloc")" -o "${XDG_CONFIG_HOME:-$HOME/.config}/wal/postrun" >/dev/null 2>&1
     18 
     19 pidof dwm >/dev/null && xdotool key super+F12
     20 xwallpaper --zoom "$bgloc"