grml-quickconfig: integrate jwm
[grml-scripts.git] / usr_sbin / grml-quickconfig
index a8a0df0..c5a5db2 100755 (executable)
@@ -4,12 +4,13 @@
 # Authors:       Michael Schierl <schierlm-public@gmx.de>, Alexander Wirt <formorer@grml.org>
 # Bug-Reports:   see http://grml.org/bugs/
 # License:       This file is licensed under the GPL v2.
-# Latest change: Fre Jun 22 23:05:01 CEST 2007 [mika]
+# Latest change: Die Mär 25 20:37:17 CET 2008 [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";
@@ -50,6 +51,7 @@ $HLINE=$B."x".$N;      # A single horizontal line drawing character
 
 # window managers
 %windowmanagers = (
+    a => 'awesome',
     d => 'dwm',
     e => 'evilwm',
     f => 'fluxbox',
@@ -58,8 +60,7 @@ $HLINE=$B."x".$N;      # A single horizontal line drawing character
     c => 'fvwm-crystal',
     j => 'jwm',
     o => 'openbox',
-    p => 'pekwm',
-    3 => 'pwm3',
+    k => 'pekwm',
     r => 'ratpoison',
     t => 'twm',
     9 => 'w9wm',
@@ -68,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";
@@ -97,10 +107,7 @@ while(1) {
    ${B}mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj${N}
 
 EOF
-  print "Press a key: ".$M;
-  ReadMode 4; # Turn off controls keys
-  while (not defined ($x = ReadKey(0))) {}
-  ReadMode 0; # Reset tty mode before exiting
+  $x = getKey();
 
   print $N.$/.$/;
   if (defined($menu_commands{$x})) {
@@ -114,16 +121,12 @@ 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 ${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
+   $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(0))) {}
-      ReadMode 0; # Reset tty mode before exiting
+      $x = getKey();
 
       print $N.$/.$/;
       if (defined($windowmanagers{$x})) {