toml@ninja.Solbourne.COM (Tom LaStrange) (02/03/90)
During the X Technical conference I attended the session managers BOF and said that I would post a description of the primitive session managerment that I have incorporated into swm. The following example works sufficiently well, such that a simple "toolplaces" can be done. swm supports a command called f.places which simple writes out a file that is suitable for use as a .xinitrc file. In fact, the command can even be instructed to write $HOME/.xinitrc for very novice users. Anyway, here is an example file written out by the swm f.places command. 1 #! /bin/sh 2 3 #********************************************************************** 4 # 5 # X startup script generated by the f.places swm command 6 # 7 #********************************************************************** 8 if [ -x $HOME/.xinitrc.local ] 9 then 10 $HOME/.xinitrc.local 11 fi 12 13 #********************************************************************** 14 # Screen 0 15 #********************************************************************** 16 DISPLAY=unix:0.0 17 export DISPLAY 18 25 swmhints -geometry 160x12+4+708 -iconGeometry +0+0 -state NormalState -cmd "xterm -geom 150x23+4+565 -name ninja -T ninja -e rlogin ninja " 26 xterm -geom 150x23+4+565 -name ninja -T ninja -e rlogin ninja & 27 40 swmhints -geometry 508x750+214+58 -iconGeometry +1028+73 -state IconicState -rootIcon -cmd "xmh " 41 xmh & 42 43 swmhints -geometry 171x231+399+203 -iconGeometry +1016+132 -state IconicState -rootIcon -cmd "xcalc " 44 xcalc & 45 46 47 #********************************************************************** 48 # Screen 1 49 #********************************************************************** 50 DISPLAY=unix:0.1 51 export DISPLAY 52 59 swmhints -geometry 90x85+1047+716 -iconGeometry +0+0 -state NormalState -cmd "xclock -display unix:0.1 -geom 125x125-4+4 " 60 xclock -display unix:0.1 -geom 125x125-4+4 & 61 62 swmhints -geometry 99x80+1037+2 -iconGeometry +0+0 -state NormalState -machine marvin -cmd "/usr/bin/X11/xload -display ninja:0.1 -fg red -bg #C400E900C500 " 63 machine=marvin; cmd='/usr/bin/X11/xload -display ninja:0.1 -fg red -bg \#C400E900C500 < /dev/null > /dev/null 2>&1 &'; cmd=\'$cmd\'; rsh -n $machine /bin/sh -c $cmd & 77 78 #********************************************************************** 79 # Start the window manager that makes this all possible 80 #********************************************************************** 81 swm Don't look at the above example and think that the shell will puke all over it. I have taken the liberty of breaking the long lines so that it is a bit more readable. Also note that the line numbers aren't sequential, I basically deleted a bunch of stuff from my .xinitrc file. Lines 8-11 allow the user to have a .xinitrc.local file that can contain any non-window related X initialization (xset, etc.). Lines 25-26 show starting the first client, an xterm. The swmhints program takes a bunch of options related to the state, position, size, and some other things related to window manager state of the window. The last option, -cmd, contains the string that should show up in the WM_COMMAND property when the top level window is finally created. swmhints simply appends this information to the end of an __SWM_START property on the root window. Line 26 simply starts the client, this is nothing more than what was in the WM_COMMAND property. Ditto on lines 40-41 and 43-44 Lines 47-51 prepare to start clients on screen 1 Lines 59-60 show that the xclock did have an original geometry specification but as can be seen from the swmhints command, both the size and location of the xclock have changed. Lines 62-63 show starting of a remote client. The string used to start the remote client is configurable through a resource. Finally, line 81 of course starts the window manager. When swm starts, it reads the __SWM_START property and makes a list of expected windows. As swm starts to reparent windows each window is checked for a match against one of the entries from the __SWM_START property. I am currently only looking at the WM_COMMAND property unless WM_CLIENT_MACHINE is different from where swm is running, then I also check WM_CLIENT_MACHINE. I should probably also be checking WM_CLASS, but I am not doing that now. If swm finds that the WM_COMMAND matches one from the __SWM_START list, the client window is sized, positioned and/or iconified depending on the saved information. There you have it. You'll notice that I can't tell the difference between clients that have the same WM_COMMAND, although that hasn't been a real problem so far. This scheme also works with any client that specifies a WM_COMMAND regardless of the toolkit used, I don't have to rely on some known set of command line options. Hopefully this will start some session manager discussion, isn't everyone else also tired of telling Sunview users that they really should use X because it is better, and then they ask you how to save their window layout ... -- Tom LaStrange Solbourne Computer Inc. ARPA: toml@Solbourne.COM 1900 Pike Rd. UUCP: ...!{boulder,sun}!stan!toml Longmont, CO 80501