From 8a7567a8b1fb3eee08ba132b642e645e37cc4ee5 Mon Sep 17 00:00:00 2001 From: Sanchayan Maity Date: Mon, 4 Apr 2022 14:52:07 +0530 Subject: [PATCH] Start tmux sessions using systemd While starting the tmux sessions from fish worked some environment variables were not getting picked up in tmux session. For example DISPLAY is set after we log in and the graphical sway session starts but since tmux sessions were started before that it would be absent from the tmux session. We may be wrong about the exact order and reasoning for this but atleast that is the observed behaviour. Fix this by defining a sway session target and making the tmux session service dependent on it. --- fish/.config/fish/conf.d/setup.fish | 3 --- sway/.config/sway/config | 2 ++ systemd/.config/systemd/user/sway-session.target | 6 ++++++ systemd/.config/systemd/user/tmux-session.service | 9 +++++++++ 4 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 systemd/.config/systemd/user/sway-session.target create mode 100644 systemd/.config/systemd/user/tmux-session.service diff --git a/fish/.config/fish/conf.d/setup.fish b/fish/.config/fish/conf.d/setup.fish index c47d655..bc4f786 100644 --- a/fish/.config/fish/conf.d/setup.fish +++ b/fish/.config/fish/conf.d/setup.fish @@ -65,9 +65,6 @@ function __fish_setup_on_tty_login --description "Set up environment on tty logi mkdir -p /tmp/gst-dot set -Ux GST_DEBUG_DUMP_DOT_DIR /tmp/gst-dot - - # Start all tmux sessions on login - ~/.tmux/session-setup.sh end # Instead of tty check, we would have liked to do this using status is-login diff --git a/sway/.config/sway/config b/sway/.config/sway/config index 3125341..8b38725 100644 --- a/sway/.config/sway/config +++ b/sway/.config/sway/config @@ -268,3 +268,5 @@ for_window [title="Firefox — Sharing Indicator"] no_focus for_window [app_id="gst-launch-1.0"] floating enable, resize set width 1920 px height 1080px assign [app_id="gst-launch-1.0"] 4 assign [title="gst-play-1.0"] 4 + +exec_always "systemctl --user import-environment; systemctl --user start sway-session.target" diff --git a/systemd/.config/systemd/user/sway-session.target b/systemd/.config/systemd/user/sway-session.target new file mode 100644 index 0000000..a6dadf9 --- /dev/null +++ b/systemd/.config/systemd/user/sway-session.target @@ -0,0 +1,6 @@ +[Unit] +Description=Sway compositor session +Documentation=man:systemd.special +BindsTo=graphical-session.target +Wants=graphical-session-pre.target +After=graphical-session-pre.target diff --git a/systemd/.config/systemd/user/tmux-session.service b/systemd/.config/systemd/user/tmux-session.service new file mode 100644 index 0000000..9a5d252 --- /dev/null +++ b/systemd/.config/systemd/user/tmux-session.service @@ -0,0 +1,9 @@ +[Unit] +Description=Start all tmux sessions on login + +[Service] +Type=forking +ExecStart=%h/.tmux/session-setup.sh + +[Install] +WantedBy=sway-session.target