From: Jacek K. <kop...@in...> - 2000-05-16 22:19:17
|
Hello. 8-) You might have seen this on lkml but I only got one response then... I'd like to know if this has any value or if I should just keep my small patch for myself. Your opinions? Following is the description of a patch to console.c and console_macros.c from 2.2.12 (I know it's old but I don't know if I should work on integrating my changes into your linuxcosole sets). Also the patch itself is added. Here's what I sent then: I always wanted the console to be able to alert me when something happened in it. So I started writing a patch to allow me to set a virtual console so that it gets switched to whenever it beeps. I then expanded it so that now you can: - have the vc switched to when it beeps, - have the vc switched to when anything is written to it, - have the vc beep whenever anything is written to it - do nothing of the above. 8-) My current additions to get you interested: Why would I like the console to beep/get switched to on write? I'd want that in cases when I want to know that something happened (peer in talk woke up, long computation ended etc.) Once somebody suggested reading /dev/vcs$N periodically but that doesn't work if nothing actually changes on the console (cursor movements for example). But yes, userspace daemon would usually do, but since I was doing the other switch (on beep) that cannot be done in userspace (afaik) I could as well add this. 8-) So why would I like the console to be switched to on beep? Again if my peer in talk wanted my attention, they could beep. I'd then be switched right into the console without having to look for the source of the beep. So again - I'll appreciate your ideas on whether to continue or forget this. 8-) Jacek Kopecky The patch: ---------------------------------------------------------- diff -u --recursive linux-2.2.12/drivers/char/console.c linux/drivers/char/console.c --- linux-2.2.12/drivers/char/console.c Thu Mar 11 01:51:35 1999 +++ linux/drivers/char/console.c Thu Jul 15 11:55:38 1999 @@ -66,6 +66,8 @@ * * Resurrected character buffers in videoram plus lots of other trickery * by Martin Mares <mj...@at...>, July 1998 + * + * Console alertness by Jacek Kopecky <ja...@un...>, July 1999 */ #include <linux/module.h> @@ -1263,6 +1265,10 @@ case 14: /* set vesa powerdown interval */ vesa_off_interval = ((par[1] < 60) ? par[1] : 60) * 60 * HZ; break; + case 15: /* set console alertness: + 1 beep on write, 2 switch on beep , 3 switch on write*/ + alert = (par[1] > 2) ? 3 : par[1]; + break; } } @@ -1402,6 +1408,8 @@ save_cur(currcons); if (do_clear) csi_J(currcons,2); + + alert = 0; } static void do_con_trol(struct tty_struct *tty, unsigned int currcons, int c) @@ -1416,6 +1424,9 @@ case 7: if (bell_duration) kd_mksound(bell_pitch, bell_duration); + /* switch console if alertness on beep */ + if ((alert == 2) && (currcons != fg_console)) + change_console(currcons); return; case 8: bs(currcons); @@ -1927,6 +1938,16 @@ } FLUSH enable_bh(CONSOLE_BH); + + /* Switch to this console if alertness is 3 + * or beep if alertness is 1 + */ + if (alert && (currcons != fg_console)) { + if (alert == 3) change_console(currcons); + else if ((alert == 1) && bell_duration) + kd_mksound(bell_pitch, bell_duration); + } + return n; #undef FLUSH } diff -u --recursive linux-2.2.12/drivers/char/console_macros.h linux/drivers/char/console_macros.h --- linux-2.2.12/drivers/char/console_macros.h Thu Sep 17 18:35:03 1998 +++ linux/drivers/char/console_macros.h Wed Jun 30 20:50:00 1999 @@ -64,6 +64,7 @@ #define complement_mask (vc_cons[currcons].d->vc_complement_mask) #define s_complement_mask (vc_cons[currcons].d->vc_s_complement_mask) #define hi_font_mask (vc_cons[currcons].d->vc_hi_font_mask) +#define alert (vc_cons[currcons].d->vc_alert) #define vcmode (vt_cons[currcons]->vc_mode) diff -u --recursive linux-2.2.12/include/linux/console_struct.h linux/include/linux/console_struct.h --- linux-2.2.12/include/linux/console_struct.h Thu Sep 17 18:35:04 1998 +++ linux/include/linux/console_struct.h Wed Jun 30 22:45:11 1999 @@ -65,6 +65,7 @@ unsigned int vc_can_do_color : 1; unsigned int vc_report_mouse : 2; unsigned int vc_kmalloced : 1; + unsigned int vc_alert : 2; /* Switch to this console on write or beep */ unsigned char vc_utf : 1; /* Unicode UTF-8 encoding */ unsigned char vc_utf_count; int vc_utf_char; diff -u --recursive --new-file linux-2.2.12/Documentation/console-alertness linux/Documentation/console-alertness --- linux-2.2.12/Documentation/console-alertness Thu Jan 1 01:00:00 1970 +++ linux/Documentation/console-alertness Fri Aug 6 22:45:45 1999 @@ -0,0 +1,31 @@ +This file describes the console alertness function of linux virtual consoles +as implemented by Jacek Kopecky (ja...@un...) in July 1999. + +First, what does console alertness mean anyway? +In cases when you want to be warned when something changes or only beeps on a +virtual console other than the one that's active at the moment (so that you +don't see the changes yourself), you can use the following escape sequences +to set the console-alertness-level to get some warnings: + +echo -ne "\033[15;0]" > /dev/ttyX alertnes off ("beep on beep") +echo -ne "\033[15;1]" > /dev/ttyX beep on write to the console +echo -ne "\033[15;2]" > /dev/ttyX switch to the console on beep +echo -ne "\033[15;3]" > /dev/ttyX switch to the console on write + +At the level 1 the virtual console /dev/ttyX beeps whenever anything is +written to it but only if the console is not currently the foreground console. +The level 2 makes the console get switched to whenever it beeps. On the highest +level the console gets switched to on each write to it. + +A side-effect of setting beep-on-write (1) or switch-on-write (3) on another +console is that the other console beeps or is switched to, this comes handy +as a test it's working. 8-) +The sequence for setting the switch-on-beep (2) level can be enhanced to give +the same kind of test: + +echo -ne "\033[15;2]\a" > /dev/ttyX + +The setting sequences may seem to be a little too user-unfriendly so I'm +planning to try to incorporate alertness setting into the setterm package. + +Enjoy. 8-) |