X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=usr_sbin%2Fgrml-quickconfig;h=29fcd47587d1f0eb7fe2b558d286f2a5bde20f93;hb=ae1b256efa526deed800fef5a985ece7749020bf;hp=a7c2a9bdc991caa24b9642f9a5c3cac2c538b233;hpb=561b409b63346bb95f6e077a403afddef26c4417;p=grml-scripts.git diff --git a/usr_sbin/grml-quickconfig b/usr_sbin/grml-quickconfig index a7c2a9b..29fcd47 100755 --- a/usr_sbin/grml-quickconfig +++ b/usr_sbin/grml-quickconfig @@ -10,7 +10,7 @@ # menu with quick config options use Term::ReadKey; -use Time::HiRes; +use Fcntl qw(F_GETFL F_SETFL O_NONBLOCK); # enable alternate charset support (needed for screen) print "\e(B\e)0"; @@ -69,15 +69,24 @@ $HLINE=$B."x".$N; # A single horizontal line drawing character n => 'wm-ng', ); -# main loop -while(1) { +sub getKey +{ + print "Press a key: ".$M; + ReadMode 4; # Turn off controls keys -# disable input buffering, see -# man perlfunc | less '+/ getc' -# for details - system "stty", '-icanon', 'eol', "\001"; + # HACK: this is necessary because startx/Xorg sets the console where it outputs + # to non-blocking mode + $flags = fcntl(STDIN, F_GETFL, 0) or die "Can't get flags for STDIN: $!\n"; + $flags = fcntl(STDIN, F_SETFL, $flags & ~O_NONBLOCK) or die "Can't set flags for STDIN: $!\n"; + + while (not defined ($x = ReadKey(0))) {} + ReadMode 0; # Reset tty mode before exiting + return $x; +} # main loop +while(1) { +# main loop $command=""; while($command eq "") { print <<"EOF"; @@ -98,13 +107,7 @@ while(1) { ${B}mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj${N} EOF - print "Press a key: ".$M; - ReadMode 4; # Turn off controls keys - while (not defined ($x = ReadKey(-1))) { - # No key yet - Time::HiRes::sleep(0.5); - } - ReadMode 0; # Reset tty mode before exiting + $x = getKey(); print $N.$/.$/; if (defined($menu_commands{$x})) { @@ -124,13 +127,7 @@ EOF ${B}mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj${N} EOF - print "Press a key: ".$M; - ReadMode 4; # Turn off controls keys - while (not defined ($x = ReadKey(-1))) { - # No key yet - Time::HiRes::sleep(0.5); - } - ReadMode 0; # Reset tty mode before exiting + $x = getKey(); print $N.$/.$/; if (defined($windowmanagers{$x})) {