Files
drunkendotfiles/.irssi/scripts/autorun/dynamic-nick.pl
dissimulo 92b9e0ec99 irssi: dynamic-nick.pl — set default nick to `|<hostname> at startup
Autorun script so the same drunkendotfiles deploy gives each host a
distinctive nick without per-host config hand-edits. Trims FQDNs to
the short hostname before composing. Static 'nick = "`"' in
config stays as a fallback if the script ever fails to load.
2026-04-21 09:07:09 -07:00

35 lines
1011 B
Perl
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#
# dynamic-nick.pl — sets the irssi default nick to `|<hostname> at startup,
# so the same dotfiles give each machine its own distinctive nick without
# having to hand-edit the config per host.
#
# Drops into ~/.irssi/scripts/autorun/, loads on irssi start.
#
use strict;
use warnings;
use vars qw($VERSION %IRSSI);
use Irssi;
use Sys::Hostname qw(hostname);
$VERSION = '0.1';
%IRSSI = (
authors => 'dissimulo',
contact => 'connect+gitea@dustin-williams.com',
name => 'dynamic-nick',
description => 'Set the default nick to `|<hostname> at startup.',
license => 'MIT',
);
sub set_dynamic_nick {
my $host = hostname();
# trim anything past the first dot — some systems return FQDNs, which
# are longer than most IRCd nick limits (typically 1630 chars).
$host =~ s/\..*$//;
my $nick = '`|' . $host;
Irssi::command("^set nick $nick");
Irssi::print("dynamic-nick: default nick set to $nick", MSGLEVEL_CLIENTCRAP);
}
set_dynamic_nick();