aboutsummaryrefslogtreecommitdiff
path: root/bin/wallpaper-shuffle
diff options
context:
space:
mode:
authorAlec Goncharow <alec@goncharow.dev>2024-01-16 08:51:19 -0500
committerAlec Goncharow <alec@goncharow.dev>2024-01-16 08:51:19 -0500
commiteca35d6d822acba9bddec526ba95041880e20b67 (patch)
tree6979442096ff7c7dea64e947563067931a5db0ba /bin/wallpaper-shuffle
parent128eec2ebf2b206b072463cd4c792cdd93664ca2 (diff)
nushell churn is too much
bash gets it
Diffstat (limited to 'bin/wallpaper-shuffle')
-rwxr-xr-xbin/wallpaper-shuffle29
1 files changed, 17 insertions, 12 deletions
diff --git a/bin/wallpaper-shuffle b/bin/wallpaper-shuffle
index 820bfeb..9f55e0c 100755
--- a/bin/wallpaper-shuffle
+++ b/bin/wallpaper-shuffle
@@ -1,12 +1,17 @@
-#!/bin/nu
-let wallpapers_path = "~/wallpapers/low-poly"
-swaymsg -t get_outputs |
- rg name |
- str trim -a |
- split row "," |
- split column ":" |
- get column2 |
- str trim | str trim -c '"' |
- each {|output|
- swaymsg $"output ($output) bg `find ($wallpapers_path) -type f | shuf -n 1` fill"
- }
+#!/usr/bin/env bash
+
+set -o errexit
+set -o nounset
+set -o pipefail
+if [[ "${TRACE-0}" == "1" ]]; then
+ set -o xtrace
+fi
+
+OUTPUTS=$(swaymsg -t get_outputs | jq -r '.[] | .name')
+export WALLPAPERS="$HOME/wallpapers/low-poly"
+
+main() {
+ echo "$OUTPUTS" | xargs -I{} sh -c "swaymsg output {} bg $(find "$WALLPAPERS" -type f | shuf -n 1) fill"
+}
+
+main "$@"