Solidify menu_launch_type

The feature to maximize application would fail from time to time
without obvious reasons, possibly due to slowness of the system
or focus not being ready.

This tries to improve that by making the start-up check default,
previously users had to switch it on manually, and putting it
first (and not last) in the line of checking, so we will know
that the application has started successfully before we attempt
to send the maximize kombos. First, we send the universal one,
Alt-F10, and then a little later another DE specific kombo.

If the first one makes the maximization happen, the second one
does nothing, if it does not work, we still have one more chance.
We do not want to introduce confirmation needles at this point.
This commit is contained in:
Lukáš Růžička 2026-04-10 11:25:43 +02:00
commit 8065013eee

View file

@ -1481,13 +1481,15 @@ sub menu_launch_type {
# Launch an application in a graphical environment, by opening a
# launcher, typing the specified string and hitting enter. Pass
# the string to be typed to launch whatever it is you want.
# A check is performed if app has started.
# Use checkstart => 0 to skip the start-up check.
# Use maximize => 1 to maximize the application after it
# is started.
# Use checkstart => 1 to check that the application has started
# Use timeout => X to override the default timeout (30)
my ($application, %args) = @_;
my $desktop = get_var("DESKTOP");
my $timeout = $args{timeout} // 30;
my $checkstart = $args{checkstart} // 1;
my $animated = $args{animated} // 0;
# The standard combo key is the "super" key, just in I3
@ -1513,9 +1515,24 @@ sub menu_launch_type {
send_key 'ret';
wait_still_screen 3;
# If not switched manually, we check for the application
# to have started successfully.
if ($args{checkstart}) {
assert_screen("apps_run_$application", timeout => $timeout);
}
# If maximizing the application was requested
# with maximize => 1
if ($args{maximize}) {
# Use a universal shortcut first, to maximize the application,
# and wait some time.
if (($desktop eq "kde") or ($desktop eq "gnome")) {
send_key("alt-f10");
}
sleep(3);
# Now, the application should be maximized. However,
# let's send one more shortcut, this time DE specific.
# to double the chance this works (sometimes it would not).
if ($desktop eq "kde") {
send_key('super-pgup');
}
@ -1523,7 +1540,7 @@ sub menu_launch_type {
send_key('super-up');
}
else {
record_soft_failure('Maximizing in this desktop is not supported at the moment!');
record_info('Maximizing in this desktop is not supported at the moment!');
}
if ($animated) {
# can't wait_still_screen if the app's animated
@ -1532,12 +1549,8 @@ sub menu_launch_type {
else {
wait_still_screen 3;
}
}
# If check that app is running was requested
# with checkstart => 1
if ($args{checkstart}) {
assert_screen("apps_run_$application", timeout => $timeout);
# Let's record the screen here for possible troubleshooting.
save_screenshot();
}
}