Sway启动时通过swaymsg启动tmux服务器后无法访问会话的问题排查求助
Sway启动时通过swaymsg启动tmux服务器后无法访问会话的问题排查求助
我想在Sway启动时自动启动tmux服务器,于是在sway.conf里添加了这一行配置:
exec ~/.config/sway/scripts/start-up.sh
对应的start-up.sh脚本内容如下:
#!/usr/bin/env bash # shellcheck disable=SC1091,SC2034 # set -e # set -u LOG=~/.sway-startup.log # Save stdout and stderr to file exec 3>&1 4>&2 >"$LOG" 2>&1 # Start tmux and make terminal on workspace 1. echo "Start tmux, let it recreate the workspaces with resurrect" tmux start-server echo "Server started." sleep 3 tmux list-sessions || { echo "ERROR: The exit-empty is not set to off, so the server directly exits!" >&2 } # Create one session if not yet existing, detach from it. tmux new-session -D -s Main-1 echo "Sessions are:" tmux list-sessions || { echo "ERROR: Sessions should now be available restored from tmux-ressurect???!" >&2 } echo "-----------" echo "Finished"
另外我已经在tmux.conf里设置了exit-empty false,就是为了避免tmux在没有会话时直接退出(这个默认行为确实有点反直觉)。
我现在纠结的点是:要不要阻止start-up.sh脚本退出?而且从脚本生成的日志~/.sway-startup.log来看,整个启动过程似乎都很正常:
Start tmux, let it recreate the workspaces with resurrect Server started. Astrovim: 1 windows (created Sat Nov 25 21:40:20 2023) Main-1: 1 windows (created Sat Nov 25 21:40:20 2023) Main-2: 1 windows (created Sat Nov 25 21:40:20 2023) NixOS: 1 windows (created Sat Nov 25 21:40:20 2023) duplicate session: Main-1 ### <<<<<<<<<<<<<<<- thats because resurrect created the above sessions automatically. Sessions are: Astrovim: 1 windows (created Sat Nov 25 21:40:20 2023) Main-1: 1 windows (created Sat Nov 25 21:40:20 2023) Main-2: 1 windows (created Sat Nov 25 21:40:20 2023) NixOS: 1 windows (created Sat Nov 25 21:40:20 2023) ----------- Finished
但实际操作时却出问题了:我运行tmux a想连接会话,系统提示没有会话存在!更诡异的是,我在btop里明明能看到tmux服务器进程在我的用户名下运行,甚至指定socket路径执行tmux -S /run/user/1000/tmux-1000 a,还是显示没有会话。
我现在完全摸不着头脑,有没有大佬能帮我排查一下这个奇怪的问题?会不会是通过swaymsg启动时触发了权限相关的问题?
备注:内容来源于stack exchange,提问作者Gabriel
相关产品推荐
相关产品推荐

