#!/bin/bash ### # Keyboard toggle script # Copyright (C) Thomas "ShALLaX" Pedley (gentoox@shallax.com) # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ### if [ `whoami` != "root" ]; then echo "You must be logged in as root to use this utility" exit fi ### # If xvkbd isnt installed, dont execute ### if [ -z `grep -m1 -i xvkbd-patch /etc/conf.d/magic-database` ]; then echo "You must first install xvkbd, run magic" exit fi ### # When adding the no-keyboard script, this file needed to exist before # the script would work, so it is made here ### if [ -z `grep -m1 -i noxvkbd1 /etc/conf.d/magic-database` ]; then echo onxvkbd1 >> /etc/conf.d/magic-database chown root:root /etc/conf.d/magic-database chmod 600 /etc/conf.d/magic-database fi ### # Check to see if its enabled first and that its installed ### if [ ! -z `grep -m1 -i onxvkbd1 /etc/conf.d/magic-database` ]; then if [ ! -z `grep -m1 -i xvkbd-patch /etc/conf.d/magic-database` ]; then ### # Activation file deleted. File created to tell magic it is no longer # activated. ### grep -vi onxvkbd1 /etc/conf.d/magic-database >> /etc/conf.d/magic-database.tmp mv /etc/conf.d/magic-database.tmp /etc/conf.d/magic-database chown root:root /etc/conf.d/magic-database chmod 600 /etc/conf.d/magic-database echo "noxvkbd1" >> /etc/conf.d/magic-database ### # Add a # (hash mark) to comment out the xvkbd line in all .xinitrc files # it is important to only comment the lines out because using xbvset # also changes the geometry on these lines. If the line is deleted, it # may be reinserted using the wrong geometry for the screen resolution # meaning the user has to run "xbvset" to correct it. ### sed "s/\/usr\/bin\/X11\/xvkbd/#\/usr\/bin\/X11\/xvkbd/" /home/gentoox/.xinitrc > /tmp/xinitrc rm -rf /home/gentoox/.xinitrc mv /tmp/xinitrc /home/gentoox/.xinitrc chmod 755 /home/gentoox/.xinitrc chown gentoox:users /home/gentoox/.xinitrc sed "s/\/usr\/bin\/X11\/xvkbd/#\/usr\/bin\/X11\/xvkbd/" /etc/skel/.xinitrc > /tmp/xinitrc rm -rf /etc/skel/.xinitrc mv /tmp/xinitrc /etc/skel/.xinitrc chmod 755 /etc/skel/.xinitrc sed "s/\/usr\/bin\/X11\/xvkbd/#\/usr\/bin\/X11\/xvkbd/" /root/.xinitrc > /tmp/xinitrc rm -rf /root/.xinitrc mv /tmp/xinitrc /root/.xinitrc chmod 755 /root/.xinitrc echo "Onscreen keyboard disabled" exit fi fi ### # Is the keyboard disabled and installed? ### if [ ! -z `grep -m1 -i noxvkbd1 /etc/conf.d/magic-database` ]; then if [ ! -z `grep -m1 -i xvkbd-patch /etc/conf.d/magic-database` ]; then grep -vi noxvkbd1 /etc/conf.d/magic-database >> /etc/conf.d/magic-database.tmp mv /etc/conf.d/magic-database.tmp /etc/conf.d/magic-database chown root:root /etc/conf.d/magic-database chmod 600 /etc/conf.d/magic-database echo "onxvkbd1" >> /etc/conf.d/magic-database ### # sed the # away from the beginning of the xvkbd lines in the .xinitrc files ### sed "s/#\/usr\/bin\/X11\/xvkbd/\/usr\/bin\/X11\/xvkbd/" /home/gentoox/.xinitrc > /tmp/xinitrc rm -rf /home/gentoox/.xinitrc mv /tmp/xinitrc /home/gentoox/.xinitrc chmod 755 /home/gentoox/.xinitrc chown gentoox:users /home/gentoox/.xinitrc sed "s/#\/usr\/bin\/X11\/xvkbd/\/usr\/bin\/X11\/xvkbd/" /etc/skel/.xinitrc > /tmp/xinitrc rm -rf /etc/skel/.xinitrc mv /tmp/xinitrc /etc/skel/.xinitrc chmod 755 /etc/skel/.xinitrc sed "s/#\/usr\/bin\/X11\/xvkbd/\/usr\/bin\/X11\/xvkbd/" /root/.xinitrc > /tmp/xinitrc rm -rf /root/.xinitrc mv /tmp/xinitrc /root/.xinitrc chmod 755 /root/.xinitrc echo "Onscreen keyboard enabled" exit fi fi