Add .config/waybar/scripts/gpu-usage/gpu-usage.py
This commit is contained in:
parent
d638987e48
commit
e61b5e82d8
1 changed files with 16 additions and 0 deletions
16
private_dot_config/waybar/scripts/gpu-usage/gpu-usage.py
Normal file
16
private_dot_config/waybar/scripts/gpu-usage/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