Switch to 'model' instead of 'serial', clean display list
This commit is contained in:
parent
57b2e76540
commit
bb7a12a8b4
274
sway/displays.pl
274
sway/displays.pl
|
@ -45,18 +45,13 @@ my $active_outputs = "$ENV{'HOME'}/.spool/active_outputs";
|
||||||
# Display Serials and Names
|
# Display Serials and Names
|
||||||
########################################################################
|
########################################################################
|
||||||
|
|
||||||
# Hash to match display Serial with a friendly name.
|
# Hash to match display model name to internal name
|
||||||
# You can get the serial from (quoted with *):
|
# You can get the model from (quoted with *):
|
||||||
# $ swaymsg -t get_outputs
|
# $ swaymsg -t get_outputs --raw
|
||||||
# Output eDP-1 'Unknown 0x057D *0x00000000*'
|
|
||||||
my %outputs = (
|
my %outputs = (
|
||||||
#'0x00000101' => 'Sam',
|
'LG TV SSCR2' => 'TV',
|
||||||
'HTNCB00059' => 'Sam',
|
'Paperlike253' => 'eInk',
|
||||||
#'3CQ4342S6W' => 'HP-1',
|
'0x4140' => 'yoga'
|
||||||
'0x00000101' => 'HP-1',
|
|
||||||
'3CQ3310Q1Q' => 'HP-2',
|
|
||||||
'0x00000000' => 'LVDS',
|
|
||||||
'0x00000101' => 'TV',
|
|
||||||
);
|
);
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
|
@ -67,14 +62,76 @@ my %outputs = (
|
||||||
# Second-level keys are the display friendly-names, above
|
# Second-level keys are the display friendly-names, above
|
||||||
# Third-level are the actual settings for that display
|
# Third-level are the actual settings for that display
|
||||||
my %configs = (
|
my %configs = (
|
||||||
|
'Both' => {
|
||||||
|
'yoga' => {
|
||||||
|
'on' => 0
|
||||||
|
},
|
||||||
|
'eInk' => {
|
||||||
|
'on' => 1,
|
||||||
|
'width' => 3200,
|
||||||
|
'height' => 1800,
|
||||||
|
'x' => 0,
|
||||||
|
'y' => 0,
|
||||||
|
'rotate' => 90,
|
||||||
|
'scale' => 2,
|
||||||
|
'waybar' => 'top',
|
||||||
|
'fallback' => '#fefefe',
|
||||||
|
},
|
||||||
'TV' => {
|
'TV' => {
|
||||||
'HP-1' => {
|
'on' => 1,
|
||||||
|
'width' => 3840,
|
||||||
|
'height' => 2160,
|
||||||
|
'x' => 900,
|
||||||
|
'y' => 0,
|
||||||
|
'rotate' => 0,
|
||||||
|
'scale' => 1.33333,
|
||||||
|
'waybar' => 'top',
|
||||||
|
'fallback' => '#010101',
|
||||||
|
'bg' => "$ENV{HOME}/wallpapers/wallpaper.png"
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'detached' => {
|
||||||
|
'yoga' => {
|
||||||
|
'on' => 1,
|
||||||
|
'width' => 2560,
|
||||||
|
'height' => 1440,
|
||||||
|
'x' => 0,
|
||||||
|
'y' => 0,
|
||||||
|
'rotate' => 0,
|
||||||
|
'scale' => 1.33333,
|
||||||
|
'waybar' => 'bottom',
|
||||||
|
'fallback' => '#010101',
|
||||||
|
'bg' => "$ENV{HOME}/wallpapers/wallpaper.png"
|
||||||
|
},
|
||||||
|
'eInk' => {
|
||||||
'on' => 0
|
'on' => 0
|
||||||
},
|
},
|
||||||
'HP-2' => {
|
'TV' => {
|
||||||
|
'on' => 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'eInk' => {
|
||||||
|
'yoga' => {
|
||||||
'on' => 0
|
'on' => 0
|
||||||
},
|
},
|
||||||
'Sam' => {
|
'eInk' => {
|
||||||
|
'on' => 1,
|
||||||
|
'width' => 3840,
|
||||||
|
'height' => 2160,
|
||||||
|
'x' => 0,
|
||||||
|
'y' => 0,
|
||||||
|
'rotate' => 0,
|
||||||
|
'scale' => 1.33333,
|
||||||
|
'waybar' => 'top',
|
||||||
|
'fallback' => '#010101',
|
||||||
|
'bg' => "$ENV{HOME}/wallpapers/wallpaper.png"
|
||||||
|
},
|
||||||
|
'TV' => {
|
||||||
|
'on' => 0
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'TV' => {
|
||||||
|
'yoga' => {
|
||||||
'on' => 0
|
'on' => 0
|
||||||
},
|
},
|
||||||
'TV' => {
|
'TV' => {
|
||||||
|
@ -84,185 +141,14 @@ my %configs = (
|
||||||
'x' => 0,
|
'x' => 0,
|
||||||
'y' => 0,
|
'y' => 0,
|
||||||
'rotate' => 0,
|
'rotate' => 0,
|
||||||
'scale' => 1.333333333,
|
'scale' => 1.33333,
|
||||||
'waybar' => 'top',
|
'waybar' => 'top',
|
||||||
'fallback' => '#282828'
|
'fallback' => '#010101',
|
||||||
|
'bg' => "$ENV{HOME}/wallpapers/wallpaper.png"
|
||||||
},
|
},
|
||||||
'eDP-1' => {
|
|
||||||
'on' => 1,
|
|
||||||
'width' => 1920,
|
|
||||||
'height' => 1080,
|
|
||||||
'x' => 3079,
|
|
||||||
'y' => 0,
|
|
||||||
'rotate' => 0,
|
|
||||||
'waybar' => 'bottom',
|
|
||||||
'fallback' => '#282828'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'detached' => {
|
|
||||||
'HP-1' => {
|
|
||||||
'on' => 0
|
|
||||||
},
|
|
||||||
'HP-2' => {
|
|
||||||
'on' => 0
|
|
||||||
},
|
|
||||||
'Sam' => {
|
|
||||||
'on' => 0
|
|
||||||
},
|
|
||||||
'TV' => {
|
|
||||||
'on' => 0
|
|
||||||
},
|
|
||||||
'eDP-1' => {
|
|
||||||
'on' => 1,
|
|
||||||
'width' => 1920,
|
|
||||||
'height' => 1080,
|
|
||||||
'x' => 0,
|
|
||||||
'y' => 0,
|
|
||||||
'rotate' => 0,
|
|
||||||
'waybar' => 'bottom',
|
|
||||||
'fallback' => '#282828'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'stacked-laptop' => {
|
|
||||||
'Sam' => {
|
|
||||||
'on' => 1,
|
|
||||||
'width' => 1920,
|
|
||||||
'height' => 1200,
|
|
||||||
'x' => 960,
|
|
||||||
'y' => 0,
|
|
||||||
'rotate' => 0,
|
|
||||||
'waybar' => 'bottom',
|
|
||||||
'fallback' => '#282828'
|
|
||||||
},
|
|
||||||
'HP-1' => {
|
|
||||||
'on' => 1,
|
|
||||||
'width' => 1920,
|
|
||||||
'height' => 1080,
|
|
||||||
'x' => 1920,
|
|
||||||
'y' => 1200,
|
|
||||||
'rotate' => 0,
|
|
||||||
'waybar' => 'top',
|
|
||||||
'fallback' => '#282828'
|
|
||||||
},
|
|
||||||
'HP-2' => {
|
|
||||||
'on' => 0
|
|
||||||
},
|
|
||||||
'TV' => {
|
|
||||||
'on' => 0
|
|
||||||
},
|
|
||||||
'eDP-1' => {
|
|
||||||
'on' => 1,
|
|
||||||
'width' => 1920,
|
|
||||||
'height' => 1080,
|
|
||||||
'x' => 0,
|
|
||||||
'y' => 1200,
|
|
||||||
'rotate' => 0,
|
|
||||||
'waybar' => 'bottom',
|
|
||||||
'fallback' => '#282828'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'stacked' => {
|
|
||||||
'Sam' => {
|
|
||||||
'on' => 1,
|
|
||||||
'width' => 1920,
|
|
||||||
'height' => 1200,
|
|
||||||
'x' => 960,
|
|
||||||
'y' => 0,
|
|
||||||
'rotate' => 0,
|
|
||||||
'waybar' => 'bottom',
|
|
||||||
'fallback' => '#282828'
|
|
||||||
},
|
|
||||||
'HP-1' => {
|
|
||||||
'on' => 1,
|
|
||||||
'width' => 1920,
|
|
||||||
'height' => 1080,
|
|
||||||
'x' => 1920,
|
|
||||||
'y' => 1200,
|
|
||||||
'rotate' => 0,
|
|
||||||
'waybar' => 'top',
|
|
||||||
'fallback' => '#282828'
|
|
||||||
},
|
|
||||||
'HP-2' => {
|
|
||||||
'on' => 1,
|
|
||||||
'width' => 1920,
|
|
||||||
'height' => 1080,
|
|
||||||
'x' => 0,
|
|
||||||
'y' => 1200,
|
|
||||||
'rotate' => 0,
|
|
||||||
'waybar' => 'top',
|
|
||||||
'fallback' => '#282828'
|
|
||||||
},
|
|
||||||
'TV' => {
|
|
||||||
'on' => 0
|
|
||||||
},
|
|
||||||
'eDP-1' => {
|
|
||||||
'on' => 0
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'sidebyside' => {
|
|
||||||
'HP-1' => {
|
|
||||||
'on' => 1,
|
|
||||||
'width' => 1080,
|
|
||||||
'height' => 1920,
|
|
||||||
'x' => 0,
|
|
||||||
'y' => 225,
|
|
||||||
'rotate' => 270,
|
|
||||||
'waybar' => 'top',
|
|
||||||
'fallback' => '#282828'
|
|
||||||
},
|
|
||||||
'Sam' => {
|
|
||||||
'on' => 1,
|
|
||||||
'width' => 1200,
|
|
||||||
'height' => 1920,
|
|
||||||
'x' => 1080,
|
|
||||||
'y' => 0,
|
|
||||||
'rotate' => 90,
|
|
||||||
'waybar' => 'top',
|
|
||||||
'fallback' => '#282828'
|
|
||||||
},
|
|
||||||
'HP-2' => {
|
|
||||||
'on' => 1,
|
|
||||||
'width' => 1080,
|
|
||||||
'height' => 1920,
|
|
||||||
'x' => 2280,
|
|
||||||
'y' => 225,
|
|
||||||
'rotate' => 90,
|
|
||||||
'waybar' => 'top',
|
|
||||||
'fallback' => '#282828'
|
|
||||||
},
|
|
||||||
'TV' => {
|
|
||||||
'on' => 0
|
|
||||||
},
|
|
||||||
'eDP-1' => {
|
|
||||||
'on' => 0,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
my $hostname = `hostname`;
|
|
||||||
chomp($hostname);
|
|
||||||
if ($hostname eq "yoga.lan.john.me.tz") {
|
|
||||||
$configs{'detached'}->{'eDP-1'}->{'width'} = 2560;
|
|
||||||
$configs{'detached'}->{'eDP-1'}->{'height'} = 1440;
|
|
||||||
$configs{'detached'}->{'eDP-1'}->{'scale'} = 1.333333;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
########################################################################
|
|
||||||
# Disable display from other laptop
|
|
||||||
########################################################################
|
|
||||||
|
|
||||||
if ($ENV{'SSH_AUTH_SOCK'} eq '/home/jpm/.ssh/ssh-agent.sock') {
|
|
||||||
foreach my $layout (keys %configs) {
|
|
||||||
delete($configs{$layout}{'LVDS'});
|
|
||||||
}
|
|
||||||
$outputs{'0x00000000'} = 'eDP-1';
|
|
||||||
} else {
|
|
||||||
foreach my $layout (keys %configs) {
|
|
||||||
delete($configs{$layout}{'eDP-1'});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
# Program (do not edit below)
|
# Program (do not edit below)
|
||||||
########################################################################
|
########################################################################
|
||||||
|
@ -330,19 +216,19 @@ my @off;
|
||||||
for (my $i = 0; $i < scalar(@$displays); $i++) {
|
for (my $i = 0; $i < scalar(@$displays); $i++) {
|
||||||
|
|
||||||
# If a display is found without any settings print error and turn it off
|
# If a display is found without any settings print error and turn it off
|
||||||
unless (defined $configs{$config}{$outputs{$displays->[$i]->{serial}}}){
|
unless (defined $configs{$config}{$outputs{$displays->[$i]->{model}}}){
|
||||||
print STDERR "Output $displays->[$i]->{name} ("
|
print STDERR "Output $displays->[$i]->{name} ("
|
||||||
. $displays->[$i]->{serial}
|
. $displays->[$i]->{model}
|
||||||
. ") found without defined function. Disabling.\n";
|
. ") found without defined function. Disabling.\n";
|
||||||
push @off, $displays->[$i]->{name};
|
push @off, $displays->[$i]->{name};
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
# If display is enabled, copy all of the desired settings
|
# If display is enabled, copy all of the desired settings
|
||||||
if ($configs{$config}{$outputs{$displays->[$i]->{serial}}}{on}) {
|
if ($configs{$config}{$outputs{$displays->[$i]->{model}}}{on}) {
|
||||||
$on->{$outputs{$displays->[$i]->{serial}}} =
|
$on->{$outputs{$displays->[$i]->{model}}} =
|
||||||
$configs{$config}{$outputs{$displays->[$i]->{serial}}};
|
$configs{$config}{$outputs{$displays->[$i]->{model}}};
|
||||||
$on->{$outputs{$displays->[$i]->{serial}}}{output} =
|
$on->{$outputs{$displays->[$i]->{model}}}{output} =
|
||||||
$displays->[$i]->{name};
|
$displays->[$i]->{name};
|
||||||
# Otherwise simply list it for disabling
|
# Otherwise simply list it for disabling
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue