From 0f56e29da70b4e77ef4637e950f1c4cc58ac1a38 Mon Sep 17 00:00:00 2001 From: Tigor Hutasuhut Date: Thu, 5 Sep 2024 11:44:20 +0700 Subject: [PATCH] homeserver: disable auto login and zellij only attach on ssh connection --- home/programs/zellij/default.nix | 38 ++++++++++++++++++-------------- profiles/homeserver.nix | 2 +- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/home/programs/zellij/default.nix b/home/programs/zellij/default.nix index 582004a..da46b43 100644 --- a/home/programs/zellij/default.nix +++ b/home/programs/zellij/default.nix @@ -27,27 +27,31 @@ in if cfg.autoAttach then /*bash*/ '' - if [[ -z "$ZELLIJ" ]]; then - ZJ_SESSIONS=$(zellij list-sessions --no-formatting) - NO_SESSIONS=$(echo "$ZJ_SESSIONS" | wc -l) - if [ "$NO_SESSIONS" -ge 2 ]; then - SELECTED_SESSION=$(echo "$ZJ_SESSIONS" | ${pkgs.skim}/bin/sk | awk '{print $1}') - if [[ -n "''${SELECTED_SESSION// /}" ]]; then - zellij attach -c "$SELECTED_SESSION" - else - zellij attach -c --index 0 - fi - else - zellij attach -c - fi - exit + if [[ ! -z "$SSH_CLIENT" ]]; then + if [[ -z "$ZELLIJ" ]]; then + ZJ_SESSIONS=$(zellij list-sessions --no-formatting) + NO_SESSIONS=$(echo "$ZJ_SESSIONS" | wc -l) + if [ "$NO_SESSIONS" -ge 2 ]; then + SELECTED_SESSION=$(echo "$ZJ_SESSIONS" | ${pkgs.skim}/bin/sk | awk '{print $1}') + if [[ -n "''${SELECTED_SESSION// /}" ]]; then + zellij attach -c "$SELECTED_SESSION" + else + zellij attach -c --index 0 + fi + else + zellij attach -c + fi + exit + fi fi '' else /*bash*/ '' - if [[ -z "$ZELLIJ" ]]; then - zellij attach -c default - exit + if [[ ! -z "$SSH_CLIENT" ]]; then + if [[ -z "$ZELLIJ" ]]; then + zellij attach -c default + exit + fi fi '' ); diff --git a/profiles/homeserver.nix b/profiles/homeserver.nix index e05b48a..bdedbad 100644 --- a/profiles/homeserver.nix +++ b/profiles/homeserver.nix @@ -11,7 +11,7 @@ user = { name = "homeserver"; fullName = "Homeserver"; - getty.autoLogin = true; + getty.autoLogin = false; }; system.stateVersion = "24.05";