[comp.windows.x] Standalone, no reboot X11-beta.1

avr@hou2d.UUCP (Adam V. Reed) (07/31/87)

In order to start the X11-beta.1 on a stand-alone sun, and kill it
without having to re-boot, I'm using the following ksh aliases and
their associated script and program:
alias -x	xkill='kill -9 `ps -g|/bin/grep Xsun|cut -c1-5`'\
		xrun=". $HOME/.xrun 2>/dev/null"
***************** cut here $HOME/.xrun follows *********************
PATH=/usr/X11$PATH
DISPLAY=mysun:0;export DISPLAY
(sleep 10 ; xterm =81x66+657+30) & 2>/dev/null
(sleep 15 ; xterm =81x66+162+30) & 2>/dev/null
(sleep 20; wm)& 2>/dev/null
Xsun >/$HOME/junk 2>&1
fixKbd
clear
***************** cut here fixKbd.c follows ************************
#include "/usr/include/stdio.h"
#include "/usr/include/fcntl.h"
#include "/usr/include/sundev/kbd.h"
#include "kbio.h"

int
main()
{
	register int  kbdFd;
	int zeroisoff=0, trans=TR_ASCII;

	kbdFd = open ("/dev/kbd", O_RDWR, 0);
	if (kbdFd < 0) {
		return (-1);
	}
	(void) ioctl (kbdFd, KIOCSDIRECT, &zeroisoff);
	(void) ioctl (kbdFd, KIOCTRANS, &trans);
	return (0);
}
***************** cut here kbio.h follows **************************
#include "/usr/include/sys/ioctl.h"

/*
 * See sundev/kbd.h for TR_NONE (don't translate) and TR_ASCII
 * (translate to ASCII) TR_EVENT (translate to virtual input
 * device codes)
 */
#define	KIOCTRANS	_IOW(k, 0, int)	/* set keyboard translation */
#define	KIOCGTRANS	_IOR(k, 5, int)	/* get keyboard translation */

#define	KIOCTRANSABLE	_IOW(k, 6, int)	/* set keyboard translatability */
#define	KIOCGTRANSABLE	_IOR(k, 7, int)	/* get keyboard translatability */
#define	TR_CANNOT	0	/* Cannot translate keyboard using tables */
#define	TR_CAN		1	/* Can translate keyboard using tables */
#define	KIOCABORT1	-1	/* Special "mask": abort1 keystation */
#define	KIOCABORT2	-2	/* Special "mask": abort2 keystation */

/*
 * Set kio_tablemask table's kio_station to kio_entry.
 * Copy kio_string to string table if kio_entry is between STRING and
 * STRING+15.  EINVAL is possible if there are invalid arguments.
 */
#define	KIOCSETKEY	_IOW(k, 1, struct kiockey)

/*
 * Get kio_tablemask table's kio_station to kio_entry.
 * Get kio_string from string table if kio_entry is between STRING and
 * STRING+15.  EINVAL is possible if there are invalid arguments.
 */
#define	KIOCGETKEY	_IOWR(k, 2, struct kiockey)

/*
 * Send the keyboard device a control command.  sundev/kbd.h contains
 * the constants that define the commands.  Normal values are:
 * KBD_CMD_BELL, KBD_CMD_NOBELL, KBD_CMD_CLICK, KBD_CMD_NOCLICK.
 * Inappropriate commands for particular keyboard types are ignored.
 *
 * Since there is no reliable way to get the state of the bell or click
 * or LED (because we can't query the kdb, and also one could do writes
 * to the appropriate serial driver--thus going around this ioctl)
 * we don't provide an equivalent state querying ioctl. 
 */
#define	KIOCCMD		_IOW(k, 8, int)	/* Send keyboard command */

/*
 * Get keyboard type.  Return values are one of KB_* from sundev/kbd.h,
 * e.g., KB_KLUNK, KB_VT100, KB_SUN2, KB_SUN3, KB_ASCII.  -1 means that
 * the type is not known.
 */
#define	KIOCTYPE	_IOR(k, 9, int)	/* get keyboard type */

/*
 * Set flag indicating whether keystrokes get routed to /dev/console.
 */
#define	KIOCSDIRECT	_IOW(k, 10, int)

/*
 * Get flag indicating whether keystrokes get routed to /dev/console.
 */
#define	KIOCGDIRECT	_IOR(k, 11, int)