On Tue, Nov 23, 2010 at 12:00 PM, [email protected] said: > Anyway I'm quite interested in the way you managed "pseudo"-sessions. > I read somewhere (can't remember where) that a mechanism to handle > sessions used to exists in X which allowed applications to "store" > and "restore" contexts when being sent *kind of* signals. Sadly I > never took the time to dig the point. So if you have any hint on the > unix-way to manage sessions I would be quite interested.
IMO the trick to managing sessions is linking the information inside each window with information about the size, placement, etc. of the window. I use the Enlightenment e16 window manager. It provides a command line interface that lists all windows and their properties. Here is one line listing a urxvt terminal: 0x1c00006 : 21 63 1138x 966 :: 0 : "urxvt" "URxvt" : "8821 ~" : "-NONE-" The first field a unique window-id, followed by placement, size, and desktop number. After that is: name, class, title, and role. I used your previous hint and am using my shell (currently Zsh) to put the process id and CWD in the title. As it turns out, I only need the PID but the CWD is handy for the user to see. I use the PID to link this window information with what is going on inside the terminal window (tabs and CWDs). This is not absolutely infallible but it is good enough for me. All the Zsh shells inside one urxvt window come from the same parent process. For this step to work it is essential that I don't use the urxvt client/server. Launching urxvt is plenty fast enough for me so this is not a problem (for me). The window title links one Zsh process with the window. I get all the others after finding the common parent process. Another failing is that the order I remember is the order of tab/shell creation. So if you move tabs around I don't remember that. I can live with that. I also use the ps command to find the CWD of each Zsh shell of interest. It can provide you a listing of the environment of each process and the CWD is listing in the environment. Okay, that is half the problem solved, how to remember sessions. The second half is restoring sessions. This is based on the ability to select a window's position, size, and desktop via the command line and on the ability to restore whatever is inside the window. E16 provides a command line interface (called eesh, the same one that produces the list of windows) that allows me to do all I need once I know the window-id of the window I want to place. The only way I have to get the window-id is kludgey and fragile. I get a list of all window-ids before the window in question is launched then I wait around and poll the entire window list waiting for something new to show up with the correct name field. BTW: The Xfce terminal also provides the geometry of the terminal in the window title which was very handy. It allowed me to launch the terminal with the correct geometry instead of resizing it a moment later. The benefits of this are 1) greater start up speed and 2) resizing the window causes my Zsh prompt to get redrawn or wrap or both which I think is ugly. The easiest program for me to save and restore was GVim which has an easy mechanism for saving and restoring what is inside the GVim window. If you like Fluxbox and you like to tinker than you may love e16. I sure do. It is the most programmable program I've ever encountered. Except for the most excellent tabbing feature, Fluxbox is like a scaled down, simplified, less programmable e16. Oh yes, one more almost related point. I changed the hotkeys for moving between urxvt tabs to alt + left/right arrow (inside a copy of the "tabbed" Perl program). I did this to remain consistent with switching between Linux virtual consoles. This turns out to be really important for me. Without this consistency, my fingers get confused. While it is possible to alter the keys used to switch between VCs, it is not trivial and the main problem is that if I set it to match terminal emulator A then it won't match terminal emulator B. So the best solution I've found was to make all the terminal emulators I use match the keys used to switch Linux VCs. Also, if I use someone else's Linux machine, or a different distro or a LiveUSB/CD, etc, the VCs will come with the stock alt + left/right for switching so it is important that I stick with those key combos for all my terminal switching to avoid confusing my fingers. Peace, James _______________________________________________ rxvt-unicode mailing list [email protected] http://lists.schmorp.de/cgi-bin/mailman/listinfo/rxvt-unicode
