I found this one on the inet. Compile it via the included script and when you execute "getvc"... it'll return the number of the virtual console you're currently in.
Handy little tool. gcc getvc.c -o getvc strip getvc mv getvc /usr/local/bin /* getvc.c * Prints the number of the current VC to stdout. * * Joey Hess, Fri Apr 4 14:58:50 EST 1997 */ #include <sys/vt.h> #include <fcntl.h> main () { int fd = 0; struct vt_stat vt; if ((fd = open("/dev/console",O_WRONLY,0)) < 0) { perror("Failed to open /dev/console\n"); return(2); } if (ioctl(fd, VT_GETSTATE, &vt) < 0) { perror("can't get VTstate\n"); close(fd); return(4); } printf("%d\n",vt.v_active); } /* End of getvc.c */ **************************************************************************** ** Registered Linux User Number 185956 http://groups.google.com/groups?hl=en&safe=off&group=linux 9:50am up 13:22, 3 users, load average: 0.00, 0.00, 0.00 _______________________________________________ Linux-users mailing list Archives, Digests, etc at http://linux.nf/mailman/listinfo/linux-users