[comp.sys.sgi] Saving window positions

andru@electron.lcs.mit.edu (Andrew Myers) (05/11/91)

Here's a much easier way to customize your window positions. Extracting
this shar archive and installing it will cause a new entry labeled
"PrefPos" to appear on the window menu. Selecting this entry will
cause the window to be positioned there from then on out.

To install: save below "cut here" to /usr/tmp/x
Then do:
    sh x
    cd prefpos
    make

Warning: installation of the script appends to the end of your user.ps.
It also creates a .4sight directory in your home directory, if none
exists. To remove a preference, you must edit .4sight/prefpos.ps and
delete the appropriate line (it will be fairly obvious).

----- cut here -----
#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  prefpos prefpos/Description prefpos/Makefile
#   prefpos/prefpos.ps prefpos/user.ps
# Wrapped by andru@brokaw on Fri May 10 14:32:53 1991
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test ! -d 'prefpos' ; then
    echo shar: Creating directory \"'prefpos'\"
    mkdir 'prefpos'
fi
if test -f 'prefpos/Description' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'prefpos/Description'\"
else
echo shar: Extracting \"'prefpos/Description'\" \(256 characters\)
sed "s/^X//" >'prefpos/Description' <<'END_OF_FILE'
X    A 4Sight customization which allows you to specify window location
X    preferences from the window border menu. No more PostScript hacking
X    to specify your preferences! Preferences are saved
X    from session to session, courtesy of The Michael Toy.
END_OF_FILE
if test 256 -ne `wc -c <'prefpos/Description'`; then
    echo shar: \"'prefpos/Description'\" unpacked with wrong size!
fi
# end of 'prefpos/Description'
fi
if test -f 'prefpos/Makefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'prefpos/Makefile'\"
else
echo shar: Extracting \"'prefpos/Makefile'\" \(326 characters\)
sed "s/^X//" >'prefpos/Makefile' <<'END_OF_FILE'
SHELL = /bin/sh
NEWSDIR = $(HOME)/.4sight
USERPS = $(HOME)/user.ps
INSTALL = /etc/install -root "" -u $(USER)
install:
X	@echo 'Checking '$(USERPS)' for customization...'
X	@if fgrep -c 'PrefPos cust' $(USERPS) > /dev/null; then echo 'Already customized'; else cat user.ps >> $(USERPS); fi
X	@$(INSTALL) -F $(NEWSDIR) prefpos.ps
END_OF_FILE
if test 326 -ne `wc -c <'prefpos/Makefile'`; then
    echo shar: \"'prefpos/Makefile'\" unpacked with wrong size!
