From 45ad579120f1785bffc73a6d64a95430113fc707 Mon Sep 17 00:00:00 2001 From: Jane Alesi Date: Wed, 20 May 2026 10:49:07 +0200 Subject: [PATCH] feat: configure systemd power management and fix kitty TERM Co-authored-by: Junie --- ansible/roles/common/handlers/main.yml | 7 ++++ ansible/roles/common/tasks/main.yml | 43 +++++++++++++++++++++++++ ansible/roles/dev-tools/tasks/main.yml | 44 ++++++++++++++++++++++++++ 3 files changed, 94 insertions(+) diff --git a/ansible/roles/common/handlers/main.yml b/ansible/roles/common/handlers/main.yml index 71e1b86..5629169 100644 --- a/ansible/roles/common/handlers/main.yml +++ b/ansible/roles/common/handlers/main.yml @@ -11,6 +11,13 @@ become: yes tags: [systemd, oomd] +- name: Restart systemd-logind + systemd: + name: systemd-logind + state: restarted + become: yes + tags: [systemd] + - name: Reload systemd systemd: daemon_reload: yes diff --git a/ansible/roles/common/tasks/main.yml b/ansible/roles/common/tasks/main.yml index 1346475..2824daa 100644 --- a/ansible/roles/common/tasks/main.yml +++ b/ansible/roles/common/tasks/main.yml @@ -120,6 +120,49 @@ become: yes tags: [systemd, optimization] +- name: Ensure systemd drop-in directories exist + file: + path: "{{ item }}" + state: directory + owner: root + group: root + mode: '0755' + with_items: + - /etc/systemd/logind.conf.d + - /etc/systemd/sleep.conf.d + become: yes + tags: [systemd, power] + +- name: Configure systemd-logind to prevent sleep on keys/lid + copy: + dest: /etc/systemd/logind.conf.d/prevent-sleep.conf + content: | + [Login] + HandleSuspendKey=ignore + HandleHibernateKey=ignore + HandleLidSwitch=ignore + owner: root + group: root + mode: '0644' + become: yes + notify: Restart systemd-logind + tags: [systemd, power] + +- name: Configure systemd-sleep to disable sleep/hibernation + copy: + dest: /etc/systemd/sleep.conf.d/prevent-sleep.conf + content: | + [Sleep] + AllowSuspend=no + AllowHibernation=no + AllowSuspendThenHibernate=no + AllowHybridSleep=no + owner: root + group: root + mode: '0644' + become: yes + tags: [systemd, power] + - name: Ensure systemd directories exist file: path: "{{ item }}" diff --git a/ansible/roles/dev-tools/tasks/main.yml b/ansible/roles/dev-tools/tasks/main.yml index 6c0b4e2..48f06b8 100644 --- a/ansible/roles/dev-tools/tasks/main.yml +++ b/ansible/roles/dev-tools/tasks/main.yml @@ -125,3 +125,47 @@ group: "{{ system_user }}" mode: '0644' tags: [chrome, webgpu] + +- name: Fix kitty cursor keys by removing TERM override in .bashrc + ansible.builtin.lineinfile: + path: "/home/{{ system_user }}/.bashrc" + regexp: '^export TERM=xterm-256color' + line: '# export TERM=xterm-256color # Fix: allow kitty to set its own TERM for cursor keys' + state: present + become: yes + become_user: "{{ system_user }}" + tags: [kitty, shell] + +- name: Ensure kitty configuration directory exists + ansible.builtin.file: + path: "/home/{{ system_user }}/.config/kitty" + state: directory + owner: "{{ system_user }}" + group: "{{ system_user }}" + mode: '0755' + become: yes + become_user: "{{ system_user }}" + tags: [kitty] + +- name: Configure kitty for proper terminal behavior + ansible.builtin.copy: + dest: "/home/{{ system_user }}/.config/kitty/kitty.conf" + content: | + # Managed by Ansible - saTway DevOps + shell bash + editor vim + + # Shell integration is enabled by default in kitty 0.24.0+ + # but we can explicitly enable it for clarity. + shell_integration enabled + + # Ensure cursor keys work correctly by not overriding TERM in shell + # (Handled via .bashrc fix) + + include /home/mw/.config/kitty/kitty-cline-keybindings.conf + owner: "{{ system_user }}" + group: "{{ system_user }}" + mode: '0644' + become: yes + become_user: "{{ system_user }}" + tags: [kitty]