From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Lucio Chiappetti Newsgroups: gmane.os.tru64.managers Subject: PARTIAL SUMMARY: which CDE workspace am I in ? Date: Fri, 04 Apr 2003 17:59:09 +0200 (MET DST) Sender: tru64-unix-managers-owner@ornl.gov Message-ID: References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Trace: main.gmane.org 1049472124 21982 80.91.224.249 (4 Apr 2003 16:02:04 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Fri, 4 Apr 2003 16:02:04 +0000 (UTC) Original-X-From: tru64-unix-managers-owner-gotm-tru64-unix-managers=m.gmane.org@sws1.ctd.ornl.gov Fri Apr 04 18:01:57 2003 Return-path: Original-Received: from sws1.ctd.ornl.gov ([160.91.22.101]) by main.gmane.org with smtp (Exim 3.35 #1 (Debian)) id 191Tdc-0005hB-00 for ; Fri, 04 Apr 2003 18:01:56 +0200 Original-Received: (qmail 2119 invoked by uid 5); 4 Apr 2003 16:02:04 -0000 Original-Followup-To: poster Precedence: bulk Original-Received: (qmail 2107 invoked by uid 49493); 4 Apr 2003 16:02:04 -0000 Original-Received: from lucio@mi.iasf.cnr.it by sws1 by uid 49491 with qmail-scanner-1.14 (clamscan: 0.54. spamassassin: 2.50-cvs. Clear:SA:0(-8.1/5.0):. Processed in 1.256882 secs); 04 Apr 2003 16:02:04 -0000 Original-Received: from unknown (HELO emroute1.cind.ornl.gov) (160.91.4.119) by 0 with SMTP; 4 Apr 2003 16:02:02 -0000 Original-Received: from emroute1.cind.ornl.gov (localhost [127.0.0.1]) by emroute1.cind.ornl.gov (PMDF V6.2 #30669) with ESMTP id <0HCT00A5FTV1LE@emroute1.cind.ornl.gov> for tru64-unix-managers@sws1.ctd.ornl.gov (ORCPT tru64-unix-managers@ornl.gov) ; Fri, 04 Apr 2003 11:02:00 -0500 (EST) Original-Received: from kronos.mi.iasf.cnr.it (kronos.mi.iasf.cnr.it [155.253.16.77]) by emroute1.cind.ornl.gov (PMDF V6.2 #30669) with ESMTP id <0HCT0068MTUYYB@emroute1.cind.ornl.gov> for tru64-unix-managers@sws1.ctd.ornl.gov (ORCPT tru64-unix-managers@ornl.gov) ; Fri, 04 Apr 2003 11:01:48 -0500 (EST) Original-Received: from poseidon.mi.iasf.cnr.it (poseidon.mi.iasf.cnr.it [155.253.16.87]) by kronos.mi.iasf.cnr.it (8.9.1/8.9.1) with ESMTP id RAA09981 for ; Fri, 04 Apr 2003 17:59:11 +0200 (MET DST) Original-Received: from localhost (lucio@localhost) by poseidon.mi.iasf.cnr.it (8.9.1/8.9.1) with ESMTP id RAA00826 for ; Fri, 04 Apr 2003 17:59:10 +0200 (MET DST) In-reply-to: Original-To: Alpha OSF list Xref: main.gmane.org gmane.os.tru64.managers:3898 X-Report-Spam: http://spam.gmane.org/gmane.os.tru64.managers:3898 On Fri, 4 Apr 2003, Lucio Chiappetti wrote: > ... I'd like to have a better way to tell me which workspace I am in, > with a name either as > > - a little icon with the workspace name > - a script which could set an environment variable [...] I have discovered the man pages and the online documentation for dtksh, and learned quite a bit about X (but not enough ?!) I have therefore solved the second problem above. The first script enclosed essentially flashes a little useless widget, but in the process of doing so returns the workspace number to the terminal. I could therefore use an assignment like set myswp=`myworkspacefast` (the name of the script) and use it in my standard script to set window banners in addition to host, username and tty. But you know the saying "appetite comes while eating". During my exercises I discovered I could keep the workspace number permanently up (e.g. in the widget title bar). I could even have the widget occupy all workspaces, and define a callback which automatically updates the title whenever I change workspace. This is exemplified by the second script, which is a sort of solution to my first problem. It has a little imperfection. When I call it (myworkspace.standalone), I cannot force the window to appear where I want. It always appears in the top left corner. Looks a window manager issue, but other applications behave differently. Also more appetite comes. I now want the above widget to come out at login. I did several tries, like updating the .dt/session/home/dt.session by hand, or calling up the CDE control panel, with no result. In particular using the control panel "set home session" did not alter the above file ! After which a more careful reading of man dtksh and of the example script contained therein (which I stripped a lot) taught me that applications to be saved in the home session require to be aware of that (or the session manager has to be aware of the application) So I copied back in (third script) the code in man dtksh. This way a "set home session" writes the correct commands. It also saves a "session file" which in my case is useless/redundant (it contains "Deiconified" and the list of the 4 ws0 ws1 ws2 ws3). BUT STILL WHEN I LOGIN THE WIDGET IS RESTARTED not only in the top left corner but also ONLY IN WORKSPACE 1. This irrespective of the fact that both the session file and my code tell it to occupy all workspaces (one at a turn or all in a go). I tried also some variations simplifying the code, ignoring the session file, or forcing occupation of one workspace at a time, but in all cases when started from login it occupies only workspace 1 (if I manually occupy all wsp's it works, and if I call it manually it occupies all wsp's) What's wrong ? ---------------------------------------------------------------------------- Lucio Chiappetti - IASF/CNR - via Bassini 15 - I-20133 Milano (Italy) ---------------------------------------------------------------------------- L'Italia ripudia la guerra [...] come Italy repudiates war {...] as a mezzo di risoluzione delle controversie way of resolution of international internazionali controversies [Art. 11 Constitution of the Italian Republic] ---------------------------------------------------------------------------- For more info : http://www.mi.iasf.cnr.it/~lucio/personal.html ---------------------------------------------------------------------------- ------------------------------------------------------------------- Script 1 : This script returns the workspace number (1-4) to terminal ------------------------------------------------------------------- #! /usr/dt/bin/dtksh XtInitialize TOPLEVEL wmProtTest Dtksh "$@" XtCreateManagedWidget DA da XmDrawingArea $TOPLEVEL XtSetValues $DA height:1 width:160 XtSetValues $TOPLEVEL title:"prova" XtRealizeWidget $TOPLEVEL XtScreen MYSCREEN $DA XRootWindowOfScreen RW $MYSCREEN DtWsmGetCurrentWorkspace $(XtDisplay "-" $TOPLEVEL) $RW CURRENT_WS_LIST XmGetAtomName NAME $(XtDisplay "-" $TOPLEVEL) $CURRENT_WS_LIST NUMBER=${NAME##ws} NUMBER=$(($NUMBER+1)) echo $NUMBER XtSetValues $TOPLEVEL title:"workspace $NUMBER" XSync $(XtDisplay "-" $TOPLEVEL) False exit ------------------------------------------------------------------- Script 2 : This script returns the workspace number (1-4) in a widget ------------------------------------------------------------------- #! /usr/dt/bin/dtksh MyCallBack() { XmGetAtomName NAME $(XtDisplay "-" $TOPLEVEL) $CB_CALL_DATA NUMBER=${NAME##ws} NUMBER=$(($NUMBER+1)) XtSetValues $TOPLEVEL title:"workspace $NUMBER" XSync $(XtDisplay "-" $TOPLEVEL) False } XtInitialize TOPLEVEL wmProtTest Dtksh "$@" XtCreateManagedWidget DA da XmDrawingArea $TOPLEVEL XtSetValues $DA height:1 width:160 XtSetValues $DA x:+1065 y:+332 XtSetValues $TOPLEVEL title:"prova" XmInternAtom SAVE_SESSION_ATOM $(XtDisplay "-" $TOPLEVEL) "WM_SAVE_YOURSELF" True XtRealizeWidget $TOPLEVEL XmAddWMProtocols $TOPLEVEL $SAVE_SESSION_ATOM XtScreen MYSCREEN $DA XRootWindowOfScreen RW $MYSCREEN DtWsmGetCurrentWorkspace $(XtDisplay "-" $TOPLEVEL) $RW CURRENT_WS_LIST XmGetAtomName NAME $(XtDisplay "-" $TOPLEVEL) $CURRENT_WS_LIST NUMBER=${NAME##ws} NUMBER=$(($NUMBER+1)) XtSetValues $TOPLEVEL title:"workspace $NUMBER" DtWsmOccupyAllWorkspaces $(XtDisplay "-" $TOPLEVEL) $(XtWindow "-" $TOPLEVEL) XSync $(XtDisplay "-" $TOPLEVEL) False DtWsmAddCurrentWorkspaceCallback NEW $DA MyCallBack XtMainLoop ------------------------------------------------------------------- Script 3 : as script 2 but should be session management aware ------------------------------------------------------------------- #! /usr/dt/bin/dtksh # # this call back acts at change of workspace MyCallBack() { XmGetAtomName NAME $(XtDisplay "-" $TOPLEVEL) $CB_CALL_DATA NUMBER=${NAME##ws} NUMBER=$(($NUMBER+1)) XtSetValues $TOPLEVEL title:"workspace $NUMBER" XSync $(XtDisplay "-" $TOPLEVEL) False } # # this from the man page # Function invoked when the session is being ended by the user SessionCallback() { # Get the name of the file into which we should save our # session information if DtSessionSavePath $TOPLEVEL PATH SAVEFILE; then exec 9>$PATH # Save off whether we are currently in an iconified state if DtShellIsIconified $TOPLEVEL ; then print -u9 'Iconified' else print -u9 'Deiconified' fi # Save off the list of workspaces we currently reside in if DtWsmGetWorkspacesOccupied $(XtDisplay "-" $TOPLEVEL) $(XtWindow "-" $TOPLEVEL) CURRENT_WS_LIST ; then # Map the comma-separated list of atoms into # their string representation oldIFS=$IFS IFS="," for item in $CURRENT_WS_LIST; do XmGetAtomName NAME $(XtDisplay "-" $TOPLEVEL) $item print -u9 $NAME done IFS=$oldIFS fi exec 9<&- # Let the session manager know how to invoke us when # the session is restored DtSetStartupCommand $TOPLEVEL "/ouranos/cdeuser/myrealworkspace $SAVEFILE" else echo "DtSessionSavePath FAILED!!" exit -3 fi } # Function invoked during a restore session; restores the # application to its previous state RestoreSession() { # Retrieve the path where our session file resides if DtSessionRestorePath $TOPLEVEL PATH $1; then exec 9<$PATH read -u9 ICONIFY # Extract and restore our iconified state case $ICONIFY in Iconified) DtSetIconifyHint $TOPLEVEL True;; *) DtSetIconifyHint $TOPLEVEL False; esac # Extract the list of workspaces we belong in, convert # them to atoms, and ask the workspace manager to relocate # us to those workspaces WS_LIST="" while read -u9 NAME do XmInternAtom ATOM $(XtDisplay "-" $TOPLEVEL) $NAME False if [ ${#WS_LIST} -gt 0 ]; then WS_LIST=$WS_LIST,$ATOM else WS_LIST=$ATOM fi done DtWsmSetWorkspacesOccupied $(XtDisplay "-" $TOPLEVEL) $(XtWindow "-" $TOPLEVEL) $WS_LIST exec 9<&- else echo "DtSessionRestorePath FAILED!!" exit -3 fi } # # # MAIN # XtInitialize TOPLEVEL wmProtTest Dtksh "$@" XtCreateManagedWidget DA da XmDrawingArea $TOPLEVEL # geometry, size is irrelevant, position is not honored ? XtSetValues $DA height:1 width:160 XtSetValues $DA x:+1065 y:+332 # just a title, it will be owerwritten later XtSetValues $TOPLEVEL title:"prova" # standard stuff from man page XmInternAtom SAVE_SESSION_ATOM $(XtDisplay "-" $TOPLEVEL) "WM_SAVE_YOURSELF" False # If a command-line argument was supplied, then treat it as the # name of the session file if (( $# > 0)) then # Restore to the state specified in the passed-in session file XtSetValues $TOPLEVEL mappedWhenManaged:False XtRealizeWidget $TOPLEVEL XSync $(XtDisplay "-" $TOPLEVEL) False RestoreSession $1 XtSetValues $TOPLEVEL mappedWhenManaged:True XtPopup $TOPLEVEL GrabNone else # This is not a session restore, so come up in the default state XtRealizeWidget $TOPLEVEL XSync $(XtDisplay "-" $TOPLEVEL) False fi # Register the fact that we are interested in participating in # session management XmAddWMProtocols $TOPLEVEL $SAVE_SESSION_ATOM XmAddWMProtocolCallback $TOPLEVEL $SAVE_SESSION_ATOM SessionCallback # get the current workspace XtScreen MYSCREEN $DA XRootWindowOfScreen RW $MYSCREEN DtWsmGetCurrentWorkspace $(XtDisplay "-" $TOPLEVEL) $RW CURRENT_WS_LIST XmGetAtomName NAME $(XtDisplay "-" $TOPLEVEL) $CURRENT_WS_LIST # change wsn in n+1 (ws0 is workspace 1 etc.) NUMBER=${NAME##ws} NUMBER=$(($NUMBER+1)) XtSetValues $TOPLEVEL title:"workspace $NUMBER" # occupy all wsp, display and install the call back DtWsmOccupyAllWorkspaces $(XtDisplay "-" $TOPLEVEL) $(XtWindow "-" $TOPLEVEL) XSync $(XtDisplay "-" $TOPLEVEL) False DtWsmAddCurrentWorkspaceCallback NEW $DA MyCallBack XtMainLoop