Allow user to provide a different configuration per host

This commit is contained in:
Oliver Traber 2024-05-27 20:57:26 +02:00
parent 82d5350ded
commit d8113f6228
Signed by: Bluemedia
GPG key ID: C0674B105057136C
10 changed files with 238 additions and 30 deletions

View file

@ -1,3 +0,0 @@
isNotebook: true
isDesktop: false
isVm: false

47
host_vars/kronos Normal file
View file

@ -0,0 +1,47 @@
mobile_platform: false
monitors:
- desc: "LG Electronics LG ULTRAGEAR 311NTZN8J917"
output: "DP-1"
resolution: "2560x1440@120"
position: "1440x1440"
background:
file: "bg1.png"
mode: "fill"
- desc: "LG Electronics LG ULTRAGEAR 311NTVS8J911"
output: "DP-2"
resolution: "2560x1440@120"
position: "1440x0"
background:
file: "bg0.png"
mode: "fill"
- desc: "Acer Technologies KG271U TATEE0048524"
output: "HDMI-A-4"
resolution: "2560x1440@120"
position: "0x320"
transform: 3
background:
file: "bgv0.png"
mode: "fill"
workspaces:
- id: 1
monitor: "LG Electronics LG ULTRAGEAR 311NTZN8J917"
default: true
- id: 2
monitor: "LG Electronics LG ULTRAGEAR 311NTVS8J911"
default: true
- id: 3
monitor: "Acer Technologies KG271U TATEE0048524"
default: true
layoutopt_orientation: "top"
on_created_empty: "flatpak run com.discordapp.Discord & keepassxc"
- id: 9
monitor: "LG Electronics LG ULTRAGEAR 311NTVS8J911"
autostart:
- command: "spotify --enable-features=UseOzonePlatform --ozone-platform=wayland"
workspace: 9
silent: true

26
host_vars/zeus Normal file
View file

@ -0,0 +1,26 @@
mobile_platform: true
monitors:
- desc: "BOE 0x07C9"
output: "eDP-1"
resolution: "1920x1080@60"
background:
file: "bg0.png"
mode: "fill"
workspaces:
- id: 1
monitor: "BOE 0x07C9"
default: true
- id: 8
monitor: "BOE 0x07C9"
- id: 9
monitor: "BOE 0x07C9"
autostart:
- command: "keepassxc"
workspace: 8
silent: true
- command: "spotify --enable-features=UseOzonePlatform --ozone-platform=wayland"
workspace: 9
silent: true

View file

@ -30,6 +30,8 @@
loop:
- src: "{{ role_path }}/files/.config"
dest: "{{ ansible_env.HOME }}/"
- src: "{{ role_path }}/files/.local"
dest: "{{ ansible_env.HOME }}/"
- name: Ensure presence of required directories
file:
@ -39,6 +41,7 @@
loop:
- "{{ ansible_env.HOME }}/.config/hypr"
- "{{ ansible_env.HOME }}/.config/waybar"
- "{{ ansible_env.HOME }}/.local/bin"
- name: Render config files
ansible.builtin.template:
@ -50,4 +53,11 @@
- src: ".config/hypr/hyprland.conf.j2"
dest: "{{ ansible_env.HOME }}/.config/hypr/hyprland.conf"
- src: ".config/waybar/config.j2"
dest: "{{ ansible_env.HOME }}/.config/waybar/config"
dest: "{{ ansible_env.HOME }}/.config/waybar/config"
- src: ".local/bin/hyprhelpr.j2"
dest: "{{ ansible_env.HOME }}/.local/bin/hyprhelpr"
- name: Make "~/.local/bin/hyprhelpr" executable
ansible.builtin.file:
dest: "{{ ansible_env.HOME }}/.local/bin/hyprhelpr"
mode: "og+x"

View file

