You are not logged in.

#1 2009-01-12 23:29:51

hack.augusto
Member
From: Brazil
Registered: 2008-08-28
Posts: 124

X - continue form last session

I think everyone of this forum is aware of the opera's and ff's option "cotinue from last time", I'm looking for the exact same functionalaty but for the X server.

Last edited by hack.augusto (2009-01-12 23:30:40)

Offline

#2 2009-01-12 23:36:07

pointone
Wiki Admin
From: Waterloo, ON
Registered: 2008-02-21
Posts: 379

Re: X - continue form last session

You'll likely need a session manager, such as gnome-session. I forget what the equivalent in KDE is.

I remember reading about a D-Bus command to save the session, though I'm not sure if this would allow you to function without a session manager.


M*cr*s*ft: Who needs quality when you have marketing?

Offline

#3 2009-01-14 04:05:52

hack.augusto
Member
From: Brazil
Registered: 2008-08-28
Posts: 124

Re: X - continue form last session

gnome-session is quite confusing, and it was a extra 40M, then I made this script:

#!/bin/zsh

#--- Configuration ---

# Blacklist - programs that are not saved between sessions
blacklist=(screen dbus-launch dbus-daemon gconfd-2 dzen session)
# Blacklist
nochild=(opera emesene)

# session file
file='/home/augusto/.session_programs'

#+++ Configuration +++

# Ratpoison's pid
wm_pid=`ps -wwao pid,comm | grep ratpoison | sed 's/ *\([0-9]*\).*/\1/'`

# Clearing list from last session
echo "" > $file
# Making sure it's executable
chmod +x $file

# The argument must be a pid number
process() {

        # All process child from the given argument and owned by the user
        for proc in "${(f)$(ps --no-headers --ppid $1 -o comm,pid,user | grep $USER)}"; do

                # Getting program name
                program=`echo $proc | sed 's/\([a-zA-Z0-9_-]*\).*/\1/'`

                # Checking if program is NOT blacklisted or empty
                if [[ ! -z "${blacklist/*$program*/}" && $proc != "" && ! -z "${proc/*<defunct>*/}" ]] then
                        # Getting the program's pid number
                        pid=`echo $proc | sed 's/[a-zA-Z0-9_-]* *\([0-9]*\).*/\1/'`
                        # Adding program to session file
                        echo $(ps --no-headers --pid $pid -o cmd)"&" >> $file
                        # Getting any wanted child from actual process
                        if [[ ! -z "${nochild/*$program*/}" ]]; then
                                process $pid
                        fi
                fi

        done
}

# Looking for "unparented" processes
process 1

# Looking for WM's child processes
process $wm_pid

if anyone want give it a try just need to add "addhook quit exec /bin/zsh -c <path_to_script>" and "exec ~/.session_programs" in the ~/.ratpoisonrc, and edit the file variable in the script

Last edited by hack.augusto (2009-01-14 05:56:03)

Offline

Board footer

Powered by FluxBB