From 7801b7bda408e401a6b8b1f8797c6f319bba8844 Mon Sep 17 00:00:00 2001 From: "flyingscorpio@clevo" Date: Sun, 12 Jun 2022 12:48:47 +0200 Subject: [PATCH] Use conditions in template instead of lineinfile --- roles/i3/tasks/main.yml | 19 ------------------- roles/i3/templates/i3config.j2 | 9 ++++++--- 2 files changed, 6 insertions(+), 22 deletions(-) diff --git a/roles/i3/tasks/main.yml b/roles/i3/tasks/main.yml index 6f15628..5ce9b4c 100644 --- a/roles/i3/tasks/main.yml +++ b/roles/i3/tasks/main.yml @@ -121,22 +121,3 @@ become: true shell: cd {{ ansible_facts.user_dir }}/.git_clones/i3blocks && make install when: ansible_facts['distribution'] == 'Debian' - -- name: Uncomment wallpaper lines for clitip or xkcd - lineinfile: - path: ~/.config/i3/config - regexp: "{{ item }}" - line: '\1' - backrefs: true - with_items: - - '^#(exec .*wallpaper\.sh$)' - - '^#(exec .* hsetroot -center .*\.png$)' - when: wallpaper_type != 'fixed' - -- name: Uncomment wallpaper lines for fixed - lineinfile: - path: ~/.config/i3/config - regexp: '^#(exec .* hsetroot -cover .*current$)' - line: '\1' - backrefs: true - when: wallpaper_type == 'fixed' diff --git a/roles/i3/templates/i3config.j2 b/roles/i3/templates/i3config.j2 index 94739f8..7ba5d01 100644 --- a/roles/i3/templates/i3config.j2 +++ b/roles/i3/templates/i3config.j2 @@ -9,9 +9,12 @@ font pango: Noto Sans 9 floating_modifier $super #autostart -#exec --no-startup-id ~/.local/bin/{{ wallpaper_type }}_wallpaper.sh -#exec --no-startup-id hsetroot -center ~/Pictures/wallpapers/{{ wallpaper_type }}-wallpaper.png -#exec --no-startup-id hsetroot -cover ~/Pictures/wallpapers/current +{% if wallpaper_type == "fixed" %} +exec --no-startup-id hsetroot -cover ~/Pictures/wallpapers/current +{% else %} +exec --no-startup-id ~/.local/bin/{{ wallpaper_type }}_wallpaper.sh +exec --no-startup-id hsetroot -center ~/Pictures/wallpapers/{{ wallpaper_type }}-wallpaper.png +{% endif %} exec --no-startup-id xsettingsd & exec --no-startup-id picom -b --config ~/.config/picom.conf