@ -15,6 +15,8 @@
- build-essential
- cmake
- meson
# hyprland-scanner
- libpugixml-dev
# hyprcursor
- libzip-dev
- librsvg2-dev
@ -22,8 +24,10 @@
# Hyprland
- libpango1.0-dev
- libtomlplusplus-dev
- uuid-dev
# xdg-desktop-portal-hyprland
- qtbase5-dev
#- qtbase5-dev
- qt6-base-dev
- libspa-0.2-dev
- libpipewire-0.3-dev
@ -35,16 +39,25 @@
owner: "{{ ansible_user_id }}"
group: "{{ ansible_user_id }}"
loop:
- "hyprwayland-scanner"
- "Hyprland"
- "hyprlang"
- "hyprcursor"
- "xdg-desktop-portal-hyprland"
- name: Checkout hyprwayland-scanner repo
ansible.builtin.git:
repo: 'https://github.com/hyprwm/hyprwayland-scanner.git'
dest: /usr/local/src/hyprwayland-scanner
version: v0.3.4
force: true
recursive: true
- name: Checkout Hyprland repo
ansible.builtin.git:
repo: 'https://github.com/hyprwm/Hyprland.git'
dest: /usr/local/src/Hyprland
version: v0.39.1
version: v0.40.0
force: true
recursive: true
@ -68,10 +81,24 @@
ansible.builtin.git:
repo: 'https://github.com/hyprwm/xdg-desktop-portal-hyprland.git'
dest: /usr/local/src/xdg-desktop-portal-hyprland
version: v1.3.1
version: master
force: true
recursive: true
- name: Build hyprwayland-scanner
ansible.builtin.command:
cmd: "{{ item }}"
chdir: /usr/local/src/hyprwayland-scanner
loop:
- "cmake -DCMAKE_INSTALL_PREFIX=/usr -B build"
- "cmake --build build"
- name: Install hyprwayland-scanner
become: yes
ansible.builtin.command:
cmd: "cmake --install build"
chdir: /usr/local/src/hyprwayland-scanner
- name: Build hyprlang
ansible.builtin.command:
cmd: "{{ item }}"
@ -134,4 +161,4 @@
- name: Reload systemd
ansible.builtin.systemd_service:
daemon_reload: true
scope: user
scope: user

View file

@ -6,7 +6,9 @@
name:
- swaylock
- swaybg
- swayidle
- waybar
- wofi
- xdg-desktop-portal-wlr
- xdg-desktop-portal-gtk
- xfce4-appfinder

View file

@ -1,23 +1,26 @@
# Monitor configuration (see https://wiki.hyprland.org/Configuring/Monitors/)
monitor=,preferred,auto,auto
{% for monitor in hostvars[ansible_hostname]['monitors'] -%}
monitor=desc:{{ monitor['desc'] }}, {{ monitor['resolution'] }}, {{ monitor['position'] }}, 1
{% endfor %}
# Programs to use
$terminal = flatpak run org.wezfurlong.wezterm
$terminal = flatpak run --nosocket=wayland org.wezfurlong.wezterm
$menu = xfce4-appfinder --disable-server
# Default env vars
env = XCURSOR_SIZE,24
env = QT_QPA_PLATFORMTHEME,qt5ct
env = QT_QPA_PLATFORMTHEME,qt5ct # change to qt6ct if you have that
# For all categories, see https://wiki.hyprland.org/Configuring/Variables/
input {
kb_layout = de
kb_variant = nodeadkeys
numlock_by_default = 1
follow_mouse = 1
follow_mouse = 2
touchpad {
natural_scroll = enabled
natural_scroll = 1
}
sensitivity = 0 # -1.0 - 1.0, 0 means no modification.
@ -34,6 +37,7 @@ general {
layout = master
# Please see https://wiki.hyprland.org/Configuring/Tearing/ before you turn this on
allow_tearing = false
}
@ -86,36 +90,41 @@ misc {
force_default_wallpaper = 0 # Set to 0 or 1 to disable the anime mascot wallpapers
}
# Example windowrule v2
# windowrulev2 = float,class:^(kitty)$,title:^(kitty)$
# See https://wiki.hyprland.org/Configuring/Window-Rules/ for more
windowrulev2 = nomaximizerequest, class:.*
windowrulev2 = suppressevent maximize, class:.*
windowrulev2 = idleinhibit fullscreen, class:.*
windowrulev2 = float,title:^(Application Finder)$
windowrulev2 = size 500 500,title:^(Application Finder)$
# Workspace rules
{% for workspace in hostvars[ansible_hostname]['workspaces'] -%}
workspace = {{ workspace['id'] }}{% if 'monitor' in workspace %}, monitor:desc:{{ workspace['monitor'] }}{% endif %}{% if 'default' in workspace %}, default:{{ workspace['default'] }}{% endif %}{% if 'layoutopt_orientation' in workspace %}, layoutopt:orientation:{{ workspace['layoutopt_orientation'] }}{% endif %}{% if 'on_created_empty' in workspace %}, on-created-empty:{{ workspace['on_created_empty'] }}{% endif %}
{% endfor %}
# Execute apps at launch
exec-once = systemctl --user import-environment DISPLAY WAYLAND_DISPLAY && hash dbus-update-activation-environment 2>/dev/null && dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK
exec-once = waybar
exec-once = swaybg -i ~/.config/background/background.png -m fill
{% if 'spotify' in role_names %}
exec-once = [workspace 9 silent] spotify --enable-features=UseOzonePlatform --ozone-platform=wayland
{% endif %}
exec-once = waybar & ~/.local/bin/hyprhelpr background & ~/.local/bin/hyprhelpr idle
{% if 'nextcloud' in role_names %}
exec-once = nextcloud --background
{% endif %}
{% for autostart in hostvars[ansible_hostname]['autostart'] -%}
exec-once = {% if 'workspace' in autostart %}[workspace {{ autostart['workspace'] }}] {% endif %}{{ autostart['command'] }}
{% endfor %}
# See https://wiki.hyprland.org/Configuring/Keywords/ for more
$mainMod = SUPER
# Keybinds, see https://wiki.hyprland.org/Configuring/Binds/ for more
# Key binds, see https://wiki.hyprland.org/Configuring/Binds/ for more
bind = $mainMod, Return, exec, $terminal
bind = $mainMod, D, exec, $menu
bind = $mainMod SHIFT, Q, killactive,
bind = $mainMod SHIFT, E, exit,
bind = $mainMod, F, fullscreen, 0
bind = $mainMod, V, togglefloating,
bind = $mainMod, L, exec, pa-loopback
#bind = $mainMod, P, pseudo, # dwindle
#bind = $mainMod, J, togglesplit, # dwindle
bind = $mainMod, L, exec, ~/.local/bin/hyprhelpr lock
bind = $mainMod, P, exec, ~/.local/bin/hyprhelpr powermenu
# Move focus with mainMod + arrow keys
bind = $mainMod, left, movefocus, l

View file

@ -28,15 +28,11 @@
"reverse-scrolling": true,
"on-click": "swaymsg exec amixer -q set Master toggle"
},
{% if isNotebook | bool %}
{% if hostvars[ansible_hostname]['mobile_platform'] | bool %}
"battery": {
"format": "{icon} {capacity}%",
"format-charging": " {capacity}%",
"format-icons": ["", "", "", "", ""]
},
{% endif %}
"custom/power":{
"format":"  ",
"on-click":"swaynag -t warning -m 'Power Menu Options' -b 'Logout' 'swaymsg exit' -b 'Lock' 'swaymsg exec swaylock -f' -b 'Suspend' 'swaymsg exec sudo systemctl suspend && swaylock -f' -b 'Reboot' 'swaymsg exec sudo systemctl reboot' -b 'Shutdown' 'swaymsg exec sudo systemctl poweroff'"
}
{% endif %}
}

