Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I start my computer I want that remember my applications opened before close the last session such as Ubuntu, and other distros do normally.

Googling, I see that I can run apps when I start session, configuring the autostart file but I don't want always run the same programs at start, instead I want reopen the programs opened before close last session.

I use Fedora spin with LXDE.

share|improve this question

Apparently LXDE doesn't have a proper session manager. However as you've mentioned we can use the autostart file. All we need to do is create a dynamic list of the programs we are running before we exit the desktop.

Here is a little bash script I whipped up that will parse the children of the root X11 window looking for apps to add to the autostart file. It has optional black and white lists. Use the blacklist for things like the window manager or anything you never want to run. Conversely use the whitelist for something you always want to run.

Try running it in a shell to see what the output looks like, then you can see if you need to add anything to the blacklist.

You'll need to wire this up to run somehow before you exit LXDE. Probably by adding a new entry into a menu.

For example: scriptnamehere.bash > ~/.config/lxsession/LXDE/autostart

As you can see this will rewrite the autostart file each time it is run, hence the need for the whitelist.


WINDOWS=($(xwininfo -root -children | \
    egrep \"[a-zA-Z]*\" | \
    cut -d' ' -f7 | \
    sed 's/":\?//g' | \
    sort -du))


for window in ${WINDOWS[@]}; do
    # test to see if element in array is an executable
    WHICH=$(which $window 2>/dev/null)

    # is it in the blacklist?
    # if so, move to the next window
    for app in ${BLACKLIST[@]}; do
    if [[ $app == $window ]]; then
        continue 2

    # otherwise add it to the autostart list
    if [[ -f $WHICH ]]; then

# add whitelisted apps
for app in ${WHITELIST[@]}; do

for app in ${APPS[@]}; do
    printf "@%s\n" "$app"
share|improve this answer
Thank you for your script! Do you know if there's any way to save the window positions and workspaces as well? – Glutanimate Dec 25 '12 at 3:03
You may be able to use the .Xresources file, depending on the application. For example to set the Geometry of an XTerm window: XTerm*Geometry: 140x50+110+60 – vschum Jan 11 '13 at 2:14

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.