mirror of
https://github.com/Nexoniarz/nexoniarz-config-nixos.git
synced 2026-11-03 04:24:27 +00:00
nixos config
This commit is contained in:
commit
5dc9fb020e
46 changed files with 6194 additions and 0 deletions
37
modules/scripts/display-set.sh
Normal file
37
modules/scripts/display-set.sh
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
#!/usr/bin/env bash
|
||||
# Applies a monitor mode/position/scale/transform immediately (hyprctl)
|
||||
# AND persists it into ~/.config/hypr/display.conf, which hyprland.conf
|
||||
# sources — without that file, hyprland.conf's generic fallback rule
|
||||
# ("monitor = , preferred, auto, 1") is the only thing on record, and
|
||||
# ANYTHING that makes Hyprland re-evaluate monitor state (observed: even
|
||||
# changing the cursor theme via `hyprctl setcursor` does this) reapplies
|
||||
# that fallback, silently dropping back to "preferred" refresh rate
|
||||
# instead of whatever the user actually picked.
|
||||
set -euo pipefail
|
||||
|
||||
mon="${1:?usage: display-set <monitor> <mode> <x> <y> <scale> [transform]}"
|
||||
mode="${2:?mode required}"
|
||||
x="${3:?x required}"
|
||||
y="${4:?y required}"
|
||||
scale="${5:?scale required}"
|
||||
transform="${6:-0}"
|
||||
|
||||
descriptor="$mon,$mode,${x}x${y},$scale"
|
||||
[ "$transform" != "0" ] && descriptor="$descriptor,transform,$transform"
|
||||
|
||||
conf="$HOME/.config/hypr/display.conf"
|
||||
mkdir -p "$(dirname "$conf")"
|
||||
touch "$conf"
|
||||
|
||||
line="monitor = $descriptor"
|
||||
if grep -q "^monitor = $mon," "$conf" 2>/dev/null; then
|
||||
tmp=$(mktemp)
|
||||
awk -v prefix="monitor = $mon," -v newline="$line" '
|
||||
index($0, prefix) == 1 { print newline; next } { print }
|
||||
' "$conf" > "$tmp"
|
||||
mv "$tmp" "$conf"
|
||||
else
|
||||
echo "$line" >> "$conf"
|
||||
fi
|
||||
|
||||
hyprctl keyword monitor "$descriptor" > /dev/null
|
||||
Loading…
Reference in a new issue