summaryrefslogtreecommitdiffstats
path: root/.local/bin/setbg
diff options
context:
space:
mode:
authorLuke Smith <luke@lukesmith.xyz>2020-03-27 22:06:47 -0400
committerLuke Smith <luke@lukesmith.xyz>2020-03-27 22:06:47 -0400
commit04c117f85699f6d13a61ebf465e9171bddf3d9b7 (patch)
tree8979774fada1b4d070a6c441a7cfedd03d0d48ff /.local/bin/setbg
parent5cb4c6deeaecf349111d51166b98848f1fc1b584 (diff)
downloadeibhear-04c117f85699f6d13a61ebf465e9171bddf3d9b7.tar.gz
eibhear-04c117f85699f6d13a61ebf465e9171bddf3d9b7.tar.zst
eibhear-04c117f85699f6d13a61ebf465e9171bddf3d9b7.zip
setbg overhaul, dwm update mv'd to postrun
Yeah of course I'm going to totally rewrite a script right after I do a video on it. It uses links now to not waste space and env variables. Location moved to cache. Thanks to those who suggested some changes.
Diffstat (limited to '.local/bin/setbg')
-rwxr-xr-x.local/bin/setbg27
1 files changed, 12 insertions, 15 deletions
diff --git a/.local/bin/setbg b/.local/bin/setbg
index be4adfd..7b07e23 100755
--- a/.local/bin/setbg
+++ b/.local/bin/setbg
@@ -1,22 +1,19 @@
#!/bin/sh
-# In LARBS, ~/.config/wall.png is the location of the system wallpaper. This
-# script, if given an argument, moves it there. This script without an
-# argument sets ~/.config/wall.png as the wallpaper, which is required on login
-# if you don't want a black screen.
-#
-# You may also give a directory name to select a random image from that
-# directory as a wallpaper. Be careful that the directory only has images.
+# This script does the following:
+# Run by itself, set the wallpaper (at X start).
+# If given a file, set that as the new wallpaper.
+# If given a directory, choose random file in it.
+# If wal is installed, also generate a colorscheme.
-[ -f "$1" ] && cp "$1" ~/.config/wall.png && notify-send -i "$HOME/.config/wall.png" "Wallpaper changed."
+# Location of link to wallpaper link.
+bgloc="${XDG_CACHE_HOME:-$HOME/.cache/}/bg"
-[ -d "$1" ] && cp "$(find "$1" -name "*.jpg" -o -name "*.jpeg" -o -name "*.png" -type f | shuf -n 1)" ~/.config/wall.png && notify-send -i "$HOME/.config/wall.png" "Random Wallpaper chosen."
+[ -f "$1" ] && ln -sf "$(readlink -f "$1")" "$bgloc" && notify-send -i "$bgloc" "Changing wallpaper..."
+
+[ -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."
# If pywal is installed, use it.
-type wal >/dev/null 2>&1 && { wal -c
- wal -s -i ~/.config/wall.png -o ~/.config/wal/postrun
- xsetroot -name "fsignal:xrdb"
- killall dwmblocks
- setsid dwmblocks >/dev/null & } >/dev/null 2>&1
+wal -s -i "$(readlink -f "$bgloc")" -o "${XDG_CONFIG_HOME:-$HOME/.config}/wal/postrun" >/dev/null 2>&1
-xwallpaper --zoom ~/.config/wall.png
+xwallpaper --zoom "$bgloc"