aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordanix <danix@danix.xyz>2026-06-11 09:48:38 +0200
committerdanix <danix@danix.xyz>2026-06-11 09:48:38 +0200
commit0f52ddcc2712573687ded1698ba0ac9b26168e00 (patch)
treef75eef0bddd9c33c24646a468dc893691fc63a8a
parentc20cfb9423a48ca4ded7e6b7b3cd014a60499e33 (diff)
downloadwallp-0f52ddcc2712573687ded1698ba0ac9b26168e00.tar.gz
wallp-0f52ddcc2712573687ded1698ba0ac9b26168e00.zip
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 <noreply@anthropic.com>
-rw-r--r--tests/wallp.bats22
-rw-r--r--wallp25
2 files changed, 47 insertions, 0 deletions
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
}