summaryrefslogtreecommitdiff
path: root/.local/bin/setbg
diff options
context:
space:
mode:
Diffstat (limited to '.local/bin/setbg')
-rwxr-xr-x.local/bin/setbg28
1 files changed, 28 insertions, 0 deletions
diff --git a/.local/bin/setbg b/.local/bin/setbg
new file mode 100755
index 0000000..6608d7a
--- /dev/null
+++ b/.local/bin/setbg
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+# Make sure given file is an image
+[ -z "$1" ] && exit
+[ ! -f "$1" ] && exit
+[ -z "$(file "$1" | grep -o 'image data')" ] && exit
+
+displays=$(xrandr | grep " connected" | sed 's/^\([a-Z,0-9,-]*\).*/\1/')
+
+# selected="$(echo "$displays" | dmenu -w "$(xdotool getactivewindow)" -p "󰍹 Select monitor:")"
+
+# Same as above but use dmenu only if there are multiple displays
+if [ "$(echo "$displays" | wc -l)" -gt 1 ]; then
+ selected="$(echo "$displays" | dmenu -w "$(xdotool getactivewindow)" -p "󰍹 Select monitor:")"
+else
+ selected="$displays"
+fi
+
+[ -z "$selected" ] && exit
+
+src="$1"
+extension="${1##*.}"
+dest="$XDG_CONFIG_HOME/wallpapers/${selected}.$extension"
+
+ln -sf "$src" "$dest" && notify-send -a "Wallpaper" -i "$src" "Changed monitor: $selected"
+
+# Re-render all wallpapers
+makewall