# 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";
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";
${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})) {
${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})) {