Last active
November 29, 2021 11:01
-
-
Save basilfx/1ab94764f4d981f15e50 to your computer and use it in GitHub Desktop.
Irssi and tmux-notify
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
use vars qw($VERSION %IRSSI); | |
use Irssi; | |
# Script info | |
$VERSION = '0.1'; | |
%IRSSI = ( | |
authors => 'Bas Stottelaar', | |
contact => '[email protected]', | |
name => 'tmux-notify', | |
description => 'Notify tmux of IRC activity', | |
license => 'MIT', | |
); | |
# Handlers | |
sub sig_notify | |
{ | |
system('/usr/local/bin/tmux-notify'); | |
} | |
# Register handlers | |
Irssi::signal_add('message public', \&sig_notify); | |
Irssi::signal_add('message private', \&sig_notify); | |
Irssi::signal_add('message invite', \&sig_notify); | |
Irssi::signal_add('message kick', \&sig_notify); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Run only in tmux | |
if [ "$TMUX_PANE" == "" ] | |
then | |
exit 0 | |
fi | |
# Retrieve information about tmux | |
WINDOW=`/usr/bin/tmux display -pt $TMUX_PANE '#S:#I' 2> /dev/null` | |
IS_WINDOW_ACTIVE=`/usr/bin/tmux display -pt $TMUX_PANE '#{window_active}' 2> /dev/null` | |
if [ "$IS_WINDOW_ACTIVE" == "0" ] && [ "$WINDOW" != "" ] | |
then | |
# Enable visual activity | |
/usr/bin/tmux set-window-option -t $WINDOW monitor-activity on > /dev/null | |
# Print nothing, but this triggers the activity monitor. Requires bash to not fuck up the output. | |
echo -ne "\0" | |
# Alternative, but not tested | |
# /usr/bin/tmux send-keys -t $WINDOW Space C-H | |
# Disable visual activity again | |
/usr/bin/tmux set-window-option -t $WINDOW monitor-activity off > /dev/null | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment