[feat] posix scripts, vim, mutt, gpg, font
[dotfiles_afify.git] / .scripts / gpu
blobd259b83a67e0cf621fcd90d2bd57ef5577e333ff
1 #!/bin/sh
3 max_mem="300"
4 max_temp="50"
5 max_gpu="25"
7 if ! [ "$(uname)" = "Linux" ]; then exit;fi
9 query=$(nvidia-smi --query-gpu=memory.used,temperature.gpu,utilization.gpu \
10 --format=csv | sed 's/memory.*//g' | tr -d '\n,')
12 cur_mem=$(echo "$query" | awk '{print $1}')
13 cur_temp=$(echo "$query" | awk '{print $3}')
14 cur_gpu=$(echo "$query" | awk '{print $4}')
16 if [ "$cur_mem" -gt "$max_mem" ] ||
17 [ "$cur_temp" -gt "$max_temp" ] ||
18 [ "$cur_gpu" -gt "$max_gpu" ]; then
19 echo "\fGPU [$cur_mem MB] [$cur_temp C] [$cur_gpu %]\x01"