Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resurrect needs a terminal to restore cursor. #535

Open
Mikilio opened this issue Feb 3, 2025 · 0 comments
Open

Resurrect needs a terminal to restore cursor. #535

Mikilio opened this issue Feb 3, 2025 · 0 comments

Comments

@Mikilio
Copy link

Mikilio commented Feb 3, 2025

Summary

I wanted to use tmux-continuum to restore my session in the background before I even start my first terminal (via start-server). Unfortunately, tmux-resurrect seems to not have been made with this in mind. In particular, the tmux switch-client commands do not work when tmux has not attached to some proper terminals. I have verified that a PTY is not enough for this as well.

What works without terminal

  • restoring sessions, windows and panes
  • restoring running commands with correct strategy

What does not work without terminal

  • Restore active and last session
  • Restore active window and pane

Solutions

I am aware that a rewrite could result in a big PR and would abandon a lot of logic that has been working for years. I would be happy to eventually see one, but for now I propose the following workarounds:

  • Start tmux automatically in an actual terminal. Many Desktops support hiding such windows.
  • Use a VT (lookup agetty) to start tmux. (REQUIRES ROOT)
  • Use the following systemd service:
# /home/mikilio/.config/systemd/user/tmuxd.service
[Install]
WantedBy=graphical-session.target

[Service]
ExecStart=/nix/store/w1m8fvzdbkpl402c1q481yly5dx1p9ki-resurrect.exp
ExecStop=/nix/store/2ldgm1x51p6bxahb78ffhkmbmj4jp6ad-tmuxplugin-resurrect-unstable-2022-05-01/share/tmux-plugins/resurrect/scripts/save.sh
ExecStop=/nix/store/5r10w0nb4m0k6i36a5isgvbmzirfwhms-tmux-3.5a/bin/tmux kill-server
Type=forking

[Unit]
After=graphical-session.target
Description=tmux user server
Documentation=man:tmux(1)
PartOf=graphical-session.target

replacing nix paths with your actual paths
The resurrect script looks something like this:

 #!/usr/bin/env expect
set env(TERM) xterm
spawn tmux
sleep 2
send "\x00"
send "\x12"
sleep 5

And is just a slight change from this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant