bt-audio: check for presence of snd-bt-sco
[grml-scripts.git] / usr_sbin / grml-quickconfig
1 #!/usr/bin/perl
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: Mon Dez 17 22:31:30 CET 2007 [mika]
8 ################################################################################
9
10 # menu with quick config options
11
12 use Term::ReadKey;
13 use Fcntl qw(F_GETFL F_SETFL O_NONBLOCK);
14
15 # enable alternate charset support (needed for screen)
16 print "\e(B\e)0";
17
18 open (my $fh, '/proc/cmdline');
19 my $cmdline = <$fh>;
20 close($fh);
21
22 my $color = 1 unless $cmdline =~ /nocolor/;
23
24 # variables for nice display
25 if ($color) {
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
30 } else {
31     $B = "\x0e";
32     $N = "\x0f";
33 }
34
35 $HLINE=$B."x".$N;      # A single horizontal line drawing character
36
37 # menu options
38 %menu_commands = (
39     d => 'grml-lang de',
40     a => 'grml-lang at',
41     c => 'grml-lang ch',
42     u => 'grml-lang us',
43     n => 'grml-network',
44     e => 'netcardconfig',
45     i => 'grml-info',
46     h => 'grml2hd',
47     m => 'pdmenu -c',
48     q => 'exit',
49 # x and Return are handled manually
50 );
51
52 # window managers
53 %windowmanagers = (
54     d => 'dwm',
55     e => 'evilwm',
56     f => 'fluxbox',
57     v => 'fvwm',
58     2 => 'fvwm2',
59     c => 'fvwm-crystal',
60     o => 'openbox',
61     k => 'pekwm',
62     p => 'pwm3',
63     r => 'ratpoison',
64     t => 'twm',
65     9 => 'w9wm',
66     w => 'windowlab',
67     i => 'wmii',
68     n => 'wm-ng',
69 );
70
71 sub getKey
72 {
73   print "Press a key: ".$M;
74   ReadMode 4; # Turn off controls keys
75
76   # HACK: this is necessary because startx/Xorg sets the console where it outputs
77   #       to non-blocking mode
78   $flags = fcntl(STDIN, F_GETFL, 0) or die "Can't get flags for STDIN: $!\n";
79   $flags = fcntl(STDIN, F_SETFL, $flags & ~O_NONBLOCK) or die "Can't set flags for STDIN: $!\n";
80
81   while (not defined ($x = ReadKey(0))) {}
82   ReadMode 0; # Reset tty mode before exiting
83   return $x;
84 }
85
86 # main loop
87 while(1) {
88 # main loop
89     $command="";
90     while($command eq "") {
91   print <<"EOF";
92
93    ${B}lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk${N}
94    $HLINE Welcome to ${M}grml-quickconfig${M}                            $HLINE
95    $HLINE Press a highlighted key to perform an action, or press $HLINE
96    $HLINE ${W}Return${N} or ${W}q${N} to go back to the shell.                   $HLINE
97    ${B}tqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqu${N}
98    $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
99    $HLINE Configure ${W}n${N}etwork (${M}grml-network${N})                       $HLINE
100    $HLINE -> Configure ${W}e${N}thernet card directly (${M}netcardconfig${N})    $HLINE
101    ${B}tqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqu${N}
102    $HLINE Show ${W}i${N}nformation about grml (${M}grml-info${N})                $HLINE
103    $HLINE Start ${W}x${N} (${M}grml-x${N})                                       $HLINE
104    $HLINE Show an application ${W}m${N}enu (${M}pdmenu${N})                      $HLINE
105    $HLINE Install grml to ${W}h${N}ard disk (${M}grml2hd${N})                    $HLINE
106    ${B}mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj${N}
107
108 EOF
109   $x = getKey();
110
111   print $N.$/.$/;
112   if (defined($menu_commands{$x})) {
113       $command = $menu_commands{$x};
114   } elsif ($x eq "\n" || $x eq ' ') {
115       $command= 'exit';
116   } elsif ($x eq "x") {
117       print <<"EOF";
118
119    ${B}lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk${N}
120    $HLINE Select a window manager (unsorted list):                $HLINE
121    $HLINE Press any other key to return to the main menu.         $HLINE
122    ${B}tqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqu${N}
123    $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}             ${N}$HLINE
124    $HLINE ${W}o${N}penbox pe${W}k${N}wm ${W}p${N}wm3 ${W}r${N}atpoison ${W}t${N}wm w${W}9${N}wm ${W}w${N}indowlab         ${N}$HLINE
125    $HLINE wm${W}i${N}i wm-${W}n${N}g                                              ${N}$HLINE
126    ${B}mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj${N}
127
128 EOF
129       $x = getKey();
130
131       print $N.$/.$/;
132       if (defined($windowmanagers{$x})) {
133     $command = "su - grml -c 'grml-x ".$windowmanagers{$x}."'";
134       } else {
135     print "Unknown key, not bound to a windowmanager.\n";
136     print "Returning to main menu.\n";
137       }
138   } else {
139       print "Unknown key.\n";
140   }
141     }
142
143 # reenable input buffering
144     system "stty", 'icanon', 'eol', '^@';
145
146     if ($command eq "exit") {
147   last;
148     }
149     print $W . "Running command: " . $M . $command . $N . $/;
150     system($command);
151     print $/;
152 }
153 print "Happy hacking!\n";
154
155 ## END OF FILE #################################################################
156 # vim: ai expandtab ft=perl