mirror of
https://github.com/Nexoniarz/nexoniarz-config-nixos-laptop.git
synced 2026-11-03 04:24:27 +00:00
Configures Pantheon (LightDM + gala) for daily use on this ASUS TUF Gaming A15 (FA507NU), and drops everything that only existed to serve the previous Hyprland/Quickshell setup: - desktop.nix: services.desktopManager.pantheon instead of programs.hyprland + greetd; comfy laptop touchpad defaults. - drivers.nix: NVIDIA PRIME render offload between the AMD Radeon 680M (drives the panel) and the RTX 4050 Max-Q (offload-only), using this machine's real PCI bus IDs; asusd/supergfxd for ASUS-specific laptop control. - apps.nix / scripts.nix: removed Hyprland/Quickshell-only packages and scripts (kitty, rofi, quickshell, mako, hyprlock, hyprpaper/mpvpaper, the Quickshell theme-picker scripts, cursor/wallpaper/display helpers) — Pantheon ships its own Files/Terminal/Screenshot/ notifications/theming natively. Kept the DE-agnostic scripts (vault toggle, metadata stripping, brightness control, Wi-Fi hotspot, telemetry, weather). - theme.nix and default-apps.nix deleted entirely — Pantheon owns GTK/icon theming itself, no more live dconf/CSS generation pipeline needed. - Deleted hyprland/ and dotfiles/ (kitty, mako, quickshell, rofi). Verified with `nixos-rebuild build`. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RpiovBQL6k5MTDMN3Ln9nL
62 lines
3 KiB
Shell
Executable file
62 lines
3 KiB
Shell
Executable file
#!/usr/bin/env bash
|
|
# Single-shot system telemetry snapshot — CPU/RAM/GPU/VRAM/disk usage — as
|
|
# one JSON object, so the Quickshell System panel can poll this on a Timer
|
|
# instead of spawning half a dozen separate processes every tick.
|
|
set -euo pipefail
|
|
|
|
# --- CPU ---
|
|
# /proc/stat's first line ("cpu ...") is cumulative jiffies since boot —
|
|
# computing instantaneous usage needs two samples across a short gap, so
|
|
# both reads happen inside this one invocation rather than needing
|
|
# cross-poll state kept on the QML side.
|
|
read_cpu() {
|
|
read -r _ user nice system idle iowait irq softirq steal _ < /proc/stat
|
|
echo "$((user + nice + system + irq + softirq + steal)) $((user + nice + system + idle + iowait + irq + softirq + steal))"
|
|
}
|
|
read -r cpu_busy1 cpu_total1 <<< "$(read_cpu)"
|
|
sleep 0.2
|
|
read -r cpu_busy2 cpu_total2 <<< "$(read_cpu)"
|
|
cpu_busy_delta=$((cpu_busy2 - cpu_busy1))
|
|
cpu_total_delta=$((cpu_total2 - cpu_total1))
|
|
cpu_pct=0
|
|
[ "$cpu_total_delta" -gt 0 ] && cpu_pct=$((100 * cpu_busy_delta / cpu_total_delta))
|
|
|
|
# --- RAM ---
|
|
mem_total_kb=$(awk '/^MemTotal:/{print $2}' /proc/meminfo)
|
|
mem_avail_kb=$(awk '/^MemAvailable:/{print $2}' /proc/meminfo)
|
|
mem_used_kb=$((mem_total_kb - mem_avail_kb))
|
|
|
|
# --- GPU / VRAM ---
|
|
# NVIDIA checked first via nvidia-smi (works regardless of which DRM card
|
|
# index the driver landed on); AMD falls back to the card0 sysfs counters
|
|
# directly — whichever's actually present decides which branch fires, so
|
|
# this works unmodified on either machine.
|
|
gpu_pct=-1
|
|
vram_used_mb=-1
|
|
vram_total_mb=-1
|
|
if command -v nvidia-smi > /dev/null 2>&1 && nvidia-smi -L > /dev/null 2>&1; then
|
|
nv_out="$(nvidia-smi --query-gpu=utilization.gpu,memory.used,memory.total --format=csv,noheader,nounits -i 0 2>/dev/null | tr -d ' ')"
|
|
IFS=',' read -r gpu_pct vram_used_mb vram_total_mb <<< "$nv_out"
|
|
elif [ -e /sys/class/drm/card0/device/gpu_busy_percent ]; then
|
|
gpu_pct="$(cat /sys/class/drm/card0/device/gpu_busy_percent 2>/dev/null || echo -1)"
|
|
if [ -e /sys/class/drm/card0/device/mem_info_vram_used ]; then
|
|
vram_used_mb=$(($(cat /sys/class/drm/card0/device/mem_info_vram_used) / 1024 / 1024))
|
|
vram_total_mb=$(($(cat /sys/class/drm/card0/device/mem_info_vram_total) / 1024 / 1024))
|
|
fi
|
|
fi
|
|
|
|
# --- Disks (root + home) ---
|
|
# Positional ($NF for mountpoint), not header-text matching — `df -h`'s
|
|
# header is locale-translated (verified live: "System plików"/"%uż." under
|
|
# this machine's pl_PL locale, not "Filesystem"/"Use%"), so matching on
|
|
# English header text would silently find nothing.
|
|
disks_json="$(df -h 2>/dev/null | awk '
|
|
NR == 1 { next }
|
|
$NF == "/" || $NF == "/home" {
|
|
gsub(/%/, "", $5)
|
|
printf "%s{\"mount\":\"%s\",\"size\":\"%s\",\"used\":\"%s\",\"avail\":\"%s\",\"pct\":\"%s\"}", (n++ ? "," : ""), $NF, $2, $3, $4, $5
|
|
}
|
|
')"
|
|
|
|
printf '{"cpuPct":%s,"memUsedKb":%s,"memTotalKb":%s,"gpuPct":%s,"vramUsedMb":%s,"vramTotalMb":%s,"disks":[%s]}\n' \
|
|
"$cpu_pct" "$mem_used_kb" "$mem_total_kb" "$gpu_pct" "$vram_used_mb" "$vram_total_mb" "$disks_json"
|