From a827eee040ef62c3939c0b6952cd4ddd1a28702c Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Sun, 15 Dec 2024 12:06:40 +0100 Subject: refactor: define scripts in files --- nixos/parts/graphical.nix | 11 ++--------- nixos/parts/scripts/reset-bg | 2 ++ nixos/parts/scripts/set-bg | 3 +++ 3 files changed, 7 insertions(+), 9 deletions(-) create mode 100644 nixos/parts/scripts/reset-bg create mode 100644 nixos/parts/scripts/set-bg diff --git a/nixos/parts/graphical.nix b/nixos/parts/graphical.nix index 8c340fc..80a5a8a 100644 --- a/nixos/parts/graphical.nix +++ b/nixos/parts/graphical.nix @@ -20,15 +20,8 @@ # When I ssh into a server my terminal changes to a host-specific background color via # a LocalCommand configured in ~/.ssh/config and a ZSH function to reset the color on exit. - (writeShellScriptBin "set-bg" '' - #!/usr/bin/env bash - rgb_with_slashes=$(echo "$1" | sed -r 's,(..)(..),\1/\2/,') - echo -en "\033]11;rgb:$rgb_with_slashes\007" - '') - (writeShellScriptBin "reset-bg" '' - #!/usr/bin/env bash - echo -en "\033]111\007" - '') + (writeShellScriptBin "set-bg" (builtins.readFile ./scripts/set-bg)) + (writeShellScriptBin "reset-bg" (builtins.readFile ./scripts/reset-bg)) # graphical tools imv diff --git a/nixos/parts/scripts/reset-bg b/nixos/parts/scripts/reset-bg new file mode 100644 index 0000000..5aa20f6 --- /dev/null +++ b/nixos/parts/scripts/reset-bg @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +echo -en "\033]111\007" diff --git a/nixos/parts/scripts/set-bg b/nixos/parts/scripts/set-bg new file mode 100644 index 0000000..e78afdc --- /dev/null +++ b/nixos/parts/scripts/set-bg @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +rgb_with_slashes=$(echo "$1" | sed -r 's,(..)(..),\1/\2/,') +echo -en "\033]11;rgb:$rgb_with_slashes\007" -- cgit v1.2.3