fi
# end of 'prefpos/Makefile'
fi
if test -f 'prefpos/prefpos.ps' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'prefpos/prefpos.ps'\"
else
echo shar: Extracting \"'prefpos/prefpos.ps'\" \(3670 characters\)
sed "s/^X//" >'prefpos/prefpos.ps' <<'END_OF_FILE'
X%%%%%%% PrefPos customization %%%%%%%%%%%%%%%%%%%%
X% Window customizations
X% Change icon shape, and the position of the message
X% Add the PrefPos entry to the menu
X%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
X
SGIWindow begin
X    /CreateFrameMenu { % - => - (Create frame menu)
X        % Note: Store menu in class to share menus, especially if retained.
X        % Note#2: sgiwin knows that "Quit" is the last thing on the menu
X        /FrameMenu [
X            (Pop)               {/totop ThisWindow send}
X            (Push)              {/tobottom ThisWindow send}
X            (PrefPos)		
X		{
X	    	     /IconLabel ThisWindow send
X		     /ClientCanvas ThisWindow send
X		     setcanvas getcanvasshape setpath pathbbox
X		     /ClientCanvas ThisWindow send
X		     dup
X		     framebuffer setcanvas
X		     getcanvaslocation % lx by rx ty canvas ox oy
X		     %
X		     % Note: this assumes that lx & by = 0
X		     %
X		     3 -1 roll setcanvas     % lx by rx ty ox oy
X		     6 -2 roll pop pop	     % rx ty ox oy
X		     4 2 roll		     % ox oy rx ty
X		     xfc 5 1 roll        % 1.333 ox oy rx ty
X		     4 index mul 4 1 roll    % 1.333 ty' ox oy rx
X		     4 index mul 4 1 roll    %  .
X		     4 index mul 4 1 roll    %  .
X		     4 index mul 4 1 roll    % 1.333 ox' oy' rx' ty'
X		     5 -1 roll pop           % (name) ox' oy' rx' ty'
X		     AddPermanentPreference
X		     prefposition
X		 }
X            (Move)              {/slide ThisWindow send}
X	    (Resize)            {/reshapefromuser ThisWindow send}
X            (Stow)              {/flipiconic ThisWindow send}
X            (Close)             {/shutOrQuit ThisWindow send}
X            (Quit ) applicationLabel append {/destroy ThisWindow send}
X        ] /new DefaultMenu send def
X        6 /addline FrameMenu send
X	/IconLabel ThisWindow send () eq
X	    { (PrefPos) /disable FrameMenu send } if
X        (Window) /settitle FrameMenu send
X    } def
end
X
X/prefFile (.4sight/pref.ps) def
X/tmpPrefDict null def
X/AddPermanentPreference {
X    /tmpPrefDict 100 dict store
X    10 dict begin
X	/preforigin {
X	    5 dict begin
X		dup type /arraytype eq {
X		    /opts exch def
X		    /y exch def
X		    /x exch def
X		    /name exch def
X		    /value (% % [) [ x y ] sprintf def
X		    opts {
X			dup type /nametype eq {
X			    (% /%) [ value 3 index ] sprintf
X			} {
X			    (% %) [ value 3 index ] sprintf
X			} ifelse
X			/value exch def
X			pop
X		    } forall
X		    /value value ( ]) append def
X		    tmpPrefDict name value put
X		} {
X		    exch (% %) sprintf
X		    exch /name exch def
X		    tmpPrefDict name 3 -1 roll put
X		} ifelse
X		tmpPrefDict name 2 copy get ( preforigin) append put
X	    end
X	} def
X
X	/prefposition {
X	    7 dict begin
X		dup type /arraytype eq {
X		    /opts exch def
X		    /yp exch def
X		    /xp exch def
X		    /y exch def
X		    /x exch def
X		    /name exch def
X		    /value (% % % % [) [ x y xp yp ] sprintf def
X		    opts {
X			dup type /nametype eq {
X			    (% /%) [ value 3 index ] sprintf
X			} {
X			    (% %) [ value 3 index ] sprintf
X			} ifelse
X			/value exch def
X		    } forall
X		    /value value ( ]) append def
X		    tmpPrefDict name value put
X		} {
X		    exch 4 2 roll exch
X		    (% % % %) sprintf
X		    exch /name exch def
X		    tmpPrefDict name 3 -1 roll put
X		} ifelse
X		tmpPrefDict name 2 copy get ( prefposition) append put
X	    end
X	} def
X
X	/prefalias {
X	    (\(%\) prefalias) sprintf
X	    tmpPrefDict 3 1 roll put
X	} def
X
X	prefFile (r) { file } stopped { pop pop } { cvx exec } ifelse
X
X	/pout prefFile (w) file def
X	tmpPrefDict {
X	    exch
X	    pout 3 1 roll
X	    (\(%\) %\n) fprintf
X	} forall
X
X	5 copy pout 6 1 roll
X	exch 3 -1 roll 5 -2 roll exch
X	(\(%\) % % % % prefposition\n) fprintf
X    end
X} def
END_OF_FILE
if test 3670 -ne `wc -c <'prefpos/prefpos.ps'`; then
    echo shar: \"'prefpos/prefpos.ps'\" unpacked with wrong size!
fi
# end of 'prefpos/prefpos.ps'
fi
if test -f 'prefpos/user.ps' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'prefpos/user.ps'\"
else
echo shar: Extracting \"'prefpos/user.ps'\" \(122 characters\)
sed "s/^X//" >'prefpos/user.ps' <<'END_OF_FILE'
X%%% PrefPos customization %%%
X{ (.4sight/prefpos.ps) LoadFile } stopped pop
X{ (.4sight/pref.ps)    LoadFile } stopped pop
END_OF_FILE
if test 122 -ne `wc -c <'prefpos/user.ps'`; then
    echo shar: \"'prefpos/user.ps'\" unpacked with wrong size!
fi
# end of 'prefpos/user.ps'
fi
echo shar: End of shell archive.
exit 0