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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
#!/usr/local/bin/perl
use strict;
use warnings;
use File::HomeDir qw(home);
use constant {
SAVE_PATH => 'pics/scrot/',
SCREENSHOT_PATH => '/usr/local/bin/scrot',
IMGVIEW_PATH => '/usr/local/bin/nsxiv',
XCLIP_PATH => '/usr/local/bin/xclip'
};
use constant LIST => [
'Select region',
'Window',
'Fullscreen',
'Monitor 1',
'Monitor 2'
];
sub show_img
{
my ($file) = @_;
my $pid;
$pid = fork();
if (not $pid) {
exec(IMGVIEW_PATH, '-b', $file);
}
return;
}
sub file_name
{
my $file_name;
$file_name = home() . '/' . SAVE_PATH . 'screen_';
$file_name .= `date "+%Y-%m-%d_%H-%M-%S"`;
chomp $file_name;
$file_name .= '.png';
return ($file_name);
}
sub action
{
my ($var) = @_;
my $pid;
my $file_name;
chomp $var;
if ($var eq ${+LIST}[0]) {
$file_name = file_name();
system(
SCREENSHOT_PATH,
$file_name,
'-q', '100',
'-s',
'-l', 'mode=classic,style=dash,width=2,color=#990000'
);
show_img($file_name);
}
elsif ($var eq ${+LIST}[1]) {
$file_name = file_name();
system(
SCREENSHOT_PATH,
$file_name,
'-q', '100',
'-u'
);
show_img($file_name);
}
elsif ($var eq ${+LIST}[2]) {
$file_name = file_name();
system(
SCREENSHOT_PATH,
$file_name,
'-q', '100'
);
show_img($file_name);
}
elsif ($var eq ${+LIST}[3]) {
$file_name = file_name();
system(
SCREENSHOT_PATH,
$file_name,
'-q', '100',
'-a', '0,0,1920,1080'
);
show_img($file_name);
}
elsif ($var eq ${+LIST}[4]) {
$file_name = file_name();
system(
SCREENSHOT_PATH,
$file_name,
'-q', '100',
'-a', '1920,180,1440,900'
);
show_img($file_name);
}
return;
}
sub main
{
my $list;
my $choice;
for (@{+LIST}) {
$list .= $_ . "\n";
}
$choice = `printf "%s" "$list" | dmenu -i -l 10 -m 0`;
action($choice);
return (0);
}
main();
__END__
|