summaryrefslogtreecommitdiffstats
path: root/.local/bin/setbg
diff options
context:
space:
mode:
authorLuke Smith <luke@lukesmith.xyz>2020-03-15 18:10:59 -0400
committerLuke Smith <luke@lukesmith.xyz>2020-03-15 18:10:59 -0400
commitdb46b82f7f0fe7d8bb76246e1e4b9947f4187012 (patch)
tree428735334465e53904cf9cdcca95a25568a129e6 /.local/bin/setbg
parenta2e0d2441b56886049892481178a119948fb7866 (diff)
downloadeibhear-db46b82f7f0fe7d8bb76246e1e4b9947f4187012.tar.gz
eibhear-db46b82f7f0fe7d8bb76246e1e4b9947f4187012.tar.zst
eibhear-db46b82f7f0fe7d8bb76246e1e4b9947f4187012.zip
setbg can take directory arg for random
Diffstat (limited to '.local/bin/setbg')
-rwxr-xr-x.local/bin/setbg7
1 files changed, 6 insertions, 1 deletions
diff --git a/.local/bin/setbg b/.local/bin/setbg
index 87096a6..ea5bc14 100755
--- a/.local/bin/setbg
+++ b/.local/bin/setbg
@@ -4,8 +4,13 @@
# 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.
-[ ! -z "$1" ] && cp "$1" ~/.config/wall.png && notify-send -i "$HOME/.config/wall.png" "Wallpaper changed."
+[ -f "$1" ] && cp "$1" ~/.config/wall.png && notify-send -i "$HOME/.config/wall.png" "Wallpaper changed."
+
+[ -d "$1" ] && mv "$(find "$1" -type f | shuf -n 1)" ~/.config/wall.png && notify-send -i "$HOME/.config/wall.png" "Random Wallpaper chosen."
# If pywal is installed, use it.
type wal >/dev/null 2>&1 && { wal -c ;