Lieber Besucher, herzlich willkommen bei: Linux Forum Linux-Web.de. Falls dies Ihr erster Besuch auf dieser Seite ist, lesen Sie sich bitte die Hilfe durch. Dort wird Ihnen die Bedienung dieser Seite näher erläutert. Darüber hinaus sollten Sie sich registrieren, um alle Funktionen dieser Seite nutzen zu können. Benutzen Sie das Registrierungsformular, um sich zu registrieren oder informieren Sie sich ausführlich über den Registrierungsvorgang. Falls Sie sich bereits zu einem früheren Zeitpunkt registriert haben, können Sie sich hier anmelden.
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »E²³« (25.10.2009, 20:28)
Quellcode |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
#!/usr/bin/perl # Filename: grml-quickconfig # Purpose: get fast access to some basic grml-scripts # 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: 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"; open (my $fh, '/proc/cmdline'); my $cmdline = <$fh>; close($fh); my $color = 1 unless $cmdline =~ /nocolor/; # variables for nice display if ($color) { $W = "\e[0;32;1m"; # White $N = "\x0f\e[0m"; # Normal $M = "\e[0;35;1m"; # Magenta (for commands) $B = "\e[0;34;1m\x0e"; # Blue, line drawing characters } else { $B = "\x0e"; $N = "\x0f"; } $HLINE=$B."x".$N; # A single horizontal line drawing character # menu options %menu_commands = ( d => 'grml-lang de', a => 'grml-lang at', c => 'grml-lang ch', u => 'grml-lang us', n => 'grml-network', e => 'netcardconfig', i => 'grml-info', h => 'grml2hd', m => 'pdmenu -c', q => 'exit', # x and Return are handled manually ); # window managers %windowmanagers = ( a => 'awesome', d => 'dwm', e => 'evilwm', f => 'fluxbox', v => 'fvwm', 2 => 'fvwm2', c => 'fvwm-crystal', j => 'jwm', o => 'openbox', k => 'pekwm', r => 'ratpoison', t => 'twm', 9 => 'w9wm', w => 'windowlab', i => 'wmii', 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) { # main loop $command=""; while($command eq "") { print <<"EOF"; ${B}lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk${N} $HLINE Welcome to ${M}grml-quickconfig${M} $HLINE $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 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} $HLINE Show ${W}i${N}nformation about grml (${M}grml-info${N}) $HLINE $HLINE Start ${W}x${N} (${M}grml-x${N}) $HLINE $HLINE Show an application ${W}m${N}enu (${M}pdmenu${N}) $HLINE $HLINE Install grml to ${W}h${N}ard disk (${M}grml2hd${N}) $HLINE ${B}mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj${N} EOF $x = getKey(); print $N.$/.$/; if (defined($windowmanagers{$x})) { $command = "su - grml -c 'grml-x ".$windowmanagers{$x}."'"; } else { print "Unknown key, not bound to a windowmanager.\n"; print "Returning to main menu.\n"; } } else { print "Unknown key.\n"; } } # reenable input buffering system "stty", 'icanon', 'eol', '^@'; if ($command eq "exit") { last; } print $W . "Running command: " . $M . $command . $N . $/; system($command); print $/; } print "Happy hacking!\n"; ## END OF FILE ################################################################# # vim: ai expandtab ft=perl |
Benutzerinformationen überspringen
Prof. Dr. Schlaumeier
Wohnort: Mecklenburg, zur Entwicklungshilfe in Chemnitz/Sachsen ;-)
Zitat
Original von PacWhite
ist es Möglich wie in MS DOS eine art System Menü zu
basteln Mit Echo befehle und ./ befehle? zum starten von sachen?
wenn ja würd mir jemannd auf dumme art erklären wie ? damit ich das kappier?