Fix monitor primary and flake update

This commit is contained in:
ltadeu6 2026-04-26 16:30:08 -03:00
parent 8894fa949c
commit 168ecf2743
2 changed files with 13 additions and 10 deletions

View file

@ -26,7 +26,7 @@ monitor = $SIDE,1920x1080@60,-1400x-1080,1
# Autostart
exec-once = waybar & hyprpaper & dbus-launch kdeconnect-indicator
exec-once = /run/current-system/sw/bin/antimicrox --tray --hidden --eventgen uinput --profile /etc/antimicrox/controller-mouse.amgp
exec-once = sh -lc 'sleep 5; for _ in $(seq 1 10); do out="$(hyprctl monitors -j | jq -r ''.[] | select(.description == \"LG Electronics LG ULTRAWIDE 512AZWSDD473\") | .name'' | head -n1)"; [ -n "$out" ] && xrandr --output "$out" --primary --auto >/dev/null 2>&1 && exit 0; sleep 2; done'
exec-once = sh -lc 'sleep 5; for _ in $(seq 1 10); do out="$(/run/current-system/sw/bin/hyprctl monitors | /run/current-system/sw/bin/awk ''/^Monitor / { name=$2 } /description: LG Electronics LG ULTRAWIDE 512AZWSDD473/ { print name; exit }'')"; [ -z "$out" ] && sleep 2 && continue; /run/current-system/sw/bin/xrandr --query | /run/current-system/sw/bin/grep -q "^$out connected primary " && exit 0; /run/current-system/sw/bin/xrandr --output "$out" --primary --auto >/dev/null 2>&1 && exit 0; sleep 2; done'
# Source a file (multi-file configs)
# source = ~/.config/hypr/myColors.conf

View file

@ -6,6 +6,7 @@
let
username = "ltadeu6";
homeDir = "/home/${username}";
repoDir = "${homeDir}/Projetos/Sistemas/nixos-config";
codexStatusPath = "/var/lib/hass/codex_status.json";
zenExtension = shortId: guid: {
name = guid;
@ -827,17 +828,15 @@ in {
systemd.services."nix-flake-update" = {
description = "Update flake.lock, commit, and rebuild";
path = [
pkgs.findutils
pkgs.git
pkgs.gnugrep
pkgs.gnused
pkgs.nixos-rebuild
pkgs.nix
pkgs.coreutils
pkgs.util-linux
];
serviceConfig = {
Type = "oneshot";
User = username;
Environment = [
"HOME=${homeDir}"
"GIT_AUTHOR_NAME=auto-upgrade"
@ -848,15 +847,19 @@ in {
};
script = ''
set -euo pipefail
export PATH="${pkgs.git}/bin:${pkgs.nix}/bin:/run/current-system/sw/bin"
export PATH="${pkgs.git}/bin:${pkgs.nix}/bin:${pkgs.util-linux}/bin:/run/current-system/sw/bin"
repo_dir="$(${pkgs.findutils}/bin/find "$HOME" -path '*/hosts/Nixos/configuration.nix' -print -quit | ${pkgs.gnused}/bin/sed 's#/hosts/Nixos/configuration\.nix##')"
if [ -z "$repo_dir" ]; then
echo "Skipping flake update: could not locate repo under $HOME"
run_as_user() {
/run/current-system/sw/bin/runuser -u ${username} -- "$@"
}
repo_dir="${repoDir}"
if [ ! -d "$repo_dir/.git" ] || [ ! -f "$repo_dir/hosts/Nixos/configuration.nix" ]; then
echo "Skipping flake update: repository not found at $repo_dir"
exit 0
fi
repo_status="$(git -C "$repo_dir" status --porcelain=v1 --untracked-files=normal)"
repo_status="$(run_as_user git -C "$repo_dir" status --porcelain=v1 --untracked-files=normal)"
relevant_status="$(printf '%s\n' "$repo_status" | ${pkgs.gnugrep}/bin/grep -vE '^[ MARCUD?!]{2} flake\.lock$' || true)"
if [ -n "$relevant_status" ]; then
echo "Skipping flake update: repository has local changes"
@ -877,7 +880,7 @@ in {
rm -f "$repo_dir/flake.lock"
fi
/run/current-system/sw/bin/nix flake update --commit-lock-file "$repo_dir"
run_as_user /run/current-system/sw/bin/nix flake update --commit-lock-file "$repo_dir"
/run/current-system/sw/bin/nixos-rebuild switch --flake "$repo_dir#Nixos"
if [ -n "$backup" ] && [ -f "$backup" ]; then