X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=usr_sbin%2Fgrml-quickconfig;h=2743418033fae7a30699d112278c600a822979e7;hb=aff26085653cc5ef38ac8b7bee649ff124c7f968;hp=d9f1c190ae5eb9f3b843b357a84242d4f3b83ed4;hpb=bb766be3bbef37e2b08c72dfc95eddac05133615;p=grml-scripts.git diff --git a/usr_sbin/grml-quickconfig b/usr_sbin/grml-quickconfig index d9f1c19..2743418 100755 --- a/usr_sbin/grml-quickconfig +++ b/usr_sbin/grml-quickconfig @@ -4,13 +4,13 @@ # Authors: Michael Schierl , Alexander Wirt # Bug-Reports: see http://grml.org/bugs/ # License: This file is licensed under the GPL v2. -# Latest change: Don Apr 12 13:47:04 CEST 2007 [mika] +# Latest change: Fre Jun 22 23:05:01 CEST 2007 [mika] ################################################################################ # 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"; @@ -57,8 +57,8 @@ $HLINE=$B."x".$N; # A single horizontal line drawing character v => 'fvwm', 2 => 'fvwm2', c => 'fvwm-crystal', - i => 'ion3', j => 'jwm', + o => 'openbox', p => 'pekwm', 3 => 'pwm3', r => 'ratpoison', @@ -69,6 +69,21 @@ $HLINE=$B."x".$N; # A single horizontal line drawing character n => 'wm-ng', ); +sub getKey +{ + print "Press a key: ".$M; + ReadMode 4; # Turn off controls keys + + # 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) { @@ -98,13 +113,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})) { @@ -118,25 +127,20 @@ EOF $HLINE Select a window manager (unsorted list): $HLINE $HLINE Press any other key to return to the main menu. $HLINE ${B}tqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqu${N} - $HLINE ${W}d${N}wm ${W}e${N}vilwm ${W}f${N}luxbox f${W}v${N}wm fvwm${W}2${N} fvwm-${W}c${N}rystal ion${W}3 ${N}$HLINE - $HLINE ${W}j${N}wm pe${W}k${N}wm ${W}p${N}wm3 ${W}t${N}wm ${W}r${N}atpoison w${W}9${N}wm ${W}w${N}indowlab ${N}$HLINE + $HLINE ${W}d${N}wm ${W}e${N}vilwm ${W}f${N}luxbox f${W}v${N}wm fvwm${W}2${N} fvwm-${W}c${N}rystal ${W}d${N}wm ${N}$HLINE + $HLINE ${W}o${N}penbox pe${W}k${N}wm ${W}p${N}wm3 ${W}t${N}wm ${W}r${N}atpoison w${W}9${N}wm ${W}w${N}indowlab ${N}$HLINE $HLINE wm${W}i${N}i wmi-${W}n${N}g ${N}$HLINE ${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})) { $command = "su - grml -c 'grml-x ".$windowmanagers{$x}."'"; } else { - print "Unknown key. Returning to main menu.\n"; + print "Unknown key, not bound to a windowmanager.\n"; + print "Returning to main menu.\n"; } } else { print "Unknown key.\n";