diff --git a/docs/CONFIG.md b/docs/CONFIG.md index b015a2fa..eb7c9475 100644 --- a/docs/CONFIG.md +++ b/docs/CONFIG.md @@ -802,7 +802,7 @@ nerdfont icons to consider: ### synchronize-panes - [up](#table-of-contents) -This widget displays whether the tmux panes are currently synchronised or not. +This widget displays whether the tmux panes are currently synchronised. To change the label: @@ -810,7 +810,26 @@ To change the label: set -g @dracula-synchronize-panes-label "Sync" ``` -`set -g @dracula-refresh-rate 5` affects this widget +The global refresh rate affects this widget: + +```bash +set -g @dracula-refresh-rate 5 +``` + +You can set a custom refresh rate just for synchronize-panes: + +```bash +set -g @dracula-synchronize-panes-refresh-rate "0.5" # default: unset +``` + +**Note:** This only takes precedence for the synchronize-panes widget. This means it won't +override the global `@dracula-refresh-rate`. + +Alternatively, you can automatically hide the label when sync is `off`: + +```bash +set -g @dracula-synchronize-panes-auto-hide true # default: false +``` ### sys-temp - [up](#table-of-contents) diff --git a/scripts/synchronize_panes.sh b/scripts/synchronize_panes.sh index 078e8a9b..c85fab6b 100755 --- a/scripts/synchronize_panes.sh +++ b/scripts/synchronize_panes.sh @@ -16,9 +16,25 @@ main() { # storing the refresh rate in the variable RATE, default is 5 RATE=$(get_tmux_option "@dracula-refresh-rate" 5) - synchronize_panes_label=$label + + # Use the @dracula-synchronize-panes-refresh-rate plugin variable to override it. + RATE_OVERRIDE=$(get_tmux_option "@dracula-synchronize-panes-refresh-rate" "") + if [[ -n "$RATE_OVERRIDE" ]]; then + RATE="$RATE_OVERRIDE" + fi + + synchronize_panes_auto_hide=$(get_tmux_option "@dracula-synchronize-panes-auto-hide" "false") synchronize_panes_status=$(get_synchronize_panes_status) - echo "$synchronize_panes_label $synchronize_panes_status" + synchronize_panes_label=$label + + if [[ "$synchronize_panes_auto_hide" == 'true' ]]; then + if [[ "$synchronize_panes_status" == 'on' ]]; then + echo "$synchronize_panes_label" + fi + else + echo "$synchronize_panes_label $synchronize_panes_status" + fi + sleep $RATE }