aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2023-12-09 22:31:29 +0100
committerTeddy Wing2023-12-09 22:31:29 +0100
commit16792128df553aa9e7a7a12da11a4b4d3672d59e (patch)
tree450e0a65e47bf1550884452c8fa8e5b7b00690a7
parent79ab49de58bdbd6ad8513e903fe82143174b328d (diff)
downloadweechat-activity-bar-16792128df553aa9e7a7a12da11a4b4d3672d59e.tar.bz2
activity_bar.pl: Add `enable` and `disable` commands
Add new commands that enable and disable the print hook. We can use these commands in terminal focus handlers, to turn on activity monitoring when WeeChat is not focused, and turn it off once it is focused.
-rw-r--r--activity_bar.pl23
1 files changed, 18 insertions, 5 deletions
diff --git a/activity_bar.pl b/activity_bar.pl
index b9bf4d7..88a99e1 100644
--- a/activity_bar.pl
+++ b/activity_bar.pl
@@ -27,13 +27,17 @@ sub shutdown {
}
-weechat::hook_print('', '', '', 0, 'print_cb', '');
+my $print_hook = weechat::hook_print('', '', '', 0, 'print_cb', '');
weechat::hook_command(
'activity_bar',
'Activity Bar commands',
- '[clear]',
- 'clear: change AnyBar icon to hollow',
- 'clear',
+ '[clear] | [enable|disable]',
+ 'clear: change AnyBar icon to hollow
+enable: enable activity notification
+disable: clear the AnyBar icon and disable activity notification',
+ 'clear
+ || enable
+ || disable',
'activity_bar_command_cb',
''
);
@@ -65,7 +69,16 @@ sub anybar_send {
sub activity_bar_command_cb {
my ($data, $buffer, $args) = @_;
- anybar_send('hollow');
+ if ($args eq 'clear') {
+ anybar_send('hollow');
+ }
+ if ($args eq 'disable') {
+ anybar_send('hollow');
+ weechat::unhook($print_hook);
+ }
+ if ($args eq 'enable') {
+ $print_hook = weechat::hook_print('', '', '', 0, 'print_cb', '');
+ }
return weechat::WEECHAT_RC_OK;
}