From 92b9e0ec997e0a817c0071a81ec16f1b0a7858f5 Mon Sep 17 00:00:00 2001 From: dissimulo Date: Tue, 21 Apr 2026 09:07:09 -0700 Subject: [PATCH] =?UTF-8?q?irssi:=20dynamic-nick.pl=20=E2=80=94=20set=20de?= =?UTF-8?q?fault=20nick=20to=20`|=20at=20startup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- .irssi/scripts/autorun/dynamic-nick.pl | 34 ++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .irssi/scripts/autorun/dynamic-nick.pl diff --git a/.irssi/scripts/autorun/dynamic-nick.pl b/.irssi/scripts/autorun/dynamic-nick.pl new file mode 100644 index 00000000..56ece68c --- /dev/null +++ b/.irssi/scripts/autorun/dynamic-nick.pl @@ -0,0 +1,34 @@ +# +# dynamic-nick.pl — sets the irssi default nick to `| 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 `| 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 16–30 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();