mirror of
https://github.com/Nexoniarz/nexoniarz-config-nixos.git
synced 2026-11-03 04:24:27 +00:00
Display Settings: drag-to-arrange multi-monitor canvas with edge snapping (locked when only one screen is connected), 8/10-bit depth, color management presets (sRGB/Wide/EDID/HDR+EDID), SDR brightness/saturation, ICC profile path, VRR toggle. display-set now takes a single pre-built descriptor instead of a fixed positional arg list, since Hyprland's monitor keyword grew well past that. Wallpapers: fixed the current-wallpaper highlight never loading on open, added real first-frame thumbnails for animated wallpapers (wallpaper-thumbs + ffmpeg), bigger 2-column grid, filename filter. Booru: separate downloads folder from Wallpapers so browsing doesn't clutter the wallpaper picker, bigger grid, Safe/Moderate/Explicit rating tiers replacing the old binary toggle, sort order (Newest/ Score/Random). Fixed pagination being completely broken (a Flow anchor violation was silently disabling the whole layout) and Danbooru's Random sort (order:random tag times out server-side -- switched to their random=true endpoint for that case). Wi-Fi panel: added a "Scanning.../No networks found" state and a manual rescan button -- previously showed nothing either way, making "still scanning" indistinguishable from a real failure. Bluetooth: auto-scans on open like Wi-Fi now, instead of requiring a manual click every time. New: System Monitor panel (CPU/RAM/GPU/VRAM/disk usage, NVIDIA or AMD detected automatically) and Weather panel (IP-geolocated or a typed city, current + hourly forecast, Open-Meteo, no API key) with a compact taskbar badge.
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"
|