summaryrefslogtreecommitdiff
path: root/pid.pl
blob: adf261c5fa0e47360ddb8ca5ecf7b5c9433a966f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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: