diff --git a/pve-mod-gui-sensors.sh b/pve-mod-gui-sensors.sh index 69d2824..0852290 100644 --- a/pve-mod-gui-sensors.sh +++ b/pve-mod-gui-sensors.sh @@ -228,6 +228,7 @@ function configure { fi done ENABLE_INTEL_GPU_INFO=true + ENABLE_GPU_INFO=true else warn "No Intel GPUs detected by intel_gpu_top." ENABLE_INTEL_GPU_INFO=false @@ -459,6 +460,7 @@ function install_mod { generate_and_insert_widget "$ENABLE_SYSTEM_INFO" "generate_system_info" "system_info" generate_and_insert_widget "$ENABLE_UPS" "generate_ups_widget" "ups" + generate_and_insert_widget "$ENABLE_GPU_INFO" "generate_gpu_widget" "gpu" generate_and_insert_widget "$ENABLE_HDD_TEMP" "generate_hdd_widget" "hdd" generate_and_insert_widget "$ENABLE_NVME_TEMP" "generate_nvme_widget" "nvme" @@ -602,22 +604,6 @@ collect_ups_output() { } collect_graphics_intel_output() { - local output_file="$1" - local intelCmd - - -use threads; -use JSON; - -my $snapshot; - -threads->create(sub { - while (1) { - my $json = `intel_gpu_top -J -s 1`; - $snapshot = decode_json($json); - sleep 1; # optional - } -}); } @@ -772,6 +758,8 @@ add_visual_separator() { if [ "$ENABLE_UPS" = true ]; then lastItemId="upsc" + elif [ "$ENABLE_GPU" = true ]; then + lastItemId="gpuInfo" elif [ "$ENABLE_HDD_TEMP" = true ]; then lastItemId="thermalHdd" elif [ "$ENABLE_NVME_TEMP" = true ]; then @@ -1629,6 +1617,83 @@ EOF fi } +# Function to generate GPU widget +generate_gpu_widget() { + #region gpu widget heredoc + # use subshell to allow variable expansion + ( + export CPU_ITEMS_PER_ROW + export CPU_TEMP_TARGET + export HELPERCTORPARAMS + + cat <<'EOF' | envsubst '$CPU_ITEMS_PER_ROW $CPU_TEMP_TARGET $HELPERCTORPARAMS' > "$1" + { + itemId: 'gpu', + colspan: 2, + iconCls: 'fa fa-desktop', + title: gettext('GPU(s)'), + printBar: false, + textField: 'gpuStats', + renderer: function(gpuStats) { + console.log(gpuStats); + if (!gpuStats || !gpuStats.Graphics || !gpuStats.Graphics.Intel) { + return 'N/A'; + } + + let html = ''; + + Object.keys(gpuStats.Graphics.Intel).forEach(key => { + const gpuData = gpuStats.Graphics.Intel[key]; + console.log("here1"); + html += `