#!/bin/sh #!/bin/bash #ident "@(#)kolor.sh 1.0 Change the background color of (some) xterm(1) X11 windows - John S. Urban" # $0 color_name # $0 # prompts for a selection #################################################### GETKEY(){ printf "${*}" #BASH#old_tty_settings=$(stty -g) # Save settings. old_tty_settings=`stty -g` # Save settings. stty -icanon #KEY=$(head -c1) #BASH#KEY=$(dd bs=1 count=1 2>/dev/null) KEY=`dd bs=1 count=1 2>/dev/null` stty "$old_tty_settings" # Restore settings. } #################################################### GETKEY(){ printf "keep $COLOR ?" read KEY < $TTY echo } #################################################### if [ "$*" != '' ] then COLOR="$1" esc -bg "$COLOR" FGCOLOR="$2" [ "$FGCOLOR" = '' ] || esc -fg "$FGCOLOR" # set foreground else TTY=`tty` showrgb |while read R G B COLOR COLOR2 do [ "$COLOR2" != '' ] && continue esc -bg "$COLOR" GETKEY "keep $COLOR ?" case "$KEY" in y*|Y*) break;; esac done fi exit