From 0f52ddcc2712573687ded1698ba0ac9b26168e00 Mon Sep 17 00:00:00 2001 From: danix Date: Thu, 11 Jun 2026 09:48:38 +0200 Subject: feat: output mapping + state path helpers Add three helper functions for logical-to-physical output mapping and state file paths: output_for maps H|V to physical connectors, wall_file_for returns config paths, pid_file_for returns cache paths. Co-Authored-By: Claude Opus 4.8 --- tests/wallp.bats | 22 ++++++++++++++++++++++ wallp | 25 +++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/tests/wallp.bats b/tests/wallp.bats index 0ffed89..b5c9ff7 100644 --- a/tests/wallp.bats +++ b/tests/wallp.bats @@ -105,3 +105,25 @@ teardown() { persist_theme "abc" [ "$(cat "$HOME/.config/wallp/theme")" = "abc" ] } + +@test "output_for maps logical to physical" { + CONF_OUTPUT_H="DP-1"; CONF_OUTPUT_V="DP-3" + run output_for H + [ "$output" = "DP-1" ] + run output_for V + [ "$output" = "DP-3" ] +} + +@test "wall_file_for returns config paths" { + run wall_file_for H + [ "$output" = "$HOME/.config/wallp/wall_h" ] + run wall_file_for V + [ "$output" = "$HOME/.config/wallp/wall_v" ] +} + +@test "pid_file_for returns cache paths" { + run pid_file_for H + [ "$output" = "$HOME/.cache/wallp/H.pid" ] + run pid_file_for V + [ "$output" = "$HOME/.cache/wallp/V.pid" ] +} diff --git a/wallp b/wallp index 6f14341..0827fa4 100644 --- a/wallp +++ b/wallp @@ -95,6 +95,31 @@ resolve_theme() { printf '%s\n' "sexy-splurge" } +# Maps logical output (H|V) to physical connector name from config. +output_for() { + case "$1" in + H) printf '%s\n' "$CONF_OUTPUT_H" ;; + V) printf '%s\n' "$CONF_OUTPUT_V" ;; + *) echo "wallp: unknown logical output '$1'" >&2; return 1 ;; + esac +} + +# Returns path to saved wall state for logical output (H|V). +wall_file_for() { + case "$1" in + H) printf '%s\n' "$HOME/.config/wallp/wall_h" ;; + V) printf '%s\n' "$HOME/.config/wallp/wall_v" ;; + esac +} + +# Returns path to PID file for logical output (H|V). +pid_file_for() { + case "$1" in + H) printf '%s\n' "$HOME/.cache/wallp/H.pid" ;; + V) printf '%s\n' "$HOME/.cache/wallp/V.pid" ;; + esac +} + main() { return 0 } -- cgit v1.2.3