feat(bootstrap): per-os desktop apps, KDE plasma-login-manager and DM resolution
This commit is contained in:
@@ -4,11 +4,20 @@
|
||||
vars:
|
||||
_autologin: "{{ system_cfg.features.desktop.autologin | default(false) }}"
|
||||
ansible.builtin.set_fact:
|
||||
# KDE resolves to the plasmalogin unit on Arch/Fedora44+ (Plasma 6.6), else sddm.
|
||||
_desktop_dm: >-
|
||||
{{
|
||||
system_cfg.features.desktop.display_manager
|
||||
('plasmalogin'
|
||||
if system_cfg.features.desktop.display_manager == 'plasma-login-manager'
|
||||
else system_cfg.features.desktop.display_manager)
|
||||
if (system_cfg.features.desktop.display_manager | length > 0)
|
||||
else (configuration_desktop_dm_map[system_cfg.features.desktop.environment] | default(''))
|
||||
else (
|
||||
('plasmalogin'
|
||||
if (os == 'archlinux' or (os == 'fedora' and (os_version | int) >= 44))
|
||||
else 'sddm')
|
||||
if system_cfg.features.desktop.environment == 'kde'
|
||||
else (configuration_desktop_dm_map[system_cfg.features.desktop.environment] | default(''))
|
||||
)
|
||||
}}
|
||||
_desktop_session: "{{ system_cfg.features.desktop.session | default('') }}"
|
||||
# Explicit session wins, else the per-environment command. Single source of
|
||||
@@ -52,6 +61,7 @@
|
||||
- _configuration_platform.init_system == 'systemd'
|
||||
- system_cfg.features.desktop.enabled | bool
|
||||
- _desktop_dm | length > 0
|
||||
- _desktop_dm != 'ly'
|
||||
ansible.builtin.command: "{{ chroot_command }} systemctl enable {{ _desktop_dm }}"
|
||||
register: configuration_enable_dm_result
|
||||
changed_when: configuration_enable_dm_result.rc == 0
|
||||
@@ -70,14 +80,40 @@
|
||||
register: _ufw_enable_result
|
||||
changed_when: _ufw_enable_result.rc == 0
|
||||
failed_when: false
|
||||
|
||||
- name: Set default systemd target to graphical
|
||||
- name: Enable ly on its tty
|
||||
when:
|
||||
- _configuration_platform.init_system == 'systemd'
|
||||
- system_cfg.features.desktop.enabled | bool
|
||||
ansible.builtin.command: "{{ chroot_command }} systemctl set-default graphical.target"
|
||||
register: _desktop_target_result
|
||||
changed_when: _desktop_target_result.rc == 0
|
||||
- _desktop_dm == 'ly'
|
||||
vars:
|
||||
_ly_tty: tty2
|
||||
block:
|
||||
- name: Enable ly display manager
|
||||
ansible.builtin.command: "{{ chroot_command }} systemctl enable ly@{{ _ly_tty }}.service"
|
||||
register: configuration_enable_ly_result
|
||||
changed_when: configuration_enable_ly_result.rc == 0
|
||||
failed_when: >-
|
||||
configuration_enable_ly_result.rc != 0
|
||||
or 'No such file or directory' in (configuration_enable_ly_result.stderr | default(''))
|
||||
or 'does not exist' in (configuration_enable_ly_result.stderr | default(''))
|
||||
|
||||
# ly drives the VT itself; mask getty so logind never spawns a login on that tty.
|
||||
- name: Mask getty on ly's tty
|
||||
ansible.builtin.command: "{{ chroot_command }} systemctl mask getty@{{ _ly_tty }}.service"
|
||||
register: configuration_mask_getty_result
|
||||
changed_when: configuration_mask_getty_result.rc == 0
|
||||
failed_when: >-
|
||||
configuration_mask_getty_result.rc != 0
|
||||
and 'No such file or directory' not in (configuration_mask_getty_result.stderr | default(''))
|
||||
and 'does not exist' not in (configuration_mask_getty_result.stderr | default(''))
|
||||
|
||||
- name: Set default systemd target
|
||||
when: _configuration_platform.init_system == 'systemd'
|
||||
vars:
|
||||
_default_target: "{{ 'graphical.target' if system_cfg.features.desktop.enabled | bool else 'multi-user.target' }}"
|
||||
ansible.builtin.command: "{{ chroot_command }} systemctl set-default {{ _default_target }}"
|
||||
register: _set_default_target_result
|
||||
changed_when: _set_default_target_result.rc == 0
|
||||
|
||||
- name: Enable PipeWire user services globally
|
||||
when:
|
||||
@@ -134,8 +170,7 @@
|
||||
- _desktop_dm == 'gdm'
|
||||
- _desktop_autologin_user | length > 0
|
||||
vars:
|
||||
# Debian's gdm3 reads /etc/gdm3/daemon.conf; RedHat/Arch GDM read
|
||||
# /etc/gdm/custom.conf. The keys are identical, only the path differs.
|
||||
# Debian gdm3 reads daemon.conf; RedHat/Arch gdm read custom.conf.
|
||||
_gdm_dir: "/mnt/etc/{{ 'gdm3' if os_family == 'Debian' else 'gdm' }}"
|
||||
_gdm_conf: "{{ 'daemon.conf' if os_family == 'Debian' else 'custom.conf' }}"
|
||||
block:
|
||||
@@ -151,16 +186,20 @@
|
||||
dest: "{{ _gdm_dir }}/{{ _gdm_conf }}"
|
||||
mode: "0644"
|
||||
|
||||
- name: Configure SDDM autologin
|
||||
# SDDM and plasma-login-manager share the [Autologin] format and the KDE Wayland
|
||||
# session; only the config dir differs (sddm.conf.d vs plasmalogin.conf.d).
|
||||
- name: Configure SDDM / plasma-login-manager autologin
|
||||
when:
|
||||
- _configuration_platform.init_system == 'systemd'
|
||||
- system_cfg.features.desktop.enabled | bool
|
||||
- _desktop_dm == 'sddm'
|
||||
- _desktop_dm in ['sddm', 'plasmalogin']
|
||||
- _desktop_autologin_user | length > 0
|
||||
vars:
|
||||
_autologin_conf_dir: "/mnt/etc/{{ 'plasmalogin.conf.d' if _desktop_dm == 'plasmalogin' else 'sddm.conf.d' }}"
|
||||
block:
|
||||
- name: Ensure SDDM config directory exists
|
||||
- name: Ensure KDE login-manager config directory exists
|
||||
ansible.builtin.file:
|
||||
path: /mnt/etc/sddm.conf.d
|
||||
path: "{{ _autologin_conf_dir }}"
|
||||
state: directory
|
||||
mode: "0755"
|
||||
|
||||
@@ -179,8 +218,29 @@
|
||||
{%- set names = _kde_wayland_sessions.files | map(attribute='path') | map('basename') | list -%}
|
||||
{{ 'plasma.desktop' if 'plasma.desktop' in names else (names | first | default('')) }}
|
||||
|
||||
- name: Write SDDM autologin drop-in
|
||||
- name: Write KDE login-manager autologin drop-in
|
||||
ansible.builtin.template:
|
||||
src: sddm-autologin.conf.j2
|
||||
dest: /mnt/etc/sddm.conf.d/10-autologin.conf
|
||||
dest: "{{ _autologin_conf_dir }}/10-autologin.conf"
|
||||
mode: "0644"
|
||||
|
||||
# ly ships a flat (sectionless) config.ini; edit it in place to keep upstream
|
||||
# defaults. Both keys are required: an unresolved session writes 'null', which
|
||||
# disables autologin rather than leaving it half-configured.
|
||||
- name: Configure ly autologin
|
||||
when:
|
||||
- _configuration_platform.init_system == 'systemd'
|
||||
- system_cfg.features.desktop.enabled | bool
|
||||
- _desktop_dm == 'ly'
|
||||
- _desktop_autologin_user | length > 0
|
||||
community.general.ini_file:
|
||||
path: /mnt/etc/ly/config.ini
|
||||
option: "{{ item.key }}"
|
||||
value: "{{ item.value }}"
|
||||
create: false
|
||||
mode: "0644"
|
||||
loop:
|
||||
- key: auto_login_user
|
||||
value: "{{ _desktop_autologin_user }}"
|
||||
- key: auto_login_session
|
||||
value: "{{ _greetd_session if (_greetd_session | length > 0) else 'null' }}"
|
||||
|
||||
@@ -43,9 +43,7 @@ configuration_desktop_dm_map:
|
||||
sway: greetd
|
||||
hyprland: greetd
|
||||
|
||||
# Per-environment session command for greetd-launched compositors (sway/hyprland):
|
||||
# the executable greetd starts. kde/gnome use a display manager (sddm/gdm) whose
|
||||
# Wayland session is resolved separately, so they are not in this map.
|
||||
# greetd session commands for sway/hyprland (gnome/kde use a DM instead).
|
||||
configuration_desktop_session_cmd_map:
|
||||
sway: sway
|
||||
hyprland: Hyprland
|
||||
|
||||
Reference in New Issue
Block a user