From b81598ccd93ed2583ce6e9366184992b6f41a177 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 3 Jan 2023 16:58:37 +0100 Subject: tv alacritty: mkdir and cp only when needed --- tv/5pkgs/simple/alacritty-tv.nix | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'tv/5pkgs/simple/alacritty-tv.nix') diff --git a/tv/5pkgs/simple/alacritty-tv.nix b/tv/5pkgs/simple/alacritty-tv.nix index d80c46cb..fd4dec9e 100644 --- a/tv/5pkgs/simple/alacritty-tv.nix +++ b/tv/5pkgs/simple/alacritty-tv.nix @@ -51,6 +51,20 @@ let scrolling.multiplier = 8; }; config-file = pkgs.writeJSON "alacritty-tv.json" config; + profile = pkgs.writeText "alacritty-tv.profile" /* sh */ '' + # Use home so Alacritty can find the configuration without arguments. + # HOME will be reset once in Alacritty. + HOME=$TMPDIR/Alacritty + export HOME + + # Install stored configuration if it has changed. + # This allows for both declarative updates and runtime modifications. + ${pkgs.coreutils}/bin/mkdir -p "$HOME" + if test "$(${pkgs.coreutils}/bin/cat "$HOME"/ref)" != ${config-file}; then + echo ${config-file} > "$HOME"/ref + ${pkgs.coreutils}/bin/cp ${config-file} "$HOME"/.alacritty.yml + fi + ''; in pkgs.symlinkJoin { @@ -62,27 +76,16 @@ pkgs.symlinkJoin { set -efu - # Use home so Alacritty can find the configuration without arguments. - # HOME will be reset once in Alacritty. - HOME=$TMPDIR/Alacritty - export HOME - - # Install stored configuration if it has changed. - # This allows for both declarative updates and runtime modifications. - ${pkgs.coreutils}/bin/mkdir -p "$HOME" - if test "$(${pkgs.coreutils}/bin/cat "$HOME"/ref)" != ${config-file}; then - echo ${config-file} > "$HOME"/ref - ${pkgs.coreutils}/bin/cp ${config-file} "$HOME"/.alacritty.yml - fi - case ''${1-} in --singleton) shift if ! ${pkgs.alacritty}/bin/alacritty msg create-window "$@"; then + . ${profile} ${pkgs.alacritty}/bin/alacritty "$@" & fi ;; *) + . ${profile} exec ${pkgs.alacritty}/bin/alacritty "$@" ;; esac -- cgit v1.2.3 From 48f91cbeb1b6bfd751cc7ed26ddee2fcf97a4f99 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 11 Jan 2023 17:14:19 +0100 Subject: tv alacritty: add support for multiple profiles --- tv/5pkgs/simple/alacritty-tv.nix | 46 +++++++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 8 deletions(-) (limited to 'tv/5pkgs/simple/alacritty-tv.nix') diff --git a/tv/5pkgs/simple/alacritty-tv.nix b/tv/5pkgs/simple/alacritty-tv.nix index fd4dec9e..f66bcdc0 100644 --- a/tv/5pkgs/simple/alacritty-tv.nix +++ b/tv/5pkgs/simple/alacritty-tv.nix @@ -6,7 +6,7 @@ let program = "${pkgs.font-size-alacritty}/bin/font-size-alacritty"; args = [arg]; }; - config = { + configs.default = { bell.animation = "EaseOut"; bell.duration = 50; bell.color = "#ff00ff"; @@ -50,16 +50,31 @@ let ]; scrolling.multiplier = 8; }; - config-file = pkgs.writeJSON "alacritty-tv.json" config; - profile = pkgs.writeText "alacritty-tv.profile" /* sh */ '' + writeProfile = name: config: let + config-file = + assert lib.types.filename.check name; + pkgs.writeJSON "alacritty-tv-${name}.json" config; + in pkgs.writeText "alacritty-tv-${name}.profile" /* sh */ '' # Use home so Alacritty can find the configuration without arguments. # HOME will be reset once in Alacritty. - HOME=$TMPDIR/Alacritty + HOME=$TMPDIR/Alacritty-${name} export HOME + # Tell Alacritty via XDG_RUNTIME_DIR where to create sockets. + # XDG_RUNTIME_DIR needs to be reset manually. + export ALACRITTY_XDG_RUNTIME_DIR="$XDG_RUNTIME_DIR" + export BASH_EXTRA_INIT=${pkgs.writeDash "alacritty-tv.cleanup.sh" '' + XDG_RUNTIME_DIR=$ALACRITTY_XDG_RUNTIME_DIR + unset ALACRITTY_XDG_RUNTIME_DIR + unset BASH_EXTRA_INIT + ''} + export XDG_RUNTIME_DIR="$HOME" + # Install stored configuration if it has changed. # This allows for both declarative updates and runtime modifications. - ${pkgs.coreutils}/bin/mkdir -p "$HOME" + # rust-xdg requires XDG_RUNTIME_DIR to be secure: + # https://docs.rs/xdg/2.4.1/src/xdg/lib.rs.html#311 + ${pkgs.coreutils}/bin/mkdir -m 0700 -p "$HOME" if test "$(${pkgs.coreutils}/bin/cat "$HOME"/ref)" != ${config-file}; then echo ${config-file} > "$HOME"/ref ${pkgs.coreutils}/bin/cp ${config-file} "$HOME"/.alacritty.yml @@ -72,20 +87,35 @@ pkgs.symlinkJoin { paths = [ (pkgs.writeDashBin "alacritty" '' # usage: - # alacritty [--singleton] [ARGS...] + # alacritty [--profile=PROFILE] [--singleton] [ARGS...] + # where + # PROFILE one of ${lib.toJSON (lib.attrNames configs)} set -efu + case ''${1-} in + ${lib.concatMapStringsSep "\n" (name: /* sh */ '' + --${lib.shell.escape name}|--profile=${lib.shell.escape name}) + shift + profile=${writeProfile name configs.${name}} + ;; + '') (lib.attrNames configs)} + *) + profile=${writeProfile "default" configs.default} + ;; + esac + + case ''${1-} in --singleton) shift if ! ${pkgs.alacritty}/bin/alacritty msg create-window "$@"; then - . ${profile} + . "$profile" ${pkgs.alacritty}/bin/alacritty "$@" & fi ;; *) - . ${profile} + . "$profile" exec ${pkgs.alacritty}/bin/alacritty "$@" ;; esac -- cgit v1.2.3 From a7a0dc6982f5399598ce4261a03fb1355620c1d2 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 11 Jan 2023 17:16:32 +0100 Subject: tv alacritty: add root profile --- tv/5pkgs/simple/alacritty-tv.nix | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'tv/5pkgs/simple/alacritty-tv.nix') diff --git a/tv/5pkgs/simple/alacritty-tv.nix b/tv/5pkgs/simple/alacritty-tv.nix index f66bcdc0..bca779df 100644 --- a/tv/5pkgs/simple/alacritty-tv.nix +++ b/tv/5pkgs/simple/alacritty-tv.nix @@ -50,6 +50,11 @@ let ]; scrolling.multiplier = 8; }; + configs.root = lib.recursiveUpdate configs.default { + colors.primary.background = "#230000"; + colors.primary.foreground = "#e0c0c0"; + colors.normal.black = "#800000"; + }; writeProfile = name: config: let config-file = assert lib.types.filename.check name; -- cgit v1.2.3 From 9c4a8aa82bea9407f3ce1b140e20cf8a34c93c30 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 11 Jan 2023 17:23:21 +0100 Subject: tv alacritty: add fzmenu profile --- tv/5pkgs/simple/alacritty-tv.nix | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'tv/5pkgs/simple/alacritty-tv.nix') diff --git a/tv/5pkgs/simple/alacritty-tv.nix b/tv/5pkgs/simple/alacritty-tv.nix index bca779df..447926cf 100644 --- a/tv/5pkgs/simple/alacritty-tv.nix +++ b/tv/5pkgs/simple/alacritty-tv.nix @@ -55,6 +55,11 @@ let colors.primary.foreground = "#e0c0c0"; colors.normal.black = "#800000"; }; + configs.fzmenu = lib.recursiveUpdate configs.default { + colors.primary.background = "#2A172A"; + window.dimensions.columns = 70; + window.dimensions.lines = 9; + }; writeProfile = name: config: let config-file = assert lib.types.filename.check name; -- cgit v1.2.3 From dba0afc600eb447b3fa088b0ef96d891fc7be2cc Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 11 Jan 2023 17:34:26 +0100 Subject: tv alacritty: add x220 and hidpi variants --- tv/5pkgs/simple/alacritty-tv.nix | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) (limited to 'tv/5pkgs/simple/alacritty-tv.nix') diff --git a/tv/5pkgs/simple/alacritty-tv.nix b/tv/5pkgs/simple/alacritty-tv.nix index 447926cf..9da85062 100644 --- a/tv/5pkgs/simple/alacritty-tv.nix +++ b/tv/5pkgs/simple/alacritty-tv.nix @@ -1,4 +1,6 @@ -{ pkgs }: +{ pkgs +, variant ? "x220" +}: let lib = import ./lib; @@ -6,7 +8,7 @@ let program = "${pkgs.font-size-alacritty}/bin/font-size-alacritty"; args = [arg]; }; - configs.default = { + configs.default = lib.recursiveUpdate variants.${variant} { bell.animation = "EaseOut"; bell.duration = 50; bell.color = "#ff00ff"; @@ -30,10 +32,6 @@ let colors.bright.cyan = "#72fbfb"; colors.bright.white = "#fbfbfb"; draw_bold_text_with_bright_colors = true; - font.normal.family = "Clean"; - font.bold.family = "Clean"; - font.bold.style = "Regular"; - font.size = 10; hints.enabled = [ { regex = "(ipfs:|ipns:|magnet:|mailto:|gemini:|gopher:|https:|http:|news:|file:|git:|ssh:|ftp:)[^\\u0000-\\u001F\\u007F-\\u009F<>\"\\s{-}\\^⟨⟩`]+"; @@ -42,12 +40,6 @@ let action = "Select"; } ]; - key_bindings = [ - { key = "Up"; mods = "Shift|Control"; command = font-size "=14"; } - { key = "Up"; mods = "Control"; command = font-size "+1"; } - { key = "Down"; mods = "Control"; command = font-size "-1"; } - { key = "Down"; mods = "Shift|Control"; command = font-size "=0"; } - ]; scrolling.multiplier = 8; }; configs.root = lib.recursiveUpdate configs.default { @@ -60,6 +52,30 @@ let window.dimensions.columns = 70; window.dimensions.lines = 9; }; + variants.hidpi = { + font.normal.family = "iosevka-tv-1"; + font.bold.family = "iosevka-tv-1"; + font.italic.family = "iosevka-tv-1"; + font.bold_italic.family = "iosevka-tv-1"; + font.size = 5; + key_bindings = [ + { key = "Up"; mods = "Control"; action = "IncreaseFontSize"; } + { key = "Down"; mods = "Control"; action = "DecreaseFontSize"; } + { key = "Down"; mods = "Shift|Control"; action = "ResetFontSize"; } + ]; + }; + variants.x220 = { + font.normal.family = "Clean"; + font.bold.family = "Clean"; + font.bold.style = "Regular"; + font.size = 10; + key_bindings = [ + { key = "Up"; mods = "Shift|Control"; command = font-size "=14"; } + { key = "Up"; mods = "Control"; command = font-size "+1"; } + { key = "Down"; mods = "Control"; command = font-size "-1"; } + { key = "Down"; mods = "Shift|Control"; command = font-size "=0"; } + ]; + }; writeProfile = name: config: let config-file = assert lib.types.filename.check name; -- cgit v1.2.3 From 70472d8c45caba8df6f57b43cec686e4df459135 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 17 Jan 2023 00:37:46 +0100 Subject: tv alacritty: TMPDIR -> XDG_RUNTIME_DIR --- tv/5pkgs/simple/alacritty-tv.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tv/5pkgs/simple/alacritty-tv.nix') diff --git a/tv/5pkgs/simple/alacritty-tv.nix b/tv/5pkgs/simple/alacritty-tv.nix index 9da85062..7e24b7e1 100644 --- a/tv/5pkgs/simple/alacritty-tv.nix +++ b/tv/5pkgs/simple/alacritty-tv.nix @@ -83,7 +83,7 @@ let in pkgs.writeText "alacritty-tv-${name}.profile" /* sh */ '' # Use home so Alacritty can find the configuration without arguments. # HOME will be reset once in Alacritty. - HOME=$TMPDIR/Alacritty-${name} + HOME=$XDG_RUNTIME_DIR/Alacritty-${name} export HOME # Tell Alacritty via XDG_RUNTIME_DIR where to create sockets. -- cgit v1.2.3 From 29c8c3ecf1cc66a638020a564e1b72966c259a8b Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 17 Jan 2023 00:42:15 +0100 Subject: tv alacritty: admit missing ref file --- tv/5pkgs/simple/alacritty-tv.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tv/5pkgs/simple/alacritty-tv.nix') diff --git a/tv/5pkgs/simple/alacritty-tv.nix b/tv/5pkgs/simple/alacritty-tv.nix index 7e24b7e1..1c7730a7 100644 --- a/tv/5pkgs/simple/alacritty-tv.nix +++ b/tv/5pkgs/simple/alacritty-tv.nix @@ -101,7 +101,8 @@ let # rust-xdg requires XDG_RUNTIME_DIR to be secure: # https://docs.rs/xdg/2.4.1/src/xdg/lib.rs.html#311 ${pkgs.coreutils}/bin/mkdir -m 0700 -p "$HOME" - if test "$(${pkgs.coreutils}/bin/cat "$HOME"/ref)" != ${config-file}; then + ref=$(! test -e "$HOME"/ref || ${pkgs.coreutils}/bin/cat "$HOME"/ref) + if test "$ref" != ${config-file}; then echo ${config-file} > "$HOME"/ref ${pkgs.coreutils}/bin/cp ${config-file} "$HOME"/.alacritty.yml fi -- cgit v1.2.3