-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
hotdog-handleDiskMenuForDevice:.pl~freebsd
executable file
·52 lines (45 loc) · 1.3 KB
/
hotdog-handleDiskMenuForDevice:.pl~freebsd
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
#!/usr/bin/env perl
$device = shift @ARGV;
if (not $device) {
die('specify device');
}
@lines = `hotdog-listDisks.pl`;
chomp @lines;
@lines = grep { m/\bfstype:[a-zA-Z0-9]+/ } @lines;
foreach $line (@lines) {
if ($line !~ m/\bdevice:$device\b/) {
next;
}
$fstype = '';
if ($line !~ m/\bfstype:([a-zA-Z0-9]+)/) {
next;
}
$fstype = $1;
if ($line =~ m/\bmountpoint:([^\s]+)/) {
$mountpoint = $1;
$quotedDevice = $device;
$quotedDevice =~ s/\\/\\\\/g;
$quotedDevice =~ s/"/\\"/g;
$quotedMountpoint = $mountpoint;
$quotedMountpoint =~ s/\\/\\\\/g;
$quotedMountpoint =~ s/"/\\"/g;
$text = "The device '$quotedDevice' is mounted at '$quotedMountpoint'.";
$cmd = sprintf('hotdog radio OK Cancel %s %s %s %s',
qq{"$text"},
'nothing 1 "Do Nothing"',
'view 0 View',
'unmount 0 Unmount');
$result = `$cmd`;
chomp $result;
if ($result eq 'view') {
chdir $mountpoint;
system('hotdog', 'nav', '.');
} elsif ($result eq 'unmount') {
system('hotdog-unmountDevice.pl', $mountpoint);
}
exit 0;
} else {
system('hotdog-mountDevice.pl', $device, $fstype);
exit 0;
}
}