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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
#!/usr/local/bin/perl
use strict;
use warnings;
use File::HomeDir qw(home);
use constant {
BSDSETSID_PATH => '/usr/local/bin/bsdsetsid',
DUNSTRC_PATH => home() . '/.config/dunst/dunstrc',
DUNSTRC_PATH => '/usr/local/bin/dunst',
MPD_NOTIFICATION_PATH => '/usr/local/bin/mpd-notification',
NOTIFYSEND_PATH => '/usr/local/bin/notify-send',
PKILL_PATH => '/bin/pkill'
};
sub kill_programs() {
system(PKILL_PATH, 'espeak');
system(PKILL_PATH, 'mpd-notification');
system(PKILL_PATH, 'dunst');
}
sub start_programs() {
system(BSDSETSID_PATH, DUNST_PATH);
system(BSDSETSID_PATH, MPD_NOTIFICATION_PATH);
}
sub main()
{
my $i;
my @lines;
kill_programs();
open(FH, '<', DUNSTRC_PATH) or die $!;
@lines = do {
local $/;
<FH>
};
close(FH);
for ($i = 0; $i < @lines, $i++) {
last if $lines[$i];
}
print $lines[$i];
open(FH, '>', home() . '/tmp') or die $!;
print FH @lines;
close(FH);
start_programs();
return;
}
main();
__END__
|