View file

@ -0,0 +1,94 @@
#!/bin/bash
set -eu
background() {
swaybg \
{% for monitor in hostvars[ansible_hostname]['monitors'] -%}
-o "{{ monitor['desc'] }}" -i ~/.config/background/{{ monitor['background']['file'] }} -m {{ monitor['background']['mode'] }} {%- if not loop.last %}\{% endif %}
{% endfor %}
}
idle() {
swayidle -w \
timeout 180 '~/.local/bin/hyprhelpr lock' \
timeout 240 'hyprctl dispatch dpms off' \
resume 'hyprctl dispatch dpms on'
}
lock() {
if pgrep -x "swaylock" >/dev/null
then
echo "A instance of swaylock is already running."
exit 1
else
swaylock -f -e -s fill --indicator-radius 150 \
{% for monitor in hostvars[ansible_hostname]['monitors'] -%}
-i {{ monitor['output'] }}:~/.config/background/lock-{{ monitor['background']['file'] }} {%- if not loop.last %}\{% endif %}
{% endfor %}
fi
}
shutdown() {
sudo systemctl poweroff
}
reboot() {
sudo systemctl reboot
}
powermenu() {
PM_ACTION=$(printf "Shutdown\nReboot\nLock\nLogoff" | wofi --show=dmenu -i --width 200 --height 150)
if [ -n "$PM_ACTION" ]; then
case $PM_ACTION in
Shutdown)
shutdown
;;
Reboot)
reboot
;;
Lock)
lock
;;
Logoff)
hyprctl dispatch exit
;;
esac
fi
}
ACTION=$1
case $ACTION in
background)
background
;;
idle)
idle
;;
lock)
lock
;;
shutdown)
shutdown
;;
reboot)
reboot
;;
powermenu)
powermenu
;;
help | -h | --help)
echo "Usage: hyprhelpr <action> [parameters]"
echo "Available actions:"
echo " background Start swaybg with the configured backgrounds."
echo " idle Start swayidle with the configured actions."
echo " lock Lock the current session using swaylock."
echo " shutdown Shut down the system."
echo " reboot Reboot the system."
echo " powermenu Show wofi in dmenu mode with different power options"
echo " help Show this help text."
;;
*)
echo "Invalid action \"$ACTION\"."' Use "hyprhelpr help" to get help.'
exit 1
esac

View file

@ -15,7 +15,7 @@ export GPG_TTY=$(tty)
# Autostart Hyprland at login
if [[ -z $DISPLAY ]] && [[ $(tty) = /dev/tty1 ]]; then
{% if isVm | bool %}
{% if hostvars[ansible_hostname]['virtual_machine'] | bool %}
export WLR_NO_HARDWARE_CURSORS=1
{% endif %}
exec Hyprland