tmux-plugins / tmux-continuum

Continuous saving of tmux environment. Automatic restore when tmux is started. Automatic tmux start when computer is turned on.
MIT License
3.31k stars 149 forks source link

Hardcoded DISPLAY Variable Issues #127

Open Friendliness opened 1 year ago

Friendliness commented 1 year ago
          @bruno- alright, that should work. I will try to help! Regarding the DISPLAY variable, I am not a 100% sure. I know that my tmux systemd service works fine right now, on different Ubuntu systems with different gpus (AMD Vega, NVidia RTX, Intel built-in) and with different monitor configurations. But it might be that if we wait for the graphical target anyway, it might not be needed. I think I will need to test that. I'll update the PR after I checked that.

Originally posted by @nuclearglow in https://github.com/tmux-plugins/tmux-continuum/issues/107#issuecomment-1144735098

Heya,

I don't know if it this is directly related to the systemd service you've created in this pull request, but I was having an issue with restored tmux sessions and neovim. The $DISPLAY environment variable you've manually set in the service wasn't always :0 for me, after suspending and unsuspending my device, xclip was unable to copy anything inside of tmux to the clipboard, until I changed the DISPLAY variable manually in the session or opened up a new pane manually.

What I did which seemed to at least fix this for now was simply remove the following line:

[Unit]
Description=tmux default session (detached)
Documentation=man:tmux(1)

[Service]
Type=forking
- Environment=DISPLAY=:0
ExecStart=/usr/bin/tmux new-session -d

ExecStop=/home/friendliness/.config/tmux/plugins/tmux-resurrect/scripts/save.sh
ExecStop=/usr/bin/tmux kill-server
KillMode=control-group

RestartSec=2

[Install]
WantedBy=default.target

If the $DISPLAY variable not being set causes any issues I'm not currently aware of, I can modify the PR I opened to get the variable automatically and not hardcode it.

I'm not very knowledgeable about x11 so this is probably not the most ideal solution but it seemed to work for me.
I'm on a dual monitor setup with an NVIDIA RTX 2080 Ti on Pop_OS.