mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-06-25 11:45:32 +02:00
Compare commits
3 Commits
b98f032141
...
fa10fe558d
Author | SHA1 | Date | |
---|---|---|---|
fa10fe558d | |||
b1d8e21772 | |||
cf823c0061 |
@ -4,3 +4,9 @@
|
||||
name:
|
||||
- gnome-terminal
|
||||
state: present
|
||||
|
||||
- name: "Set zsh as default shell for {{users.client.username}}"
|
||||
user:
|
||||
name: "{{users.client.username}}"
|
||||
shell: /usr/bin/zsh
|
||||
become: true
|
@ -27,3 +27,4 @@ galaxy_info:
|
||||
|
||||
dependencies:
|
||||
- client-git
|
||||
- shell
|
@ -35,21 +35,12 @@
|
||||
daemon_reload: true
|
||||
become: false
|
||||
|
||||
- name: Set SSH_AUTH_SOCK in bash_profile or profile
|
||||
block:
|
||||
- name: Choose profile file
|
||||
set_fact:
|
||||
profile_file: "$HOME/.bash_profile"
|
||||
when: ansible_facts.env.HOME is defined and lookup('file', ansible_env.HOME + '/.bash_profile', errors='ignore') is defined
|
||||
|
||||
- name: Fallback to .profile if .bash_profile not found
|
||||
set_fact:
|
||||
profile_file: "$HOME/.profile"
|
||||
when: profile_file is not defined
|
||||
|
||||
- name: Ensure SSH_AUTH_SOCK is set in profile
|
||||
- name: Ensure ~/.profile exists with common environment
|
||||
lineinfile:
|
||||
path: "{{ profile_file }}"
|
||||
path: "$HOME/.profile"
|
||||
line: 'export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent.socket"'
|
||||
insertafter: EOF
|
||||
state: present
|
||||
create: yes
|
||||
mode: "0644"
|
||||
become: false
|
@ -1,3 +1,38 @@
|
||||
https://chatgpt.com/share/67ed14d0-4220-800f-a592-82513553fb97
|
||||
https://chatgpt.com/share/67ed1520-8a54-800f-98a5-12372413994a
|
||||
https://chatgpt.com/share/67ed158b-66d4-800f-b418-e52460c225ce
|
||||
# Driver Lid Switch 🛑💻
|
||||
|
||||
## Description
|
||||
|
||||
This Ansible role configures lid switch behavior on Linux systems where the default behavior does not work correctly—particularly on laptops like the HP Spectre x360 14-ef2777ng running Manjaro Linux, Wayland, and GNOME. By default, closing the lid can trigger hibernation or suspend incorrectly, even while docked or on external power.
|
||||
|
||||
This role integrates [`setup-hibernate`](https://github.com/kevinveenbirkenbach/setup-hibernate) to configure hibernation support and sets systemd rules to define proper lid switch behavior based on power state.
|
||||
|
||||
## Overview
|
||||
|
||||
This role addresses a common issue on Linux laptops: closing the lid while docked or plugged in leads to unintended sleep or hibernation. It installs the necessary hibernation tools and updates `/etc/systemd/logind.conf` to:
|
||||
|
||||
- Hibernate on lid close when on battery
|
||||
- Lock the session when on AC power or docked
|
||||
|
||||
## Purpose
|
||||
|
||||
The purpose of this role is to enforce a consistent and predictable lid switch behavior across power states, improving usability on laptops that otherwise behave unpredictably when the lid is closed.
|
||||
|
||||
## Features
|
||||
|
||||
- **Installs `setup-hibernate`:** Uses `pkgmgr` to install and initialize hibernation support.
|
||||
- **Systemd Integration:** Applies proper `logind.conf` settings for lid switch handling.
|
||||
- **Power-aware Configuration:** Differentiates between battery, AC power, and docked state.
|
||||
- **Idempotent Design:** Ensures safe re-runs and minimal unnecessary restarts.
|
||||
|
||||
## More Ressources
|
||||
- https://chatgpt.com/share/67ed14d0-4220-800f-a592-82513553fb97
|
||||
- https://chatgpt.com/share/67ed1520-8a54-800f-98a5-12372413994a
|
||||
- https://chatgpt.com/share/67ed158b-66d4-800f-b418-e52460c225ce
|
||||
|
||||
## Credits 📝
|
||||
|
||||
Developed and maintained by **Kevin Veen-Birkenbach**.
|
||||
Learn more at [www.veen.world](https://www.veen.world)
|
||||
|
||||
Part of the [CyMaIS Project](https://github.com/kevinveenbirkenbach/cymais)
|
||||
License: [CyMaIS NonCommercial License (CNCL)](https://s.veen.world/cncl)
|
27
roles/driver-lid-switch/meta/main.yml
Normal file
27
roles/driver-lid-switch/meta/main.yml
Normal file
@ -0,0 +1,27 @@
|
||||
---
|
||||
galaxy_info:
|
||||
author: "Kevin Veen-Birkenbach"
|
||||
description: "Fixes incorrect lid switch behavior on Linux laptops by setting up hibernation and configuring systemd."
|
||||
license: "CyMaIS NonCommercial License (CNCL)"
|
||||
license_url: "https://s.veen.world/cncl"
|
||||
company: |
|
||||
Kevin Veen-Birkenbach
|
||||
Consulting & Coaching Solutions
|
||||
https://www.veen.world
|
||||
min_ansible_version: "2.9"
|
||||
platforms:
|
||||
- name: Archlinux
|
||||
versions:
|
||||
- rolling
|
||||
galaxy_tags:
|
||||
- lid
|
||||
- laptop
|
||||
- power
|
||||
- hibernate
|
||||
- systemd
|
||||
- archlinux
|
||||
repository: https://s.veen.world/cymais
|
||||
issue_tracker_url: https://s.veen.world/cymaisissues
|
||||
documentation: https://s.veen.world/cymais
|
||||
dependencies:
|
||||
- role: package-manager
|
@ -1,5 +1,14 @@
|
||||
---
|
||||
- name: Set HandleLidSwitch to hibernate in /etc/systemd/logind.conf
|
||||
- name: install setup-hibernate
|
||||
command:
|
||||
cmd: "pkgmgr install setup-hibernate --clone-mode https"
|
||||
become: true
|
||||
|
||||
- name: Setup hibernate
|
||||
command: setup-hibernate --non-interactive
|
||||
become: true
|
||||
|
||||
- name: Configure systemd lid switch behavior to hibernate on lid close (battery), lock on AC and docked
|
||||
become: yes
|
||||
lineinfile:
|
||||
path: /etc/systemd/logind.conf
|
||||
@ -7,3 +16,24 @@
|
||||
line: 'HandleLidSwitch=hibernate'
|
||||
backup: yes
|
||||
notify: Restart systemd-logind
|
||||
become: true
|
||||
|
||||
- name: Configure systemd to lock session when lid is closed on external power
|
||||
become: yes
|
||||
lineinfile:
|
||||
path: /etc/systemd/logind.conf
|
||||
regexp: '^#?HandleLidSwitchExternalPower='
|
||||
line: 'HandleLidSwitchExternalPower=lock'
|
||||
backup: yes
|
||||
notify: Restart systemd-logind
|
||||
become: true
|
||||
|
||||
- name: Configure systemd to lock session when lid is closed while docked
|
||||
become: yes
|
||||
lineinfile:
|
||||
path: /etc/systemd/logind.conf
|
||||
regexp: '^#?HandleLidSwitchDocked='
|
||||
line: 'HandleLidSwitchDocked=lock'
|
||||
backup: yes
|
||||
notify: Restart systemd-logind
|
||||
become: true
|
@ -10,6 +10,5 @@
|
||||
- wine-gecko
|
||||
- wine-mono
|
||||
- winetricks
|
||||
- lib32-wine
|
||||
state: present
|
||||
update_cache: yes
|
||||
|
27
roles/shell/README.md
Normal file
27
roles/shell/README.md
Normal file
@ -0,0 +1,27 @@
|
||||
# Shell 🐚
|
||||
|
||||
## Description
|
||||
|
||||
This Ansible role ensures that [.profile](https://en.wikipedia.org/wiki/Bourne_shell#Startup_scripts) is sourced in both [Bash](https://www.gnu.org/software/bash/) and [Zsh](https://www.zsh.org/) environments. It enables consistent environment variable loading across different login shells by linking shell-specific profile files (`.bash_profile`, `.zprofile`) to a centralized `.profile`.
|
||||
|
||||
## Overview
|
||||
|
||||
By standardizing `.profile` as the central source for environment configuration, this role ensures consistent shell behavior. It does **not** manage the contents of `.profile` itself — only guarantees that it is sourced by supported shells.
|
||||
|
||||
## Purpose
|
||||
|
||||
The purpose of this role is to unify shell environment setup across Bash and Zsh. It minimizes duplication and confusion by encouraging the use of `.profile` for shared configuration such as environment variables and agent settings.
|
||||
|
||||
## Features
|
||||
|
||||
- **Centralized Configuration:** Promotes `.profile` as the single source for shared shell settings.
|
||||
- **Cross-Shell Compatibility:** Ensures both Bash and Zsh source `.profile` properly.
|
||||
- **Non-Invasive:** Does not alter the content of `.profile`.
|
||||
|
||||
## Credits 📝
|
||||
|
||||
Developed and maintained by **Kevin Veen-Birkenbach**.
|
||||
Learn more at [www.veen.world](https://www.veen.world)
|
||||
|
||||
Part of the [CyMaIS Project](https://github.com/kevinveenbirkenbach/cymais)
|
||||
License: [CyMaIS NonCommercial License (CNCL)](https://s.veen.world/cncl)
|
32
roles/shell/meta/main.yml
Normal file
32
roles/shell/meta/main.yml
Normal file
@ -0,0 +1,32 @@
|
||||
---
|
||||
galaxy_info:
|
||||
author: "Kevin Veen-Birkenbach"
|
||||
description: "Ensures that .profile is sourced in all shells."
|
||||
license: "CyMaIS NonCommercial License (CNCL)"
|
||||
license_url: "https://s.veen.world/cncl"
|
||||
company: |
|
||||
Kevin Veen-Birkenbach
|
||||
Consulting & Coaching Solutions
|
||||
https://www.veen.world
|
||||
min_ansible_version: "2.9"
|
||||
platforms:
|
||||
- name: Archlinux
|
||||
versions:
|
||||
- rolling
|
||||
- name: Debian
|
||||
versions:
|
||||
- all
|
||||
- name: Ubuntu
|
||||
versions:
|
||||
- all
|
||||
galaxy_tags:
|
||||
- shell
|
||||
- bash
|
||||
- zsh
|
||||
- environment
|
||||
- profile
|
||||
- dotfiles
|
||||
repository: https://s.veen.world/cymais
|
||||
issue_tracker_url: https://s.veen.world/cymaisissues
|
||||
documentation: https://s.veen.world/cymais
|
||||
dependencies: []
|
20
roles/shell/tasks/main.yml
Normal file
20
roles/shell/tasks/main.yml
Normal file
@ -0,0 +1,20 @@
|
||||
---
|
||||
- name: Ensure ~/.bash_profile sources ~/.profile
|
||||
lineinfile:
|
||||
path: "$HOME/.bash_profile"
|
||||
line: '[ -f ~/.profile ] && . ~/.profile'
|
||||
insertafter: EOF
|
||||
state: present
|
||||
create: yes
|
||||
mode: "0644"
|
||||
become: false
|
||||
|
||||
- name: Ensure ~/.zprofile sources ~/.profile
|
||||
lineinfile:
|
||||
path: "$HOME/.zprofile"
|
||||
line: '[ -f ~/.profile ] && . ~/.profile'
|
||||
insertafter: EOF
|
||||
state: present
|
||||
create: yes
|
||||
mode: "0644"
|
||||
become: false
|
@ -84,6 +84,8 @@
|
||||
include_role:
|
||||
name: client-wireguard
|
||||
|
||||
|
||||
|
||||
## backup setup
|
||||
- name: setup replica backup hosts
|
||||
when: ("backup_remote_to_local" in group_names)
|
||||
@ -106,6 +108,12 @@
|
||||
include_role:
|
||||
name: driver-epson-multiprinter
|
||||
|
||||
|
||||
- name: setup hibernate lid switch
|
||||
when: ("driver-lid-switch" in group_names)
|
||||
include_role:
|
||||
name: driver-lid-switch
|
||||
|
||||
## system setup
|
||||
- name: setup swapfile hosts
|
||||
when: ("swapfile" in group_names)
|
||||
|
Loading…
x
Reference in New Issue
Block a user