mirror of
https://github.com/Nexoniarz/nexoniarz-config-nixos.git
synced 2026-11-03 04:24:27 +00:00
Redesign Display Settings, Wallpapers, Booru; add System Monitor, Weather
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.
This commit is contained in:
parent
d1ff0a11e0
commit
aa89dd729c
10 changed files with 1729 additions and 114 deletions
|
|
@ -1,23 +1,27 @@
|
|||
#!/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
|
||||
# Applies a full monitor descriptor 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.
|
||||
#
|
||||
# Takes the monitor name and everything after it as one pre-built
|
||||
# descriptor string (mode,position,scale + optional transform/bitdepth/
|
||||
# cm/sdrbrightness/sdrsaturation/vrr/icc keyword,value pairs) rather than
|
||||
# fixed positional args — Hyprland's own `monitor` keyword syntax grew
|
||||
# past "mode/x/y/scale/transform" (color management, HDR, VRR, ICC), and
|
||||
# the caller (LeftFlyout.qml's Displays panel) already has all of that as
|
||||
# structured state, so it's simpler for it to build the one string than
|
||||
# for this script to accept a growing positional argument list.
|
||||
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}"
|
||||
mon="${1:?usage: display-set <monitor> <descriptor-tail>}"
|
||||
descriptor_tail="${2:?descriptor required}"
|
||||
|
||||
descriptor="$mon,$mode,${x}x${y},$scale"
|
||||
[ "$transform" != "0" ] && descriptor="$descriptor,transform,$transform"
|
||||
descriptor="$mon,$descriptor_tail"
|
||||
|
||||
conf="$HOME/.config/hypr/display.conf"
|
||||
mkdir -p "$(dirname "$conf")"
|
||||
|
|
|
|||
62
modules/scripts/system-telemetry.sh
Executable file
62
modules/scripts/system-telemetry.sh
Executable file
|
|
@ -0,0 +1,62 @@
|
|||
#!/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"
|
||||
25
modules/scripts/wallpaper-thumbs.sh
Normal file
25
modules/scripts/wallpaper-thumbs.sh
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
#!/usr/bin/env bash
|
||||
# Generates (or reuses) a cached preview JPEG for each animated wallpaper
|
||||
# — first frame ~1s in, to skip a common black/fade intro on most clips —
|
||||
# so the Wallpapers panel can show a real thumbnail instead of a generic
|
||||
# play icon. Prints "<source path>\t<thumbnail path>" per file on stdout
|
||||
# once it's ready, so the caller (LeftFlyout.qml) never has to
|
||||
# independently reconstruct the cache filename — it's a hash of the
|
||||
# source path, chosen only to keep filenames short/safe, not something
|
||||
# QML needs to know how to derive.
|
||||
set -euo pipefail
|
||||
|
||||
cache_dir="${1:?usage: wallpaper-thumbs <cache-dir> <file...>}"
|
||||
shift
|
||||
mkdir -p "$cache_dir"
|
||||
|
||||
for file in "$@"; do
|
||||
[ -f "$file" ] || continue
|
||||
name="$(printf '%s' "$file" | sha1sum | cut -d' ' -f1)"
|
||||
thumb="$cache_dir/$name.jpg"
|
||||
if [ ! -f "$thumb" ] || [ "$file" -nt "$thumb" ]; then
|
||||
ffmpeg -y -ss 00:00:01 -i "$file" -frames:v 1 -vf "scale=320:-1" "$thumb" \
|
||||
> /dev/null 2>&1 || true
|
||||
fi
|
||||
[ -f "$thumb" ] && printf '%s\t%s\n' "$file" "$thumb"
|
||||
done
|
||||
32
modules/scripts/weather-fetch.sh
Executable file
32
modules/scripts/weather-fetch.sh
Executable file
|
|
@ -0,0 +1,32 @@
|
|||
#!/usr/bin/env bash
|
||||
# Fetches current weather + a short hourly forecast from Open-Meteo (free,
|
||||
# no API key/account needed) for either the machine's IP-geolocated
|
||||
# position (default, via ip-api.com — also free/keyless) or an explicitly
|
||||
# named city, and prints one combined JSON object.
|
||||
set -euo pipefail
|
||||
|
||||
city="${1:-}"
|
||||
|
||||
if [ -n "$city" ]; then
|
||||
encoded="$(jq -sRr @uri <<< "$city")"
|
||||
geo="$(curl -s "https://geocoding-api.open-meteo.com/v1/search?count=1&name=$encoded")"
|
||||
lat="$(jq -r '.results[0].latitude // empty' <<< "$geo")"
|
||||
lon="$(jq -r '.results[0].longitude // empty' <<< "$geo")"
|
||||
place="$(jq -r '.results[0].name // empty' <<< "$geo")"
|
||||
country="$(jq -r '.results[0].country // empty' <<< "$geo")"
|
||||
else
|
||||
ipgeo="$(curl -s "http://ip-api.com/json/")"
|
||||
lat="$(jq -r '.lat // empty' <<< "$ipgeo")"
|
||||
lon="$(jq -r '.lon // empty' <<< "$ipgeo")"
|
||||
place="$(jq -r '.city // empty' <<< "$ipgeo")"
|
||||
country="$(jq -r '.country // empty' <<< "$ipgeo")"
|
||||
fi
|
||||
|
||||
if [ -z "$lat" ] || [ -z "$lon" ]; then
|
||||
echo '{"error":"location lookup failed"}'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
weather="$(curl -s "https://api.open-meteo.com/v1/forecast?latitude=$lat&longitude=$lon¤t=temperature_2m,weather_code,wind_speed_10m,precipitation&hourly=temperature_2m,weather_code,precipitation_probability&timezone=auto&forecast_days=2")"
|
||||
|
||||
jq --arg place "$place" --arg country "$country" '. + {place: $place, country: $country}' <<< "$weather"
|
||||
Loading…
Reference in a new issue