Skip to content

Resurrect needs a terminal to restore cursor. #535

@Mikilio

Description

@Mikilio

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions