[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Inconsistent behaviour of "keystatus" in a waiting loop

From: Andrei Borzenkov
Subject: Re: Inconsistent behaviour of "keystatus" in a waiting loop
Date: Tue, 19 May 2015 06:39:58 +0300

В Mon, 18 May 2015 22:24:00 +0200
"Arbiel (gmx)" <address@hidden> пишет:

> Hi
> I wish to have grub wait until the user has taken a specific action and
> presses down a key, such as control, shift or alt keys to inform the
> action has been taken. It's possible to test this with the keystatus
> --<key> function.
> With the following lines
>     echo "Press Ctrl key down to go on." ;
>     until keystatus --ctrl ; do true ; done ;
>     echo "Ctrl key pressed down." ;
> grub seems to enter and endless loop. However, if the Ctrl key is
> pressed before the "Press Ctrl key down to go on." message is displayed,
> grub immediately exits the loop.

keystatus checks whether key state is "pressed". It has no way to know
since when key is pressed. It does not check for transition, it checks
for state. What behavior you expect when key is pressed before loop

> With
>     until keystatus --alt ; do
>         echo "Press Alt key down to go on" ;
>         sleep -v 3 ;
>         done ;
>     echo "Alt key pressed down." ;
> grubs exits the loop, however after a delay which seems to increase with
> the number of "Press Alt down to go on" displayed before the alt key is
> pressed down.

Not sure I understand what do you mean or how is it different from the
first example.

> How can this behaviour be explained and what should I do to have grub
> react at the pressing of the key ?

Loop while key is pressed; echo message; loop until key is pressed. But
please note that in general it is not even guaranteed that terminal is
capable of returning modifier status at all; so you should first check
whether keystatus is supported on current input source(s), otherwise you
will enter endless loop.

Attachment: pgpEEljShZrZa.pgp
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]