Fix waybar Nvidia module

This commit is contained in:
Bun 2025-05-12 11:19:54 -04:00
parent f50b90ba94
commit a791dd0583
5 changed files with 20 additions and 10 deletions

View file

@ -61,6 +61,7 @@
BC="${bc}/bin/bc"
HEAD="${uutils-coreutils-noprefix}/bin/head"
CAT="${uutils-coreutils-noprefix}/bin/cat"
NVIDIA="/run/current-system/sw/bin/nvidia-smi"
# Detect the active GPU driver
gpu_driver="$($LSPCI -k | $GREP -Eo 'in use: (nvidia|amdgpu)' | $AWK '{print $3}')"
@ -72,7 +73,7 @@
# Get VRAM usage in MB
if [[ "$gpu_driver" == "nvidia" ]]; then
vram_usage_mb="$(nvidia-smi --query-gpu=memory.used --format=csv,noheader,nounits | $HEAD -n1)"
vram_usage_mb="$($NVIDIA --query-gpu=memory.used --format=csv,noheader,nounits | $HEAD -n1)"
elif [[ "$gpu_driver" == "amdgpu" ]]; then
vram_bytes="$($CAT /sys/class/drm/card*/device/mem_info_vram_used 2>/dev/null | $HEAD -n1)"
vram_usage_mb="$($BC <<< "$vram_bytes / 1024 / 1024")"

View file

@ -0,0 +1,11 @@
{ config, pkgs, stable, unstable, ... }:
with pkgs; {
_module.args.pkgsStable = import stable {
inherit (stdenv.hostPlatform) system;
inherit (config.nixpkgs) config;
};
_module.args.pkgsUnstable = import unstable {
inherit (stdenv.hostPlatform) system;
inherit (config.nixpkgs) config;
};
}

View file

@ -1,6 +1,7 @@
{ pkgs, ... }:
{
imports = [
./channels
./gc
./unfree
];