Add notification when display setup is changed
This commit is contained in:
parent
267e505265
commit
e986f0eabb
17
get_randr.pl
17
get_randr.pl
@ -11,11 +11,12 @@ unless (exists $ENV{'WAYLAND_DISPLAY'}) {
|
||||
|
||||
my $app = {};
|
||||
$app->{'displays'} = {};
|
||||
$app->{'setup'} = "";
|
||||
|
||||
get_display_info($app);
|
||||
show_debug(Data::Dumper->Dump([$app]));
|
||||
my $wlr_line = get_wlr_line($app);
|
||||
|
||||
notify($app);
|
||||
print "${wlr_line}\n";
|
||||
|
||||
# -----------
|
||||
@ -93,6 +94,7 @@ sub get_wlr_line {
|
||||
my $num_disps = scalar(keys(%{$app->{'displays'}}));
|
||||
if ($num_disps == 1) {
|
||||
show_debug("Single display configuration");
|
||||
$app->{'setup'} = "Single display configuration";
|
||||
$wlr_line = "wlr-randr --output HDMI-A-1 --off --output eDP-1 --on --pos 0,0"
|
||||
} elsif ($num_disps > 1) {
|
||||
# Determine setup (Custom)
|
||||
@ -103,6 +105,7 @@ sub get_wlr_line {
|
||||
my ($h, $v) = get_display_current_dimensions($app, $matching_disps->[0]);
|
||||
my $disp_name = $matching_disps->[0]->{'name'};
|
||||
show_debug("Multiple display configuration: Den room");
|
||||
$app->{'setup'} = "Multiple display configuration: Den room";
|
||||
|
||||
$wlr_line = "wlr-randr --output ${disp_name} --on --pos 0,0 --output eDP-1 --on --pos ${h},0";
|
||||
}
|
||||
@ -114,6 +117,7 @@ sub get_wlr_line {
|
||||
my ($h, $v) = get_display_current_dimensions($app, $matching_disps->[0]);
|
||||
my $disp_name = $matching_disps->[0]->{'name'};
|
||||
show_debug("Multiple display configuration: Media room");
|
||||
$app->{'setup'} = "Multiple display configuration: Media room";
|
||||
|
||||
$wlr_line = "wlr-randr --output ${disp_name} --on --pos 0,0 --output eDP-1 --on --pos 0,${v}";
|
||||
}
|
||||
@ -144,9 +148,20 @@ sub get_display_current_dimensions {
|
||||
|
||||
return ($disp->{'current_mode'}->{'horizontal'}, $disp->{'current_mode'}->{'vertical'});
|
||||
}
|
||||
# -----------
|
||||
sub notify {
|
||||
my ($app) = @_;
|
||||
|
||||
system("notify-send",
|
||||
"--app-name=get_randr.pl",
|
||||
"--icon=/usr/share/icons/Adwaita/scalable/devices/video-display.svg",
|
||||
"--expire-time=5000",
|
||||
"Display Configuration Changed", "Now set to - $app->{'setup'}");
|
||||
}
|
||||
|
||||
# -----------
|
||||
sub show_debug {
|
||||
my ($str) = @_;
|
||||
# UNCOMMENT TO DEBUG # print "[DEBUG] $str\n";
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user