- Notifications
You must be signed in to change notification settings - Fork 73
Add CPU and GPU temperature #61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
8 commits Select commit Hold shift + click to select a range
1d27247 initial cpu_temp
casperdcl 13a7844 add temp icons & colours
casperdcl 55f127e document temperatures
casperdcl 504844a tidy scripts code
casperdcl e6eeec5 add GPU temperatures too
casperdcl a39fa17 much improve such documentation very
casperdcl 824b372 variable rename
casperdcl bea8177 review comment update
casperdcl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| #!/usr/bin/env bash | ||
| | ||
| CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
| | ||
| source "$CURRENT_DIR/helpers.sh" | ||
| | ||
| cpu_temp_format="%2.0f" | ||
| cpu_temp_unit="C" | ||
| | ||
| print_cpu_temp() { | ||
| cpu_temp_format=$(get_tmux_option "@cpu_temp_format" "$cpu_temp_format") | ||
| cpu_temp_unit=$(get_tmux_option "@cpu_temp_unit" "$cpu_temp_unit") | ||
| if command_exists "sensors"; then | ||
| ([ "$cpu_temp_unit" == F ] && sensors -f || sensors) | awk -v format="$cpu_temp_format$cpu_temp_unit" '/^Core [0-9]+/ {gsub("[^0-9.]", "", $3); sum+=$3; n+=1} END {printf(format, sum/n)}' | ||
| fi | ||
| } | ||
| | ||
| main() { | ||
| print_cpu_temp | ||
| } | ||
| main |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| #!/usr/bin/env bash | ||
| | ||
| CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
| | ||
| source "$CURRENT_DIR/helpers.sh" | ||
| | ||
| cpu_temp_low_bg_color="" | ||
| cpu_temp_medium_bg_color="" | ||
| cpu_temp_high_bg_color="" | ||
| | ||
| cpu_temp_low_default_bg_color="#[bg=green]" | ||
| cpu_temp_medium_default_bg_color="#[bg=yellow]" | ||
| cpu_temp_high_default_bg_color="#[bg=red]" | ||
| | ||
| get_bg_color_settings() { | ||
| cpu_temp_low_bg_color=$(get_tmux_option "@cpu_temp_low_bg_color" "$cpu_temp_low_default_bg_color") | ||
| cpu_temp_medium_bg_color=$(get_tmux_option "@cpu_temp_medium_bg_color" "$cpu_temp_medium_default_bg_color") | ||
| cpu_temp_high_bg_color=$(get_tmux_option "@cpu_temp_high_bg_color" "$cpu_temp_high_default_bg_color") | ||
| } | ||
| | ||
| print_bg_color() { | ||
| local cpu_temp=$($CURRENT_DIR/cpu_temp.sh | sed -e 's/[^0-9.]//') | ||
| local cpu_temp_status=$(temp_status $cpu_temp) | ||
| if [ $cpu_temp_status == "low" ]; then | ||
| echo "$cpu_temp_low_bg_color" | ||
| elif [ $cpu_temp_status == "medium" ]; then | ||
| echo "$cpu_temp_medium_bg_color" | ||
| elif [ $cpu_temp_status == "high" ]; then | ||
| echo "$cpu_temp_high_bg_color" | ||
| fi | ||
| } | ||
| | ||
| main() { | ||
| get_bg_color_settings | ||
| print_bg_color | ||
| } | ||
| main |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| #!/usr/bin/env bash | ||
| | ||
| CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
| | ||
| source "$CURRENT_DIR/helpers.sh" | ||
| | ||
| cpu_temp_low_fg_color="" | ||
| cpu_temp_medium_fg_color="" | ||
| cpu_temp_high_fg_color="" | ||
| | ||
| cpu_temp_low_default_fg_color="#[bg=green]" | ||
| cpu_temp_medium_default_fg_color="#[bg=yellow]" | ||
| cpu_temp_high_default_fg_color="#[bg=red]" | ||
| | ||
| get_fg_color_settings() { | ||
| cpu_temp_low_fg_color=$(get_tmux_option "@cpu_temp_low_fg_color" "$cpu_temp_low_default_fg_color") | ||
| cpu_temp_medium_fg_color=$(get_tmux_option "@cpu_temp_medium_fg_color" "$cpu_temp_medium_default_fg_color") | ||
| cpu_temp_high_fg_color=$(get_tmux_option "@cpu_temp_high_fg_color" "$cpu_temp_high_default_fg_color") | ||
| } | ||
| | ||
| print_fg_color() { | ||
| local cpu_temp=$($CURRENT_DIR/cpu_temp.sh | sed -e 's/[^0-9.]//') | ||
| local cpu_temp_status=$(temp_status $cpu_temp) | ||
| if [ $cpu_temp_status == "low" ]; then | ||
| echo "$cpu_temp_low_fg_color" | ||
| elif [ $cpu_temp_status == "medium" ]; then | ||
| echo "$cpu_temp_medium_fg_color" | ||
| elif [ $cpu_temp_status == "high" ]; then | ||
| echo "$cpu_temp_high_fg_color" | ||
| fi | ||
| } | ||
| | ||
| main() { | ||
| get_fg_color_settings | ||
| print_fg_color | ||
| } | ||
| main |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| #!/usr/bin/env bash | ||
| | ||
| CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
| | ||
| source "$CURRENT_DIR/helpers.sh" | ||
| | ||
| # script global variables | ||
| cpu_temp_low_icon="" | ||
| cpu_temp_medium_icon="" | ||
| cpu_temp_high_icon="" | ||
| | ||
| cpu_temp_low_default_icon="=" | ||
| cpu_temp_medium_default_icon="≡" | ||
| cpu_temp_high_default_icon="≣" | ||
| | ||
| # icons are set as script global variables | ||
| get_icon_settings() { | ||
| cpu_temp_low_icon=$(get_tmux_option "@cpu_temp_low_icon" "$cpu_temp_low_default_icon") | ||
| cpu_temp_medium_icon=$(get_tmux_option "@cpu_temp_medium_icon" "$cpu_temp_medium_default_icon") | ||
| cpu_temp_high_icon=$(get_tmux_option "@cpu_temp_high_icon" "$cpu_temp_high_default_icon") | ||
| } | ||
| | ||
| print_icon() { | ||
| local cpu_temp=$($CURRENT_DIR/cpu_temp.sh | sed -e 's/[^0-9.]//') | ||
| local cpu_temp_status=$(temp_status $cpu_temp) | ||
| if [ $cpu_temp_status == "low" ]; then | ||
| echo "$cpu_temp_low_icon" | ||
| elif [ $cpu_temp_status == "medium" ]; then | ||
| echo "$cpu_temp_medium_icon" | ||
| elif [ $cpu_temp_status == "high" ]; then | ||
| echo "$cpu_temp_high_icon" | ||
| fi | ||
| } | ||
| | ||
| main() { | ||
| get_icon_settings | ||
| print_icon "$1" | ||
| } | ||
| main |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| #!/usr/bin/env bash | ||
| | ||
| CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
| | ||
| source "$CURRENT_DIR/helpers.sh" | ||
| | ||
| gpu_temp_format="%2.0f" | ||
| | ||
| print_gpu_temp() { | ||
| gpu_temp_format=$(get_tmux_option "@gpu_temp_format" "$gpu_temp_format") | ||
| | ||
| if command_exists "nvidia-smi"; then | ||
| loads=$(cached_eval nvidia-smi) | ||
| elif command_exists "cuda-smi"; then | ||
| loads=$(cached_eval cuda-smi) | ||
| else | ||
| echo "No GPU" | ||
| return | ||
| fi | ||
| echo "$loads" | sed -nr 's/.*\s([0-9]+)C.*/\1/p' | awk -v format="${gpu_temp_format}C" '{sum+=$1; n+=1} END {printf format, sum/n}' | ||
| } | ||
| | ||
| main() { | ||
| print_gpu_temp | ||
| } | ||
| main |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| #!/usr/bin/env bash | ||
| | ||
| CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
| | ||
| source "$CURRENT_DIR/helpers.sh" | ||
| | ||
| gpu_temp_low_bg_color="" | ||
| gpu_temp_medium_bg_color="" | ||
| gpu_temp_high_bg_color="" | ||
| | ||
| gpu_temp_low_default_bg_color="#[bg=green]" | ||
| gpu_temp_medium_default_bg_color="#[bg=yellow]" | ||
| gpu_temp_high_default_bg_color="#[bg=red]" | ||
| | ||
| get_bg_color_settings() { | ||
| gpu_temp_low_bg_color=$(get_tmux_option "@gpu_temp_low_bg_color" "$gpu_temp_low_default_bg_color") | ||
| gpu_temp_medium_bg_color=$(get_tmux_option "@gpu_temp_medium_bg_color" "$gpu_temp_medium_default_bg_color") | ||
| gpu_temp_high_bg_color=$(get_tmux_option "@gpu_temp_high_bg_color" "$gpu_temp_high_default_bg_color") | ||
| } | ||
| | ||
| print_bg_color() { | ||
| local gpu_temp=$($CURRENT_DIR/gpu_temp.sh | sed -e 's/[^0-9.]//') | ||
| local gpu_temp_status=$(temp_status $gpu_temp) | ||
| if [ $gpu_temp_status == "low" ]; then | ||
| echo "$gpu_temp_low_bg_color" | ||
| elif [ $gpu_temp_status == "medium" ]; then | ||
| echo "$gpu_temp_medium_bg_color" | ||
| elif [ $gpu_temp_status == "high" ]; then | ||
| echo "$gpu_temp_high_bg_color" | ||
| fi | ||
| } | ||
| | ||
| main() { | ||
| get_bg_color_settings | ||
| print_bg_color | ||
| } | ||
| main |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| #!/usr/bin/env bash | ||
| | ||
| CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
| | ||
| source "$CURRENT_DIR/helpers.sh" | ||
| | ||
| gpu_temp_low_fg_color="" | ||
| gpu_temp_medium_fg_color="" | ||
| gpu_temp_high_fg_color="" | ||
| | ||
| gpu_temp_low_default_fg_color="#[bg=green]" | ||
| gpu_temp_medium_default_fg_color="#[bg=yellow]" | ||
| gpu_temp_high_default_fg_color="#[bg=red]" | ||
| | ||
| get_fg_color_settings() { | ||
| gpu_temp_low_fg_color=$(get_tmux_option "@gpu_temp_low_fg_color" "$gpu_temp_low_default_fg_color") | ||
| gpu_temp_medium_fg_color=$(get_tmux_option "@gpu_temp_medium_fg_color" "$gpu_temp_medium_default_fg_color") | ||
| gpu_temp_high_fg_color=$(get_tmux_option "@gpu_temp_high_fg_color" "$gpu_temp_high_default_fg_color") | ||
| } | ||
| | ||
| print_fg_color() { | ||
| local gpu_temp=$($CURRENT_DIR/gpu_temp.sh | sed -e 's/[^0-9.]//') | ||
| local gpu_temp_status=$(temp_status $gpu_temp) | ||
| if [ $gpu_temp_status == "low" ]; then | ||
| echo "$gpu_temp_low_fg_color" | ||
| elif [ $gpu_temp_status == "medium" ]; then | ||
| echo "$gpu_temp_medium_fg_color" | ||
| elif [ $gpu_temp_status == "high" ]; then | ||
| echo "$gpu_temp_high_fg_color" | ||
| fi | ||
| } | ||
| | ||
| main() { | ||
| get_fg_color_settings | ||
| print_fg_color | ||
| } | ||
| main |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.