From 9e3f392c28791205591e5e5c32ad7534eb5fc707 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Tue, 12 Dec 2023 20:41:46 +0100 Subject: 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. --- activity_bar.pl | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) 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); } -- cgit v1.2.3