-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
fx_screen_profiles
executable file
·63 lines (50 loc) · 1.42 KB
/
fx_screen_profiles
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
#!/usr/bin/perl
# abstract: for some stupid reason I can't open multiple firefox
# instances using the same profile on different monitors
# so this script uses a left, middle (default) and right monitor profile
# to circumvent this issue
use strict;
use warnings FATAL => 'all';
use utf8;
use open qw(:std :utf8);
use IPC::Cmd qw(run);
use Data::Dumper;
use Sys::Hostname;
## sdorfehs -c sdump
# left: DP-0 0 0 0 1080 1920 1
# middle: DP-2 1 1080 0 1920 1080 0
# right: HDMI-0 2 3000 0 1080 1920 0
my $firefox_profile;
my $url = shift @ARGV || 'http://192.168.1.97:3000';
my @screens = split(',', `sdorfehs -c sdump`);
# fantomen desktop
my %monitors = (
'DP-0' => 'left',
'DP-2' => 'middle',
'HDMI-0' => 'right',
'DP-5' => 'above',
);
if(hostname() eq 'x1') {
# x1 thinkpad
%monitors = (
'DP-3-1-6' => 'left',
'DP-3-1-5' => 'middle', # 144hz
'eDP-1' => 'right', # internal laptop screen
'DP-3-2' => 'above',
);
}
for my $screen(@screens) {
my ($monitor) = $screen =~ m/^(\S+)/;
# active status is 1 or 0, the last char in the string
my ($active_status) = $screen =~ m/([01])$/;
if($active_status) {
print "using fx profile $monitors{$monitor}\n";
# use the default profile for the middle monitor
$firefox_profile = $monitors{$monitor} eq 'middle' ? 'default-release' : $monitors{$monitor};
last;
}
}
run(
command => "firefox -P $firefox_profile '$url'",
verbose => 3,
);