X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=usr_sbin%2Fgrml-quickconfig;h=cb4ab85d8f14486da90ae7bde5404fbe5d66b3fa;hb=612a27a90cb7b951fad917a2fad5ba07c5ec519b;hp=ea1395cafbf85f5b2e5b02ddb024a3bd647b7f0a;hpb=10dd4d041f14e5cd0f7bd87d9b9b307d20bc3548;p=grml-scripts.git diff --git a/usr_sbin/grml-quickconfig b/usr_sbin/grml-quickconfig index ea1395c..cb4ab85 100755 --- a/usr_sbin/grml-quickconfig +++ b/usr_sbin/grml-quickconfig @@ -4,12 +4,12 @@ # 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] ################################################################################ # menu with quick config options use Term::ReadKey; +use Fcntl qw(F_GETFL F_SETFL O_NONBLOCK); # enable alternate charset support (needed for screen) print "\e(B\e)0"; @@ -39,6 +39,7 @@ $HLINE=$B."x".$N; # A single horizontal line drawing character a => 'grml-lang at', c => 'grml-lang ch', u => 'grml-lang us', + s => 'grml-lang es', n => 'grml-network', e => 'netcardconfig', i => 'grml-info', @@ -50,16 +51,16 @@ $HLINE=$B."x".$N; # A single horizontal line drawing character # window managers %windowmanagers = ( + a => 'awesome', d => 'dwm', e => 'evilwm', f => 'fluxbox', v => 'fvwm', 2 => 'fvwm2', c => 'fvwm-crystal', - i => 'ion3', j => 'jwm', - p => 'pekwm', - 3 => 'pwm3', + o => 'openbox', + k => 'pekwm', r => 'ratpoison', t => 'twm', 9 => 'w9wm', @@ -68,14 +69,23 @@ $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 "") { @@ -86,7 +96,7 @@ while(1) { $HLINE Press a highlighted key to perform an action, or press $HLINE $HLINE ${W}Return${N} or ${W}q${N} to go back to the shell. $HLINE ${B}tqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqu${N} - $HLINE Set keyboard layout (${M}grml-lang${N}): ${W}d${N}e ${W}a${N}t ${W}c${N}h ${W}u${N}s $HLINE + $HLINE Set keyboard layout (${M}grml-lang${N}): ${W}d${N}e ${W}a${N}t ${W}c${N}h e${W}s${N} ${W}u${N}s $HLINE $HLINE Configure ${W}n${N}etwork (${M}grml-network${N}) $HLINE $HLINE -> Configure ${W}e${N}thernet card directly (${M}netcardconfig${N}) $HLINE ${B}tqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqu${N} @@ -97,42 +107,33 @@ 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 - } - ReadMode 0; # Reset tty mode before exiting + $x = getKey(); print $N.$/.$/; if (defined($menu_commands{$x})) { $command = $menu_commands{$x}; - } elsif ($x eq "\n") { + } elsif ($x eq "\n" || $x eq ' ') { $command= 'exit'; } elsif ($x eq "x") { print <<"EOF"; - ${B}lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk${N} - $HLINE Select a window manager (unsorted list): $HLINE - $HLINE Press any other key to return to the main menu. $HLINE - ${B}tqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqu${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 $HLINE - $HLINE w${W}9${N}wm ${W}w${N}indowlab wm${W}i${N}i wmi-${W}n${N}g $HLINE - ${B}mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj${N} + ${B}lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk${N} + $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}a${N}wesome ${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}j${N}wm ${N}$HLINE + $HLINE ${W}o${N}penbox pe${W}k${N}wm ${W}r${N}atpoison ${W}t${N}wm w${W}9${N}wm ${W}w${N}indowlab wm${W}i${N}i wm-${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 - } - 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.\n"; + print "Unknown key, not bound to a windowmanager.\n"; + print "Returning to main menu.\n"; } } else { print "Unknown key.\n";