Add .config/waybar/scripts/gpu-usage.py
This commit is contained in:
parent
790403a9c0
commit
a11ff813b7
1 changed files with 16 additions and 0 deletions
16
private_dot_config/waybar/scripts/gpu-usage.py
Normal file
16
private_dot_config/waybar/scripts/gpu-usage.py
Normal file
|
|
@ -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))
|
||||||
Loading…
Reference in a new issue