aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordanix <danix@danix.xyz>2026-06-11 10:03:15 +0200
committerdanix <danix@danix.xyz>2026-06-11 10:03:15 +0200
commit17920afbe5ab2c1ba3e81c9a38a0c924ccd9d1a0 (patch)
tree07e110fdc78eabdbd09788eb22905619a8219acb
parentba7ff8c7bc2f7b9316ad374b3f80b27829a553b7 (diff)
downloadwallp-17920afbe5ab2c1ba3e81c9a38a0c924ccd9d1a0.tar.gz
wallp-17920afbe5ab2c1ba3e81c9a38a0c924ccd9d1a0.zip
feat: set action (CLI + qarma selection)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
-rw-r--r--tests/wallp.bats23
-rw-r--r--wallp37
2 files changed, 60 insertions, 0 deletions
diff --git a/tests/wallp.bats b/tests/wallp.bats
index 27595c7..ad4b9bf 100644
--- a/tests/wallp.bats
+++ b/tests/wallp.bats
@@ -214,3 +214,26 @@ teardown() {
grep -q "swaybg -o DP-1 -i $HOME/dh.png" "$HOME/calls.log"
[ "$(cat "$HOME/.config/wallp/wall_h")" = "$HOME/dh.png" ]
}
+
+@test "set CLI partial sets only V" {
+ CONF_OUTPUT_H="DP-1"; CONF_OUTPUT_V="DP-3"; CONF_THEME="conf"
+ : > "$HOME/v.png"
+ do_set "" "V=$HOME/v.png"
+ grep -q "swaybg -o DP-3 -i $HOME/v.png" "$HOME/calls.log"
+ ! grep -q "swaybg -o DP-1" "$HOME/calls.log"
+}
+
+@test "set CLI persists flag theme" {
+ CONF_OUTPUT_H="DP-1"; CONF_OUTPUT_V="DP-3"; CONF_THEME="conf"
+ : > "$HOME/h.png"
+ do_set "flagtheme" "H=$HOME/h.png"
+ [ "$(cat "$HOME/.config/wallp/theme")" = "flagtheme" ]
+}
+
+@test "set with no args and no display errors" {
+ CONF_OUTPUT_H="DP-1"; CONF_OUTPUT_V="DP-3"; CONF_THEME="conf"
+ unset WAYLAND_DISPLAY
+ run do_set ""
+ [ "$status" -eq 1 ]
+ [[ "$output" == *"no display"* ]]
+}
diff --git a/wallp b/wallp
index 851860a..11bcf80 100644
--- a/wallp
+++ b/wallp
@@ -204,6 +204,43 @@ finalize() {
apply_theme "$1"
}
+# Interactive selection via qarma. Populates SET_H/SET_V. Isolated for testing.
+qarma_select() {
+ local choice file
+ choice="$(qarma --list --title="wallp" --text="Which screen?" \
+ --column="Screen" H V Both 2>/dev/null)" || return 1
+ case "$choice" in
+ H|Both)
+ file="$(qarma --file-selection --preview-images 500 --width 1300 --height 600 \
+ --title='Choose Horizontal Wallpaper')" && SET_H="$file" ;;
+ esac
+ case "$choice" in
+ V|Both)
+ file="$(qarma --file-selection --preview-images 500 --width 1300 --height 600 \
+ --title='Choose Vertical Wallpaper')" && SET_V="$file" ;;
+ esac
+ return 0
+}
+
+do_set() {
+ local flag_theme="$1"; shift
+ SET_H="" SET_V=""
+ if [ "$#" -gt 0 ]; then
+ parse_set_args "$@" || return 1
+ fi
+ if [ -z "$SET_H" ] && [ -z "$SET_V" ]; then
+ if [ -n "${WAYLAND_DISPLAY:-}" ]; then
+ qarma_select || return 1
+ else
+ echo "wallp: no display: pass H=<file> and/or V=<file>" >&2
+ return 1
+ fi
+ fi
+ [ -n "$SET_H" ] && { apply_output H "$SET_H" || true; }
+ [ -n "$SET_V" ] && { apply_output V "$SET_V" || true; }
+ finalize "$(resolve_theme "$flag_theme")"
+}
+
main() {
return 0
}