0

Is there any way to save the Nautilus state? I'm usually opening more windows and more tabs, divided by arguments, but it's very frustrating to lose them every time I shutdown the system.

8
  • You can choose hibernate instead of shutdown
    – Pandya
    Sep 19, 2014 at 8:38
  • @Pandya sure, but it isn't the same thing. Also, hibernation often arise many problems and sooner or later I'm forced to shutdown the system.
    – tigerjack
    Sep 19, 2014 at 8:41
  • 1
    Have you tried this? askubuntu.com/questions/52112/…
    – MrV
    Sep 19, 2014 at 8:58
  • @MrV don't know exactly how it works, I just tried to type nautilus --sm-client-state-file ~/.config/session-state/nautilus-xxxxxxxxxx.desktop & and it returns Could not parse arguments: Unknown option --sm-client-state-file Also, nautilus man doesn't contain anything about this.
    – tigerjack
    Sep 19, 2014 at 9:08
  • Did you try the session saving suggestion too?
    – Nattgew
    Sep 19, 2014 at 16:26

2 Answers 2

2

There isn't a (simple) way to do this, but this question has a script that can help:

open nautilus as new tab in existing window

Note that xdotool and wmctrl need to be installed for it to work.

Using that script as a basis, you could make a script that automatically opens a defined set of windows and tabs. This is just to give a general idea and not tested. For example, I don't know how wmctrl would work with multiple Nautilus windows. I'm sure the loops/variables/quotes could be better too (I'm not attempting to simulate a 2D array yet).

windows=2
tabs1=(/home/user/Documents /home/user/Downloads)
tabs2=(/usr/share /etc)

#Save old clipboard value
oldclip="$(xclip -o -sel clip)"

#The following would be the cleanest way to code this:

#while i < $windows; do
    #open nautilus
    #for tab in tabs; do
        #open tab in this window
    #done
#done

nautilus ${tabs1[0]}

for tab in ${tabs1[@]}; do
    i=0
    for tab in ${tabs[@]}; do
        if [ $i -gt 0]; then
            echo -n tab | xclip -i -sel clip
            wmctrl -xF -R nautilus.Nautilus && xdotool key ctrl+t ctrl+l ctrl+v Return
        fi
        i=$[$i + 1]
    done
done

#Restore old clipboard value
echo -n "$oldclip" | xclip -i -sel clip

The best way to do this would be to loop through all windows and all tabs. It would open Nautilus with tab 1, then open tab 2, etc. It uses the clipboard to store the tab location, and pastes it in to the location field.

You would need to manually set the number of windows and the tabs in each one before each shutdown. But I realized you could use the script in reverse to save the open tabs:

#Save old clipboard value
oldclip="$(xclip -o -sel clip)"

wmctrl -xF -R nautilus.Nautilus && xdotool key ctrl+l ctrl+c
tab=$(xclip -o -sel clip)
tabs[0]=""

i=1

while [ "$tab" != "$tabs[0]"]; do
    tabs[i]="$tab"
    wmctrl -xF -R nautilus.Nautilus && xdotool key ctrl+l ctrl+c
    tab=$(xclip -o -sel clip)
    i=$[$i + 1]
done

#i=1

#while i < $windows; do
    #open window, open tabs?
#done

#Restore old clipboard value
echo -n "$oldclip" | xclip -i -sel clip

That's about all I can do at the moment. I may try to test this later, and any suggestions/fixes are welcome.

2
  • Thanks for your help :) Btw, I haven't understood how to proceed with the scripts. The "#while i < $windows; do" and following lines are just an explanation of what happens in the next lines or it's just pseudocode waiting for a right way to implement?
    – tigerjack
    Sep 20, 2014 at 8:53
  • Yeah, that's just pseudocode for the simplest loop, if the variables can be worked out.
    – Nattgew
    Sep 22, 2014 at 16:29
1

In the case of windows, it's possible to make a custom launcher which opens all URIs specified.

You can see the file /usr/share/applications/nautilus-home.desktop. There is a line starting with Exec:

Exec=nautilus --new-window %U

You can change it in this way:

Exec=nautilus -n URI1 URI2 …

After you save it somewhere such as your desktop and check the executable permissions, it will open each specified URI in a separate window.

1
  • Thanks :) Indeed, it seems useful. The problem now is: how can I store the URI of my tabs before I shutdown the system?
    – tigerjack
    Sep 20, 2014 at 8:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .