2 # Filename: grml-quickconfig
3 # Purpose: get fast access to some basic grml-scripts
4 # Authors: Michael Schierl <schierlm-public@gmx.de>, Alexander Wirt <formorer@grml.org>
5 # Bug-Reports: see http://grml.org/bugs/
6 # License: This file is licensed under the GPL v2.
7 # Latest change: Fre Jun 22 23:05:01 CEST 2007 [mika]
8 ################################################################################
10 # menu with quick config options
13 use Fcntl qw(F_GETFL F_SETFL O_NONBLOCK);
15 # enable alternate charset support (needed for screen)
18 open (my $fh, '/proc/cmdline');
22 my $color = 1 unless $cmdline =~ /nocolor/;
24 # variables for nice display
26 $W = "\e[0;32;1m"; # White
27 $N = "\x0f\e[0m"; # Normal
28 $M = "\e[0;35;1m"; # Magenta (for commands)
29 $B = "\e[0;34;1m\x0e"; # Blue, line drawing characters
35 $HLINE=$B."x".$N; # A single horizontal line drawing character
49 # x and Return are handled manually
74 print "Press a key: ".$M;
75 ReadMode 4; # Turn off controls keys
77 # HACK: this is necessary because startx/Xorg sets the console where it outputs
78 # to non-blocking mode
79 $flags = fcntl(STDIN, F_GETFL, 0) or die "Can't get flags for STDIN: $!\n";
80 $flags = fcntl(STDIN, F_SETFL, $flags & ~O_NONBLOCK) or die "Can't set flags for STDIN: $!\n";
82 while (not defined ($x = ReadKey(0))) {}
83 ReadMode 0; # Reset tty mode before exiting
90 # disable input buffering, see
91 # man perlfunc | less '+/ getc'
93 system "stty", '-icanon', 'eol', "\001";
97 while($command eq "") {
100 ${B}lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk${N}
101 $HLINE Welcome to ${M}grml-quickconfig${M} $HLINE
102 $HLINE Press a highlighted key to perform an action, or press $HLINE
103 $HLINE ${W}Return${N} or ${W}q${N} to go back to the shell. $HLINE
104 ${B}tqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqu${N}
105 $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
106 $HLINE Configure ${W}n${N}etwork (${M}grml-network${N}) $HLINE
107 $HLINE -> Configure ${W}e${N}thernet card directly (${M}netcardconfig${N}) $HLINE
108 ${B}tqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqu${N}
109 $HLINE Show ${W}i${N}nformation about grml (${M}grml-info${N}) $HLINE
110 $HLINE Start ${W}x${N} (${M}grml-x${N}) $HLINE
111 $HLINE Show an application ${W}m${N}enu (${M}pdmenu${N}) $HLINE
112 $HLINE Install grml to ${W}h${N}ard disk (${M}grml2hd${N}) $HLINE
113 ${B}mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj${N}
119 if (defined($menu_commands{$x})) {
120 $command = $menu_commands{$x};
121 } elsif ($x eq "\n" || $x eq ' ') {
123 } elsif ($x eq "x") {
126 ${B}lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk${N}
127 $HLINE Select a window manager (unsorted list): $HLINE
128 $HLINE Press any other key to return to the main menu. $HLINE
129 ${B}tqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqu${N}
130 $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
131 $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
132 $HLINE wm${W}i${N}i wmi-${W}n${N}g ${N}$HLINE
133 ${B}mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj${N}
139 if (defined($windowmanagers{$x})) {
140 $command = "su - grml -c 'grml-x ".$windowmanagers{$x}."'";
142 print "Unknown key, not bound to a windowmanager.\n";
143 print "Returning to main menu.\n";
146 print "Unknown key.\n";
150 # reenable input buffering
151 system "stty", 'icanon', 'eol', '^@';
153 if ($command eq "exit") {
156 print $W . "Running command: " . $M . $command . $N . $/;
160 print "Happy hacking!\n";
162 ## END OF FILE #################################################################
163 # vim: ai expandtab ft=perl