From 93f4b81fb94ffb5a5878774a49b391ac4577b081 Mon Sep 17 00:00:00 2001 From: Sonny Bakker Date: Fri, 4 Sep 2026 14:19:22 +0200 Subject: [PATCH] Use EnvironmentFile for tmux service --- tasks/systemd.yml | 15 ++++++++++++++- templates/tmux/env.j2 | 10 ++++++++++ templates/{tmux.j2 => tmux/service.j2} | 2 +- 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 templates/tmux/env.j2 rename templates/{tmux.j2 => tmux/service.j2} (80%) diff --git a/tasks/systemd.yml b/tasks/systemd.yml index d79cfa8..2c940e2 100644 --- a/tasks/systemd.yml +++ b/tasks/systemd.yml @@ -14,16 +14,29 @@ - name: Copy tmux service ansible.builtin.template: - src: "templates/tmux.j2" + src: "templates/tmux/service.j2" dest: "{{ xdg_config_dir }}/systemd/user/tmux.service" mode: "0644" notify: - User daemon-reload - Restart tmux service +- name: Create tmux configuration directory + ansible.builtin.file: + path: "{{ xdg_config_dir }}/tmux" + state: directory + mode: "0755" + - name: Copy tmux startup script ansible.builtin.copy: src: "files/tmux_start" dest: "{{ ansible_env.HOME }}/.local/bin/tmux_start" mode: "0740" force: false + +- name: Copy tmux environment file + ansible.builtin.template: + src: "templates/tmux/env.j2" + dest: "{{ xdg_config_dir }}/tmux/env" + mode: "0755" + force: false diff --git a/templates/tmux/env.j2 b/templates/tmux/env.j2 new file mode 100644 index 0000000..ff750ba --- /dev/null +++ b/templates/tmux/env.j2 @@ -0,0 +1,10 @@ +WAYLAND_DISPLAY=wayland-0 +XDG_CONFIG_DIRS=/home/sonny/.config/kdedefaults:/etc/xdg +XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session1 +XDG_MENU_PREFIX=plasma- +XDG_SEAT=seat0 +XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0 +XDG_SESSION_CLASS=user +XDG_VTNR=2 +XDG_SESSION_ID=2 +XDG_DATA_DIRS=/home/sonny/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share/:/usr/share/ diff --git a/templates/tmux.j2 b/templates/tmux/service.j2 similarity index 80% rename from templates/tmux.j2 rename to templates/tmux/service.j2 index 3044e2b..2d195b2 100644 --- a/templates/tmux.j2 +++ b/templates/tmux/service.j2 @@ -4,7 +4,7 @@ Description=Tmux startup script [Service] -Environment=WAYLAND_DISPLAY=wayland-0 +EnvironmentFile={{ xdg_config_dir }}/tmux/env ExecStart=/home/sonny/.local/bin/tmux_start Type=forking RemainAfterExit=yes