From b9a9097f95ee7a9e5105bad57730e82bd4d4235c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20K=C3=B6rber?= Date: Sat, 2 Oct 2021 10:52:59 +0200 Subject: [PATCH] autostart: Template the autostart target unit file --- .../autostart.target => autostart.target.j2} | 4 +++- user.yml | 22 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) rename autostart/{services/autostart.target => autostart.target.j2} (84%) diff --git a/autostart/services/autostart.target b/autostart/autostart.target.j2 similarity index 84% rename from autostart/services/autostart.target rename to autostart/autostart.target.j2 index cd054a3..7d4fbae 100644 --- a/autostart/services/autostart.target +++ b/autostart/autostart.target.j2 @@ -7,7 +7,9 @@ Wants=discord.service Wants=dpms.service Wants=dunst.service Wants=element.service -Wants=firefox.service +{% for profile in user.firefox_profiles|default([]) %} +Wants=firefox@{{ profile.name }}.service +{% endfor %} Wants=gpg-agent.service Wants=gnome-keyring.service Wants=keepassx.service diff --git a/user.yml b/user.yml index e2de76e..ad76dff 100644 --- a/user.yml +++ b/user.yml @@ -478,5 +478,27 @@ group: "{{ user_group_name }}" with_fileglob: /var/lib/dotfiles/autostart/services/* + - name: get state of autostart.target + stat: + path: "/home/{{ user.name }}/.config/systemd/user/autostart.target" + register: autostart_target_stat + + - name: remove invalid autostart.target + file: + path: "/home/{{ user.name }}/.config/systemd/user/autostart.target" + state: absent + when: + - autostart_target_stat.stat.exists + - not autostart_target_stat.stat.isreg + + - name: deploy autostart.target + template: + src: ./autostart/autostart.target.j2 + dest: "/home/{{ user.name }}/.config/systemd/user/autostart.target" + owner: "{{ user.name }}" + group: "{{ user_group_name }}" + force: true + follow: false + tags: - autostart