fish: standardize config structure

This commit is contained in:
2026-01-04 19:11:27 +01:00
parent 4e2a3ed796
commit 2fc4d242dd
14 changed files with 18 additions and 35 deletions
@@ -0,0 +1,22 @@
if test -n "$XDG_CURRENT_DESKTOP"; and test "$XDG_CURRENT_DESKTOP" = "niri"
set -l env_config "$HOME/.config/niri/config/envs.kdl"
if test -f "$env_config"
while read -la line
# Remove comments
set line (string replace -r '//.*' '' -- "$line")
# Trim whitespace
set line (string trim -- "$line")
# Skip "environment" block lines
if test -z "$line"; or string match -q "environment*" -- "$line"; or test "$line" = "}"
continue
end
# Match lines like: VARIABLE "value" where VARIABLE is alphanumeric/underscore
set -l matches (string match -r '^([0-9A-Za-z_]+)\s+"(.*)"$' -- "$line")
# If have a matches, set the environment variable
if test (count $matches) -eq 3
set -xg $matches[2] $matches[3]
end
end < "$env_config"
end
end