From 597844c60cf5af95bf88845007e792fd879859ae Mon Sep 17 00:00:00 2001 From: ulic-youthlic Date: Wed, 15 Jan 2025 22:56:52 +0800 Subject: [PATCH] fix pinentry selector in pkgs --- pkgs/pinentry-selector.nix | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/pkgs/pinentry-selector.nix b/pkgs/pinentry-selector.nix index 55c722f..24558fb 100644 --- a/pkgs/pinentry-selector.nix +++ b/pkgs/pinentry-selector.nix @@ -5,18 +5,21 @@ pkgs.writeShellApplication { pinentry-all ]; text = '' - case $(tty) in - /dev/tty[1-9]) - pinentry-curses;; - /dev/pts/*) - if [ -v SSH_CLIENT ] && [ -n "$SSH_CLIENT" ]; then - pinentry-curses - else - pinentry-qt - fi - ;; - *) - pinentry-curses;; - esac + if [ -v XDG_SESSION_TYPE ]; then + case $XDG_SESSION_TYPE in + tty) + pinentry-tty;; + *) + pinentry-qt;; + esac + elif [ -v SSH_CLIENT ] && [ -n "$SSH_CLIENT" ]; then + pinentry-tty + elif [ -v WAYLAND_DISPLAY ] && [ -n "$WAYLAND_DISPLAY" ]; then + pinentry-qt + elif [ -v DISPLAY ] && [ -n "$DISPLAY" ]; then + pinentry-qt + else + pinentry-tty + fi ''; }