homeserver: disable auto login and zellij only attach on ssh connection

This commit is contained in:
Tigor Hutasuhut 2024-09-05 11:44:20 +07:00
parent b566cdb15c
commit 0f56e29da7
2 changed files with 22 additions and 18 deletions

View file

@ -27,27 +27,31 @@ in
if cfg.autoAttach then if cfg.autoAttach then
/*bash*/ /*bash*/
'' ''
if [[ -z "$ZELLIJ" ]]; then if [[ ! -z "$SSH_CLIENT" ]]; then
ZJ_SESSIONS=$(zellij list-sessions --no-formatting) if [[ -z "$ZELLIJ" ]]; then
NO_SESSIONS=$(echo "$ZJ_SESSIONS" | wc -l) ZJ_SESSIONS=$(zellij list-sessions --no-formatting)
if [ "$NO_SESSIONS" -ge 2 ]; then NO_SESSIONS=$(echo "$ZJ_SESSIONS" | wc -l)
SELECTED_SESSION=$(echo "$ZJ_SESSIONS" | ${pkgs.skim}/bin/sk | awk '{print $1}') if [ "$NO_SESSIONS" -ge 2 ]; then
if [[ -n "''${SELECTED_SESSION// /}" ]]; then SELECTED_SESSION=$(echo "$ZJ_SESSIONS" | ${pkgs.skim}/bin/sk | awk '{print $1}')
zellij attach -c "$SELECTED_SESSION" if [[ -n "''${SELECTED_SESSION// /}" ]]; then
else zellij attach -c "$SELECTED_SESSION"
zellij attach -c --index 0 else
fi zellij attach -c --index 0
else fi
zellij attach -c else
fi zellij attach -c
exit fi
exit
fi
fi fi
'' ''
else else
/*bash*/ '' /*bash*/ ''
if [[ -z "$ZELLIJ" ]]; then if [[ ! -z "$SSH_CLIENT" ]]; then
zellij attach -c default if [[ -z "$ZELLIJ" ]]; then
exit zellij attach -c default
exit
fi
fi fi
'' ''
); );

View file

@ -11,7 +11,7 @@
user = { user = {
name = "homeserver"; name = "homeserver";
fullName = "Homeserver"; fullName = "Homeserver";
getty.autoLogin = true; getty.autoLogin = false;
}; };
system.stateVersion = "24.05"; system.stateVersion = "24.05";