From 5cfbe03d7195eb0ebe9a3cfe6f5c65b3c9eae29d Mon Sep 17 00:00:00 2001 From: Konstantin Demin Date: Thu, 19 Dec 2024 20:50:46 +0300 Subject: [PATCH] zsh: optimize gpg-agent initialization --- .config/zsh/rc/gpg-agent.zsh | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/.config/zsh/rc/gpg-agent.zsh b/.config/zsh/rc/gpg-agent.zsh index e3f4990..28122d5 100644 --- a/.config/zsh/rc/gpg-agent.zsh +++ b/.config/zsh/rc/gpg-agent.zsh @@ -6,12 +6,17 @@ z-gpg-agent() { (( ${+commands[gpg-agent]} )) || return 127 - local u - for u in gpg-agent.{service,socket} ; do - z-systemctl-exists --user $u || continue - - z-systemctl --user --now enable $u - done + if (( ${+commands[systemctl]} )) ; then + local u s + for u in gpg-agent.{service,socket} ; do + s=$(z-systemctl --user is-enabled $u) + case "$s" in + disabled ) ;; + * ) continue ;; + esac + z-systemctl --user --now enable $u + done + fi (( ${+commands[gpgconf]} )) || return 127