From a11ff813b7d702e7dc78fea9f8cac21c07fb11df Mon Sep 17 00:00:00 2001 From: Yarne Coppens Date: Sat, 7 Feb 2026 11:09:36 +0100 Subject: [PATCH] Add .config/waybar/scripts/gpu-usage.py --- private_dot_config/waybar/scripts/gpu-usage.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 private_dot_config/waybar/scripts/gpu-usage.py diff --git a/private_dot_config/waybar/scripts/gpu-usage.py b/private_dot_config/waybar/scripts/gpu-usage.py new file mode 100644 index 0000000..e13f048 --- /dev/null +++ b/private_dot_config/waybar/scripts/gpu-usage.py @@ -0,0 +1,16 @@ +from subprocess import check_output +import json + +gpu_usage = check_output(["nvidia-smi", "--query-gpu=utilization.gpu", "--format=csv,noheader,nounits"]) + +gpu_usage = gpu_usage.decode('utf-8').replace("\n",'') + +return_json = { + "text":gpu_usage, + "alt":"GPU_PERCENT", + "tooltip":"GPU percentage", + "class":"gpu_class", + "percentage":int(gpu_usage) +} + +print(json.dumps(return_json)) \ No newline at end of file