xautolock
在给定的时间不活动之后,我用来锁定屏幕并挂起笔记本电脑。这很好。这是如何xautolock
开始的.xsessionrc
:
xautolock -time 60 -detectsleep -locker '~/bin/lockscreen --suspend' &
该~/bin/lockscreen
脚本除其他功能外,还ssh-add -D
可以从正在运行的SSH代理中删除所有SSH密钥。但是,当xautolock
从中产生此消息时,它不起作用.xsessionrc
-该ssh-add -D
命令抱怨它无法与身份验证代理进行通信。
但是,我可以ssh-add -D
在终端上正常pkill xautolock
运行,如果再在终端上运行xautolock
命令.xsessionrc
,则一切正常。
为什么不能ssh-add -D
过程中催生的xautolock
,从催生.xsessionrc
聊到SSH代理,而是ssh-add -D
催生了从xautolock
从一个普通终端可以催生?
ps auf
显示这棵树:
root 24126 0.0 0.1 105812 5032 tty1 Ss 18:34 0:00 /bin/login --
andreas 24132 0.0 0.1 40232 4956 tty1 S 18:34 0:00 \_ -zsh
andreas 24140 0.0 0.0 4328 1576 tty1 S+ 18:34 0:00 \_ /bin/sh /usr/bin/startx
andreas 24162 0.0 0.0 15944 1952 tty1 S+ 18:34 0:00 \_ xinit /etc/X11/xinit/xinitrc -- /etc/X11/xinit/xserverrc :0 vt1 -auth /tmp/serverauth.afXu0ohTRz
root 24163 1.4 0.5 165868 20048 tty1 S 18:34 0:02 \_ /usr/bin/X -nolisten tcp :0 vt1 -auth /tmp/serverauth.afXu0ohTRz
andreas 24169 0.0 0.2 113572 10600 tty1 S 18:34 0:00 \_ x-window-manager
andreas 24203 0.0 0.7 489436 26380 tty1 Sl 18:34 0:00 \_ nm-applet
andreas 24204 0.0 0.0 20140 2700 tty1 S 18:34 0:00 \_ xautolock -time 60 -detectsleep -locker ~/bin/lockscreen --suspend
andreas 24209 0.0 0.0 22196 2680 tty1 S 18:34 0:00 \_ /usr/bin/unclutter -idle 1 -root
andreas 24212 0.0 0.0 10688 340 ? Ss 18:34 0:00 \_ /usr/bin/ssh-agent /usr/bin/dbus-launch --exit-with-session x-window-manager
我唯一可行的理论是,因为xautolock
该分支ssh-add
命令是在SSH代理之前启动的,所以它不知道该代理的存在,但这对我来说似乎很奇怪。
X窗口管理器通过命令启动ssh-agent dbus-launcher --exit-with-session i3
,这意味着SSH代理在窗口管理器之前启动。但是,Debian.xsessionrc
在发生这种情况之前xautolocker
就已经找到了资源,因此在启动时,SSH代理尚未启动,并且ssh-add
尚未设置与代理进行通信所需的环境变量。
一种解决方案是.xinitrc
在采购之前进行修改以启动代理.xsessionrc
:
if command -v 'ssh-agent' >/dev/null 2>&1; then
eval $(ssh-agent -s)
fi
[ -e $HOME/.xsessionrc ] && . $HOME/.xsessionrc
x-window-manager
if command -v 'ssh-agent' >/dev/null 2>&1; then
ssh-agent -k
fi
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句