From c933dae67e5171fc6ab4395ccfb3ec886871be98 Mon Sep 17 00:00:00 2001 From: osdamv Date: Thu, 6 Aug 2020 08:22:03 -0600 Subject: [PATCH 1/7] Option to remove the time A simple if to remove the time option, I do not like it because I already have a huge watch in my desktop environment --- scripts/dracula.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/scripts/dracula.sh b/scripts/dracula.sh index bf7388c..54798bd 100755 --- a/scripts/dracula.sh +++ b/scripts/dracula.sh @@ -31,6 +31,7 @@ main() show_cpu_usage=$(get_tmux_option "@dracula-cpu-usage" false) show_ram_usage=$(get_tmux_option "@dracula-ram-usage" false) show_gpu_usage=$(get_tmux_option "@dracula-gpu-usage" false) + show_time=$(get_tmux_option "@dracula-show-time" true) # Dracula Color Pallette white='#f8f8f2' @@ -138,11 +139,12 @@ main() tmux set-option -ga status-right "#[fg=${orange},bg=${powerbg},nobold,nounderscore,noitalics] ${right_sep}#[fg=${dark_gray},bg=${orange}] #(cat $current_dir/../data/weather.txt)" powerbg=${orange} fi - - if $show_military; then # military time - tmux set-option -ga status-right "#[fg=${dark_purple},bg=${powerbg},nobold,nounderscore,noitalics] ${right_sep}#[fg=${white},bg=${dark_purple}] %a %m/%d %R ${timezone} " - else - tmux set-option -ga status-right "#[fg=${dark_purple},bg=${powerbg},nobold,nounderscore,noitalics] ${right_sep}#[fg=${white},bg=${dark_purple}] %a %m/%d %I:%M %p ${timezone} " + if $show_time; then + if $show_military; then # military time + tmux set-option -ga status-right "#[fg=${dark_purple},bg=${powerbg},nobold,nounderscore,noitalics] ${right_sep}#[fg=${white},bg=${dark_purple}] %a %m/%d %R ${timezone} " + else + tmux set-option -ga status-right "#[fg=${dark_purple},bg=${powerbg},nobold,nounderscore,noitalics] ${right_sep}#[fg=${white},bg=${dark_purple}] %a %m/%d %I:%M %p ${timezone} " + fi fi tmux set-window-option -g window-status-current-format "#[fg=${gray},bg=${dark_purple}]${left_sep}#[fg=${white},bg=${dark_purple}] #I #W #[fg=${dark_purple},bg=${gray}]${left_sep}" From 14ad891d3dda829675898ef096ae6aa4c0616c5b Mon Sep 17 00:00:00 2001 From: Jaewon Chung Date: Fri, 7 Aug 2020 00:56:00 +0900 Subject: [PATCH 2/7] Support multi-gpu environment --- scripts/gpu_usage.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/gpu_usage.sh b/scripts/gpu_usage.sh index 3bb1445..f59e306 100755 --- a/scripts/gpu_usage.sh +++ b/scripts/gpu_usage.sh @@ -4,7 +4,7 @@ get_platform() { case $(uname -s) in Linux) - gpu=$(lspci -v | grep -i gpu | grep driver | awk '{print $5}') + gpu=$(lspci -v | grep VGA | head -n 1 | awk '{print $5}') echo $gpu ;; @@ -20,10 +20,12 @@ get_platform() get_gpu() { gpu=$(get_platform) - if [ $gpu == nvidia-gpu ]; then - usage=$(nvidia-smi | grep "%" | awk '{print $13}') - echo $usage + if [[ "$gpu" == NVIDIA ]]; then + usage=$(nvidia-smi | grep '%' | awk '{ sum += $13 } END { printf("%d%%\n", sum / NR) }') + else + usage='unknown' fi + echo $usage } main() { @@ -33,5 +35,3 @@ main() } # run the main driver main - - From 288cdc5a99c170048b3489143e34a3198e21a6b2 Mon Sep 17 00:00:00 2001 From: Ethan Edwards Date: Thu, 6 Aug 2020 19:05:43 -0400 Subject: [PATCH 3/7] adding the option to turn off time on powerline --- scripts/dracula.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/scripts/dracula.sh b/scripts/dracula.sh index 54798bd..f2d68c3 100755 --- a/scripts/dracula.sh +++ b/scripts/dracula.sh @@ -178,12 +178,13 @@ main() tmux set-option -ga status-right "#[fg=${dark_gray},bg=${orange}] #(cat $current_dir/../data/weather.txt) " fi - if $show_military; then # military time - tmux set-option -ga status-right "#[fg=${white},bg=${dark_purple}] %a %m/%d %R ${timezone} " - else - tmux set-option -ga status-right "#[fg=${white},bg=${dark_purple}] %a %m/%d %I:%M %p ${timezone} " + if $show_time; then + if $show_military; then # military time + tmux set-option -ga status-right "#[fg=${white},bg=${dark_purple}] %a %m/%d %R ${timezone} " + else + tmux set-option -ga status-right "#[fg=${white},bg=${dark_purple}] %a %m/%d %I:%M %p ${timezone} " + fi fi - tmux set-window-option -g window-status-current-format "#[fg=${white},bg=${dark_purple}] #I #W " fi From 695a67531f794a7f743ac3c070e080359021748a Mon Sep 17 00:00:00 2001 From: Ethan Edwards Date: Sun, 9 Aug 2020 01:50:07 -0400 Subject: [PATCH 4/7] init for refresh_rate NOT WORKING --- scripts/cpu_info.sh | 2 +- scripts/dracula.sh | 6 +++++- scripts/gpu_usage.sh | 2 +- scripts/ram_info.sh | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/scripts/cpu_info.sh b/scripts/cpu_info.sh index c5180cd..7bc72d1 100755 --- a/scripts/cpu_info.sh +++ b/scripts/cpu_info.sh @@ -23,7 +23,7 @@ main() { cpu_percent=$(get_percent) echo "CPU $cpu_percent" - sleep 10 + sleep $RATE } # run main driver diff --git a/scripts/dracula.sh b/scripts/dracula.sh index f2d68c3..f324c12 100755 --- a/scripts/dracula.sh +++ b/scripts/dracula.sh @@ -32,6 +32,10 @@ main() show_ram_usage=$(get_tmux_option "@dracula-ram-usage" false) show_gpu_usage=$(get_tmux_option "@dracula-gpu-usage" false) show_time=$(get_tmux_option "@dracula-show-time" true) + show_refresh=$(get_tmux_option "@dracula-refresh-rate" 5) + + # exporting the value for the other scripts to read + export RATE=$show_refresh # Dracula Color Pallette white='#f8f8f2' @@ -79,7 +83,7 @@ main() esac # sets refresh interval to every 5 seconds - tmux set-option -g status-interval 5 + tmux set-option -g status-interval $show_refresh # set clock to 12 hour by default tmux set-option -g clock-mode-style 12 diff --git a/scripts/gpu_usage.sh b/scripts/gpu_usage.sh index 3bb1445..6935af7 100755 --- a/scripts/gpu_usage.sh +++ b/scripts/gpu_usage.sh @@ -29,7 +29,7 @@ main() { gpu_usage=$(get_gpu) echo "GPU $gpu_usage" - sleep 10 + sleep $RATE } # run the main driver main diff --git a/scripts/ram_info.sh b/scripts/ram_info.sh index 7b3a6a2..5263e5d 100755 --- a/scripts/ram_info.sh +++ b/scripts/ram_info.sh @@ -39,7 +39,7 @@ main() { ram_percent=$(get_percent) echo "RAM $ram_percent" - sleep 10 + sleep $RATE } #run main driver From e290571feea1ab33dffa481a1aa87a8e296d8d9e Mon Sep 17 00:00:00 2001 From: Ethan Edwards Date: Mon, 10 Aug 2020 07:57:48 -0400 Subject: [PATCH 5/7] added the refresh rate by pulling from the .tmux.conf file and running the get_tmux_option function and using that as the variable for the refresh rate on sleep --- scripts/cpu_info.sh | 12 ++++++++++++ scripts/dracula.sh | 3 --- scripts/gpu_usage.sh | 12 ++++++++++++ scripts/ram_info.sh | 12 ++++++++++++ 4 files changed, 36 insertions(+), 3 deletions(-) diff --git a/scripts/cpu_info.sh b/scripts/cpu_info.sh index 7bc72d1..34635c0 100755 --- a/scripts/cpu_info.sh +++ b/scripts/cpu_info.sh @@ -1,5 +1,16 @@ #!/usr/bin/env bash +get_tmux_option() { + local option=$1 + local default_value=$2 + local option_value=$(tmux show-option -gqv "$option") + if [ -z $option_value ]; then + echo $default_value + else + echo $option_value + fi +} + get_percent() { case $(uname -s) in @@ -21,6 +32,7 @@ get_percent() main() { + RATE=$(get_tmux_option "@dracula-refresh-rate" 5) cpu_percent=$(get_percent) echo "CPU $cpu_percent" sleep $RATE diff --git a/scripts/dracula.sh b/scripts/dracula.sh index f324c12..b33d8d2 100755 --- a/scripts/dracula.sh +++ b/scripts/dracula.sh @@ -34,9 +34,6 @@ main() show_time=$(get_tmux_option "@dracula-show-time" true) show_refresh=$(get_tmux_option "@dracula-refresh-rate" 5) - # exporting the value for the other scripts to read - export RATE=$show_refresh - # Dracula Color Pallette white='#f8f8f2' gray='#44475a' diff --git a/scripts/gpu_usage.sh b/scripts/gpu_usage.sh index 6935af7..3b783ee 100755 --- a/scripts/gpu_usage.sh +++ b/scripts/gpu_usage.sh @@ -1,5 +1,16 @@ #!/usr/bin/env bash +get_tmux_option() { + local option=$1 + local default_value=$2 + local option_value=$(tmux show-option -gqv "$option") + if [ -z $option_value ]; then + echo $default_value + else + echo $option_value + fi +} + get_platform() { case $(uname -s) in @@ -27,6 +38,7 @@ get_gpu() } main() { + RATE=$(get_tmux_option "@dracula-refresh-rate" 5) gpu_usage=$(get_gpu) echo "GPU $gpu_usage" sleep $RATE diff --git a/scripts/ram_info.sh b/scripts/ram_info.sh index 5263e5d..30f905c 100755 --- a/scripts/ram_info.sh +++ b/scripts/ram_info.sh @@ -1,5 +1,16 @@ #!/usr/bin/env bash +get_tmux_option() { + local option=$1 + local default_value=$2 + local option_value=$(tmux show-option -gqv "$option") + if [ -z $option_value ]; then + echo $default_value + else + echo $option_value + fi +} + get_percent() { case $(uname -s) in @@ -37,6 +48,7 @@ get_percent() main() { + RATE=$(get_tmux_option "@dracula-refresh-rate" 5) ram_percent=$(get_percent) echo "RAM $ram_percent" sleep $RATE From b662f2e10d68c23422eb56af61ff553b51b6923c Mon Sep 17 00:00:00 2001 From: Ethan Edwards Date: Mon, 10 Aug 2020 08:04:51 -0400 Subject: [PATCH 6/7] documentation --- INSTALL.md | 1 + README.md | 1 + scripts/cpu_info.sh | 2 ++ scripts/gpu_usage.sh | 2 ++ scripts/ram_info.sh | 2 ++ 5 files changed, 8 insertions(+) diff --git a/INSTALL.md b/INSTALL.md index a24609f..03362b6 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -21,6 +21,7 @@ Customize the status bar by adding any of these lines to your .tmux.conf as desi * Switch from default fahrenheit to celsius: `set -g @dracula-show-fahrenheit false` * Enable powerline symbols: `set -g @dracula-show-powerline true` * Switch powerline symbols `set -g @dracula-show-left-sep ` for left and `set -g @dracula-show-right-sep ` for right symbol (can set any symbol you like as seperator) +* Adjust the refresh rate for the bar `set -g @dracula-refresh-rate 5` the default is 5, it can accept any number * Enable military time: `set -g @dracula-military-time true` * Disable timezone: `set -g @dracula-show-timezone false` * Switch the left smiley icon `set -g @dracula-show-left-icon session` it can accept `session`, `smiley`, `window`, or any character. diff --git a/README.md b/README.md index f8ec8a9..666ead6 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ Configuration and options can be found at [draculatheme.com/tmux](https://dracul * Current location based on network with temperature and forecast icon (if available) * Network connection status and SSID * Battery percentage and AC power connection status +* Refresh rate control * CPU usage * RAM usage * GPU usage diff --git a/scripts/cpu_info.sh b/scripts/cpu_info.sh index 34635c0..c765d16 100755 --- a/scripts/cpu_info.sh +++ b/scripts/cpu_info.sh @@ -1,5 +1,6 @@ #!/usr/bin/env bash +# function for getting the refresh rate get_tmux_option() { local option=$1 local default_value=$2 @@ -32,6 +33,7 @@ get_percent() main() { + # storing the refresh rate in the variable RATE, default is 5 RATE=$(get_tmux_option "@dracula-refresh-rate" 5) cpu_percent=$(get_percent) echo "CPU $cpu_percent" diff --git a/scripts/gpu_usage.sh b/scripts/gpu_usage.sh index 3b783ee..79b60f1 100755 --- a/scripts/gpu_usage.sh +++ b/scripts/gpu_usage.sh @@ -1,5 +1,6 @@ #!/usr/bin/env bash +# function for getting the refresh rate get_tmux_option() { local option=$1 local default_value=$2 @@ -38,6 +39,7 @@ get_gpu() } main() { + # storing the refresh rate in the variable RATE, default is 5 RATE=$(get_tmux_option "@dracula-refresh-rate" 5) gpu_usage=$(get_gpu) echo "GPU $gpu_usage" diff --git a/scripts/ram_info.sh b/scripts/ram_info.sh index 30f905c..141e7a6 100755 --- a/scripts/ram_info.sh +++ b/scripts/ram_info.sh @@ -1,5 +1,6 @@ #!/usr/bin/env bash +# function for getting the refresh rate get_tmux_option() { local option=$1 local default_value=$2 @@ -48,6 +49,7 @@ get_percent() main() { + # storing the refresh rate in the variable RATE, default is 5 RATE=$(get_tmux_option "@dracula-refresh-rate" 5) ram_percent=$(get_percent) echo "RAM $ram_percent" From 33703eb2d35b5612b9abd041c5e3f9f55fdc9b86 Mon Sep 17 00:00:00 2001 From: Gaganpreet Date: Mon, 31 Aug 2020 11:41:45 +0200 Subject: [PATCH 7/7] specify numeric locale for parsing top output --- scripts/cpu_info.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/cpu_info.sh b/scripts/cpu_info.sh index c5180cd..92cec3b 100755 --- a/scripts/cpu_info.sh +++ b/scripts/cpu_info.sh @@ -4,7 +4,7 @@ get_percent() { case $(uname -s) in Linux) - percent=$(top -bn1 | grep "Cpu(s)" | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $1"%"}') + percent=$(LC_NUMERIC=en_US.UTF-8 top -bn1 | grep "Cpu(s)" | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $1"%"}') echo $percent ;;