---
#########
# Login Benutzer
- name: Erzeuge login Benutzer laptop
  user:
    name: laptop
    password: '$6$mIpgV5pylqiYinr5$n9GQvQvY2SqY9bIZr1UPxFWaCHhLDyfy7/QaFNUFscFK.Pd.DcOmne.WUelGvKbRLEYInEiMYzxMK.hIIVAVc1'
    groups: 
      - sudo
      - dialout
    state: present
    shell: /bin/bash
    system: no
    createhome: yes
    home: /home/laptop 

- name: Remove qgm-login.sh 
  ansible.builtin.file:
    path: /etc/profile.d/qgm-login.sh
    state: absent

#########
# Softwareauswahl
- name: Install packages for laptops
  apt:
    name:
      - firmware-iwlwifi
    autoremove: true
    state: latest
  environment:
    http_proxy: '' 

#########
# Anpassungen an KDE
# - Doppelklick zum öffnen von Dateien
# - Style auf breeze fetstackern
# - Kein Benutzerwechsel
# - Kein Lockscreen
# - Keine neue Session

- name: Set mandatory KDE settings for laptops
  ansible.builtin.copy: 
    dest: /etc/xdg/kdeglobals
    content: |
      [KDE][$i]
      SingleClick=false
      widgetStyle=breeze

      [KDE Action Restrictions][$i]
      action/switch_user=false
      action/start_new_session=false
      
#########
# Screen Locking ermöglichen
- name: Enable screen locking
  ansible.builtin.file:
    path: /etc/xdg/kscreenlockerrc
    state: absent

#########
# plasma-discover installieren
- name: Install plasma-discover
  ansible.builtin.apt:
    name: plasma-discover
    state: latest

- name: Remove suspend config
  file: 
    path: /etc/systemd/sleep.conf.d/nosuspend.conf
    state: absent

- name: Allow suspend
  blockinfile:
    path: /etc/systemd/sleep.conf.d/nosuspend.conf
    create: true
    block: |
      [Sleep]
      AllowSuspend=yes
      AllowHibernation=no
      AllowSuspendThenHibernate=no
      AllowHybridSleep=no

- name: Change label on login screen
  replace:
    path: /usr/share/sddm/themes/qgm-sugar-dark/theme.conf
    regexp: 'Anmelden am Netzwerk'
    replace: "Lokal anmelden am Laptop"

- name: Disable ansible user login
  ansible.builtin.user:
    name: ansible
    password_lock: True

- name: disable sshd
  systemd:
    name: ssh
    state: started
    enabled: no

