diff options
| -rw-r--r-- | tests/wallp.bats | 23 | ||||
| -rw-r--r-- | wallp | 37 |
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"* ]] +} @@ -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 } |
