---
- name: Install xcape
  become: true
  package:
    name: xcape
    state: installed
  when: only_config is not defined

- name: Map capslock to ctrl and escape in Xorg
  lineinfile:
    path: "{{ ansible.HOME }}/.xprofile"
    line: "{{ item }}"
  with_items:
    - "xcape -e 'Caps_Lock=Escape'             # Map Caps-Lock to Escape"
    - "setxkbmap us -variant mac               # US Keyboard layout with German letters"
    - "setxkbmap -option 'caps:ctrl_modifier'  # Map Caps-Lock-modifier to Ctrl"
  when: ansible_os_family != "NixOS"

---
- name: Install xcape
  become: true
  package:
    name: xcape
    state: installed
  when: only_config is not defined

- name: Map capslock to ctrl and escape in Xorg
  lineinfile:
    path: "{{ ansible.HOME }}/.xprofile"
    line: "{{ item }}"
  with_items:
    - "xcape -e 'Caps_Lock=Escape'             # Map Caps-Lock to Escape"
    - "setxkbmap us -variant mac               # US Keyboard layout with German letters"
    - "setxkbmap -option 'caps:ctrl_modifier'  # Map Caps-Lock-modifier to Ctrl"

Configure local xprofile even on NixOS
xcape: Configure local xprofile even on NixOS
