From 414b067f8e3f7daeefda0462934ec36d4f128310 Mon Sep 17 00:00:00 2001 From: Matt Turner Date: Wed, 8 Apr 2020 22:21:32 -0700 Subject: Initial import --- pid.pl | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 pid.pl (limited to 'pid.pl') diff --git a/pid.pl b/pid.pl new file mode 100644 index 0000000..adf261c --- /dev/null +++ b/pid.pl @@ -0,0 +1,26 @@ +use Irssi; +use strict; +use warnings; + +our $VERSION = "1.0"; +our %IRSSI = ( + authors => 'Matt Turner', + contact => 'mattst88@gmail.com', + name => 'pid', + description => 'Writes a pid file', + license => 'GNU GPLv2 or later', + url => 'https://mattst88.com/', +); + +my $pidfile = "$ENV{XDG_RUNTIME_DIR}/irssi.pid"; +open FH, ">", $pidfile or die "Error writing '$pidfile': $!\n"; +print FH $$; +close FH; + +sub remove_pidfile { + unlink $pidfile; +} + +Irssi::command_bind('quit', 'remove_pidfile'); + +# vim:set ts=2 sw=2 expandtab: -- cgit v1.2.3