diff options
author | Teddy Wing | 2023-12-12 20:41:46 +0100 |
---|---|---|
committer | Teddy Wing | 2023-12-12 20:41:46 +0100 |
commit | 9e3f392c28791205591e5e5c32ad7534eb5fc707 (patch) | |
tree | 09b8d73f6f26046a024152a698488c16a84157a6 | |
parent | a9aad0dc5605944c4d811c5ae91ff6b8896f4eba (diff) | |
download | weechat-activity-bar-9e3f392c28791205591e5e5c32ad7534eb5fc707.tar.bz2 |
activity_bar.pl: Don't change AnyBar colour for lower priority messages
If you've received a highlight and a normal message comes in, or if you
have a private message and get highlighted, then the AnyBar colour
should not change. We should keep the AnyBar colour of the highest
priority message.
-rw-r--r-- | activity_bar.pl | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/activity_bar.pl b/activity_bar.pl index 9c4f54a..e3fc829 100644 --- a/activity_bar.pl +++ b/activity_bar.pl @@ -43,6 +43,17 @@ sub shutdown { } +# Map colours to priority levels. Higher number is higher priority. +my %color_priorities = ( + 'hollow' => 0, + 'blue' => 1, + 'purple' => 2, + 'orange' => 3, +); + +# Store the most recent colour set to AnyBar. Default to 'hollow'. +my $anybar_last_color = 'hollow'; + my $print_hook = weechat::hook_print('', '', '', 0, 'print_cb', ''); weechat::hook_command( 'activity_bar', @@ -92,6 +103,17 @@ sub print_cb { sub anybar_send { my ($message) = @_; + if ( + $message ne 'hollow' + + # If the current priority is lower than the previous colour. + && $color_priorities{$message} < $color_priorities{$anybar_last_color} + ) { + return; + } + + $anybar_last_color = $message; + $socket->send($message); } |