-
Notifications
You must be signed in to change notification settings - Fork 0
/
ptkrandr.pl
executable file
·77 lines (60 loc) · 1.42 KB
/
ptkrandr.pl
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
#!/usr/bin/perl
use warnings;
use strict;
use Tk;
my $script = $0;
my @lines = `xrandr`;
my $screen = -1;
my @screens;
my $res = 0;
my $monitor = 0;
for my $line (@lines){
if($line =~ /^Screen (\d+):/){
$screen = $1;
}
elsif($line =~ /^\s*(\d+x\d+\S*)/){
$screens[$screen]->{$monitor}->{'resolutions'}->[$res] = $1;
$res++;
}
elsif ($line =~ /^(\S+)\s+connected\s+(\d+x\d+)/){
$monitor = $1;
$screens[$screen]->{$monitor}->{'currentresolution'} = $2;
$res = 0;
}
else{
$monitor = 0;
$res = 0;
}
}
$screen = 0;
my $mw = MainWindow->new(-title => 'Monitor Configuration');
for my $curscreen (@screens) {
my $frame = $mw->Frame(
-label => 'Screen ' . "$screen",
-borderwidth => 1,
-relief => 'solid');
$screen++;
for my $curmon (keys($curscreen)){
my $subframe = $frame->Frame(
-label => $curmon . ': ' . $curscreen->{$curmon}->{'currentresolution'},
-borderwidth => 1,
-relief => 'raised');
$subframe->Button(
-text => 'Auto dectect',
-command => sub {
system('xrandr --output ' . $curmon . ' --auto');
exec($script);
})->pack(-side => 'top');
for my $curres (@{$curscreen->{$curmon}->{'resolutions'}}){
$subframe->Button(
-text => "$curres",
-command => sub {
system('xrandr --output ' . $curmon . ' --mode ' . $curres);
exec $script;
})->pack(-side => 'top');
}
$subframe->pack(-side => 'left');
}
$frame->pack(-side => 'left');
}
MainLoop;