From 5055fefcf8b6db6bef2b3117541d9109da8d939c Mon Sep 17 00:00:00 2001 From: Matthieu Bessat Date: Tue, 9 Jul 2024 12:51:06 +0200 Subject: [PATCH] feat(sway): add sway systemd trigger --- ansible/roles/sway/tasks/main.yaml | 11 +++++++++++ ansible/templates/sway_systemd_trigger_target | 2 ++ ansible/templates/systemd/targets/sway-session.target | 6 ++++++ ansible/workstation.yaml | 4 ++++ 4 files changed, 23 insertions(+) create mode 100644 ansible/roles/sway/tasks/main.yaml create mode 100644 ansible/templates/sway_systemd_trigger_target create mode 100644 ansible/templates/systemd/targets/sway-session.target diff --git a/ansible/roles/sway/tasks/main.yaml b/ansible/roles/sway/tasks/main.yaml new file mode 100644 index 0000000..0c2ad0f --- /dev/null +++ b/ansible/roles/sway/tasks/main.yaml @@ -0,0 +1,11 @@ +- name: Add sway systemd target + become: true + template: + src: "systemd/targets/sway-session.target" + dest: /etc/systemd/user/sway-session.target + +- name: Add sway config + become: true + template: + src: "sway_systemd_trigger_target" + dest: /etc/sway/config.d/10-systemd-target diff --git a/ansible/templates/sway_systemd_trigger_target b/ansible/templates/sway_systemd_trigger_target new file mode 100644 index 0000000..7df4fce --- /dev/null +++ b/ansible/templates/sway_systemd_trigger_target @@ -0,0 +1,2 @@ +exec "systemctl --user import-environment {,WAYLAND_}DISPLAY SWAYSOCK; systemctl --user start sway-session.target" +exec swaymsg -t subscribe '["shutdown"]' && systemctl --user stop sway-session.target diff --git a/ansible/templates/systemd/targets/sway-session.target b/ansible/templates/systemd/targets/sway-session.target new file mode 100644 index 0000000..30151b3 --- /dev/null +++ b/ansible/templates/systemd/targets/sway-session.target @@ -0,0 +1,6 @@ +[Unit] +Description=sway compositor session +Documentation=man:systemd.special(7) +BindsTo=graphical-session.target +Wants=graphical-session-pre.target +After=graphical-session-pre.target diff --git a/ansible/workstation.yaml b/ansible/workstation.yaml index 62c5305..cbe92b6 100644 --- a/ansible/workstation.yaml +++ b/ansible/workstation.yaml @@ -152,6 +152,10 @@ community.general.pacman: name: "{{ (lookup('file', 'arch_packages.json') | from_json)['native'] }}" # the python script will return a list of packages + - name: Install sway + include_role: + name: sway + # DOTS - name: Clone dots file git: