summaryrefslogtreecommitdiffstats
path: root/pkgs/simple/alacritty-tv.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/simple/alacritty-tv.nix')
-rw-r--r--pkgs/simple/alacritty-tv.nix56
1 files changed, 39 insertions, 17 deletions
diff --git a/pkgs/simple/alacritty-tv.nix b/pkgs/simple/alacritty-tv.nix
index 0d2fe59..ebf609e 100644
--- a/pkgs/simple/alacritty-tv.nix
+++ b/pkgs/simple/alacritty-tv.nix
@@ -5,18 +5,33 @@ pkgs.symlinkJoin {
paths = [
(pkgs.writeDashBin "alacritty" ''
# usage:
- # alacritty [--profile=PROFILE] [--singleton] [ARGS...]
+ # alacritty [--dtach] [--profile=PROFILE] [--singleton] [COMMAND [ARGS...]]
# where
# PROFILE must have a corresponding file /etc/alacritty/PROFILE.toml
set -efu
+ dtach=
profile=default
- case ''${1-} in
- --profile=*)
- profile=''${1#--profile=}
- shift
- esac
+ singleton=
+ while :; do
+ case ''${1-} in
+ --dtach)
+ dtach=1
+ shift
+ ;;
+ --profile=*)
+ profile=''${1#--profile=}
+ shift
+ ;;
+ --singleton)
+ singleton=1
+ shift
+ ;;
+ *)
+ break
+ esac
+ done
config=/etc/alacritty/$profile.toml
@@ -31,17 +46,24 @@ pkgs.symlinkJoin {
${pkgs.jq}/bin/jq .device_scale_factor
)
- case ''${1-} in
- --singleton)
- shift
- if ! ${pkgs.alacritty}/bin/alacritty --config-file "$config" msg create-window "$@"; then
- ${pkgs.alacritty}/bin/alacritty --config-file "$config" "$@" &
- fi
- ;;
- *)
- exec ${pkgs.alacritty}/bin/alacritty --config-file "$config" "$@"
- ;;
- esac
+ if test "$dtach" = 1; then
+ if test $# = 0; then
+ _CURRENT_DESKTOP_NAME=''${_CURRENT_DESKTOP_NAME-$(${pkgs.xextras}/bin/net-current-desktop)}
+ SHELL=''${SHELL-${pkgs.bash}/bin/bash}
+ sock=$XDG_RUNTIME_DIR/Alacritty-$DISPLAY-dtach-$_CURRENT_DESKTOP_NAME-$$.sock
+ set -- -e ${pkgs.dtach}/bin/dtach -c "$sock" -r winch -z "$SHELL"
+ else
+ echo 'alacritty-tv: warning: option --dtach ignored: arguments provided' >&2
+ fi
+ fi
+
+ if test "$singleton" = 1; then
+ if ! ${pkgs.alacritty}/bin/alacritty --config-file "$config" msg create-window "$@"; then
+ ${pkgs.alacritty}/bin/alacritty --config-file "$config" "$@" &
+ fi
+ else
+ exec ${pkgs.alacritty}/bin/alacritty --config-file "$config" "$@"
+ fi
'')
pkgs.alacritty
];