2

I've been working hours on this problem. When nautilus file manager is NOT running nautilus is running because it controls icons on the desktop.

$ ps -aux | grep nautilus | grep -v grep
rick      5613  0.2  1.7 2355392 140012 pts/19 Sl+  19:04   0:08 nautilus

So use this command without nautilus file manager open and you see:

$ ps -L -p 5613 -o pid,nice,lwp,comm
  PID  NI   LWP COMMAND
 5613   0  5613 nautilus
 5613   0  5614 gmain
 5613   0  5615 gdbus
 5613   0  5617 dconf worker

Now open up nautilus file manager and redo ps command:

$ nautilus

$ ps -L -p 5613 -o pid,nice,lwp,comm
  PID  NI   LWP COMMAND
 5613   0  5613 nautilus
 5613   0  5614 gmain
 5613   0  5615 gdbus
 5613   0  5617 dconf worker
 5613   0  4788 pool

Close the nautilus files window and rerun the command (after waiting a second or two) and the pool disappears.

Is this the correct way of seeing if nautilus file manager is running?

I've incorporated above technique into an answer in Ask Ubuntu I'd like to improve if possible:

1
  • +1 for looking into and explaining the details of this problem :-)
    – sudodus
    Oct 13, 2019 at 9:13

1 Answer 1

5

The best way to check whether there are any Nautilus windows open is to check for them on the session D-Bus:

gdbus introspect --session --dest org.gnome.Nautilus \
      --object-path /org/gnome/Nautilus --recurse | awk '/^ *node /{print $2}'

This will show window entries under /org/gnome/Nautilus/window if there are any open windows; so

gdbus introspect --session --dest org.gnome.Nautilus \
      --object-path /org/gnome/Nautilus --recurse |
grep -q '^ *node /org/gnome/Nautilus/window/'

will succeed if there are any open windows, fail otherwise.

3
  • 1
    With desktop icons and no browser I get .../window/1 with file browser that plus .../window/9. On fresh reboot no file browser still .../window/1 with files open get that plus .../window/3. Ubuntu 16.04.6 LTS - GNOME nautilus 3.14.3 Note: Files does autostart on login and I have to close it for testing. Oct 16, 2019 at 10:55
  • Oh, sorry about that, so the desktop counts as a window too (at least in some setups). Let’s see if I can find something better... Oct 16, 2019 at 11:53
  • 1
    Better would be best but I did get it working appending grep -v '/window/1 my only concern is there might be more than one gnome app that uses a window which would give a false positive that file browser is running. Oct 16, 2019 at 12:26

You must log in to answer this question.

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