summaryrefslogtreecommitdiffstats
path: root/bin/watch_lock
blob: 6de654fcaea3f5b4938e59c7cb779959a35c262d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/perl
use strict;
use warnings;

my $pid = open my $in, '-|', 'xscreensaver-command -watch'
    or die "Couldn't spawn process: $!";
$SIG{TERM} = sub { kill TERM => $pid; exit };
while (<$in>) {
    if (/^LOCK/) {
        system "$ENV{HOME}/.bin/on_lock";
        if ($? == -1) {
            warn "Couldn't exec on_lock: $!";
        }
        elsif ($? != 0) {
            warn "on_lock exited with value " . ($? >> 8);
        }
    } elsif (/^UNBLANK/) {
        #system "on_unlock"
    }
}