I want to start tmux
server on sway startup.
Therefore I created in sway.conf
the following:
exec ~/.config/sway/scripts/start-up.sh
in which script I start tmux as such:
#!/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"
In the tmux.conf
I have set exit-empty false
such that tmux does not quit if no session on `tmux start-server (weird behavior...).
I am really unsure if I need to block the script start-up.sh
from exiting or not, because the log ~/.sway-startup.log
from launching the script with swaymsg exec .../start-up.sh
reports the following:
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
After that when I tmux a
it reports there are no sessions
. This is so weird, the server runs as I can see in btop
(running under my user name) but also using tmux -S /run/user/1000/tmux-1000 a
pointing to the socket does report no sessions
?
I am really puzzled and dont know whats going on? How can I resolve this strange issue?
Somehow this is permission problem when starting over swaymsg
.
tmux display-message -p '#{socket_path}'
. Restart and check the log. The point istmux -S garbage a
may showno sessions
(and creategarbage
), so let's better be sure what the path of the socket is.