projects
/
grml-scripts.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
3ea9195
)
streamlined getting key into a separate function
author
Michael Gebetsroither
<michael.geb@gmx.at>
Tue, 13 Nov 2007 10:32:43 +0000
(11:32 +0100)
committer
Michael Gebetsroither
<michael.geb@gmx.at>
Tue, 13 Nov 2007 10:32:43 +0000
(11:32 +0100)
usr_sbin/grml-quickconfig
patch
|
blob
|
history
diff --git
a/usr_sbin/grml-quickconfig
b/usr_sbin/grml-quickconfig
index
e3293f7
..
2743418
100755
(executable)
--- a/
usr_sbin/grml-quickconfig
+++ b/
usr_sbin/grml-quickconfig
@@
-10,6
+10,7
@@
# menu with quick config options
use Term::ReadKey;
# 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";
# enable alternate charset support (needed for screen)
print "\e(B\e)0";
@@
-68,6
+69,21
@@
$HLINE=$B."x".$N; # A single horizontal line drawing character
n => 'wm-ng',
);
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
while(1) {
@@
-97,12
+113,7
@@
while(1) {
${B}mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj${N}
EOF
${B}mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj${N}
EOF
- print "Press a key: ".$M;
- ReadMode 4; # Turn off controls keys
- $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
+ $x = getKey();
print $N.$/.$/;
if (defined($menu_commands{$x})) {
print $N.$/.$/;
if (defined($menu_commands{$x})) {
@@
-122,12
+133,7
@@
EOF
${B}mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj${N}
EOF
${B}mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj${N}
EOF
- print "Press a key: ".$M;
- ReadMode 4; # Turn off controls keys
- $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
+ $x = getKey();
print $N.$/.$/;
if (defined($windowmanagers{$x})) {
print $N.$/.$/;
if (defined($windowmanagers{$x})) {