From 7b837afa2d137d94e8aff4030f4c8976609810eb Mon Sep 17 00:00:00 2001 From: Bluemedia Date: Wed, 6 Aug 2025 14:24:02 +0200 Subject: [PATCH] Add defaults for all relevant host_vars --- roles/desktop-environment/tasks/config.yml | 2 +- roles/desktop-environment/tasks/utils.yml | 4 ++-- .../templates/.config/hypr/hyprland.conf.j2 | 12 ++++++++---- .../templates/.local/bin/hyprhelpr.j2 | 8 ++++++++ 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/roles/desktop-environment/tasks/config.yml b/roles/desktop-environment/tasks/config.yml index d4486ed..af1c5ca 100644 --- a/roles/desktop-environment/tasks/config.yml +++ b/roles/desktop-environment/tasks/config.yml @@ -33,7 +33,7 @@ dest: "/etc/systemd/" - src: "{{ role_path }}/files/systemd/sleep.conf.d" dest: "/etc/systemd/" - when: hostvars[ansible_hostname]['mobile_platform'] + when: "hostvars[ansible_hostname]['mobile_platform'] | default(false)" - name: Copy static config files copy: diff --git a/roles/desktop-environment/tasks/utils.yml b/roles/desktop-environment/tasks/utils.yml index 531dc9e..87a74a9 100644 --- a/roles/desktop-environment/tasks/utils.yml +++ b/roles/desktop-environment/tasks/utils.yml @@ -39,7 +39,7 @@ name: - brightnessctl - network-manager - when: hostvars[ansible_hostname]['mobile_platform'] + when: "hostvars[ansible_hostname]['mobile_platform'] | default(false)" - name: Install brightnessctl udev rules become: yes @@ -49,7 +49,7 @@ owner: root group: root mode: u=rw,g=r,o=r - when: hostvars[ansible_hostname]['mobile_platform'] + when: "hostvars[ansible_hostname]['mobile_platform'] | default(false)" - name: Install zsh become: yes diff --git a/roles/desktop-environment/templates/.config/hypr/hyprland.conf.j2 b/roles/desktop-environment/templates/.config/hypr/hyprland.conf.j2 index e4663b2..bca980e 100644 --- a/roles/desktop-environment/templates/.config/hypr/hyprland.conf.j2 +++ b/roles/desktop-environment/templates/.config/hypr/hyprland.conf.j2 @@ -1,8 +1,12 @@ # Monitor configuration (see https://wiki.hyprland.org/Configuring/Monitors/) +{% if (hostvars[ansible_hostname]['monitors'] | default([])) | length > 0 %} {% for monitor in hostvars[ansible_hostname]['monitors'] %} -monitor=desc:{{ monitor['desc'] }}, {{ monitor['resolution'] }}, {{ monitor['position'] | default('auto') }}, 1{% if 'transform' in monitor %}, transform, {{ monitor['transform'] }}{% endif %} +monitor = desc:{{ monitor['desc'] }}, {{ monitor['resolution'] }}, {{ monitor['position'] | default('auto') }}, 1{% if 'transform' in monitor %}, transform, {{ monitor['transform'] }}{% endif %} {% endfor %} +{% else %} +monitor = , preferred, auto, 1 +{% endif %} # Programs to use $terminal = flatpak run --nosocket=wayland org.wezfurlong.wezterm @@ -102,7 +106,7 @@ windowrulev2 = float,title:^(Application Finder)$ windowrulev2 = size 500 500,title:^(Application Finder)$ # Workspace rules -{% for workspace in hostvars[ansible_hostname]['workspaces'] %} +{% for workspace in hostvars[ansible_hostname]['workspaces'] | default([]) %} workspace = {{ workspace['id'] }}{% if 'monitor' in workspace %}, monitor:desc:{{ workspace['monitor'] }}{% endif %}{% if 'default' in workspace %}, default:{{ workspace['default'] | lower }}{% endif %}{% if 'layoutopt_orientation' in workspace %}, layoutopt:orientation:{{ workspace['layoutopt_orientation'] }}{% endif %}{% if 'on_created_empty' in workspace %}, on-created-empty:{{ workspace['on_created_empty'] }}{% endif %} {% endfor %} @@ -119,7 +123,7 @@ exec-once = flatpak run com.tomjwatson.Emote {% if 'nextcloud' in role_names %} exec-once = nextcloud --background {% endif %} -{% for autostart in hostvars[ansible_hostname]['autostart'] %} +{% for autostart in hostvars[ansible_hostname]['autostart'] | default([]) %} exec-once = {% if 'workspace' in autostart %}[workspace {{ autostart['workspace'] }} {%- if (autostart['silent'] | default('false')) | bool %} silent{% endif %}] {% endif %}{{ autostart['command'] }} {% endfor %} @@ -178,7 +182,7 @@ bind = $mainMod SHIFT, 0, movetoworkspace, 10 bindm = $mainMod, mouse:272, movewindow bindm = $mainMod, mouse:273, resizewindow -{% if hostvars[ansible_hostname]['mobile_platform'] | bool %} +{% if (hostvars[ansible_hostname]['mobile_platform'] | default(false)) | bool %} # Backlight control bind = , XF86MonBrightnessUp, exec, brightnessctl -d intel_backlight set +5% bind = , XF86MonBrightnessDown, exec, brightnessctl -d intel_backlight set 5%- diff --git a/roles/desktop-environment/templates/.local/bin/hyprhelpr.j2 b/roles/desktop-environment/templates/.local/bin/hyprhelpr.j2 index 35cf40e..02c941b 100644 --- a/roles/desktop-environment/templates/.local/bin/hyprhelpr.j2 +++ b/roles/desktop-environment/templates/.local/bin/hyprhelpr.j2 @@ -4,10 +4,14 @@ set -eu background() { swaybg \ +{% if (hostvars[ansible_hostname]['monitors'] | default([])) | length > 0 %} {% for monitor in hostvars[ansible_hostname]['monitors'] %} -o "{{ monitor['desc'] }}" -i ~/.config/background/{{ monitor['background']['file'] }} -m {{ monitor['background']['mode'] }} {%- if not loop.last %} \{% endif %} {% endfor %} +{% else %} + -o '*' -i ~/.config/background/bg0.png -m fill +{% endif %} } idle() { @@ -25,10 +29,14 @@ lock() { exit 1 else swaylock -f -e -s fill --indicator-radius 150 \ +{% if (hostvars[ansible_hostname]['monitors'] | default([])) | length > 0 %} {% for monitor in hostvars[ansible_hostname]['monitors'] %} -i {{ monitor['output'] }}:~/.config/background/lock-{{ monitor['background']['file'] }} {%- if not loop.last %} \{% endif %} {% endfor %} +{% else %} + -i ~/.config/background/lock-bg0.png +{% endif %} fi }