3

I'm opening a nautilus window from my bash script with nautilus --new-window .

How can I keep reading the currently open directory (even after navigating somewhere)?

3

You could use dbus-monitor to watch for related events when you change the current folder in any tab of any nautilus window:

dbus-monitor "
  type='signal',
  interface='org.freedesktop.DBus.Properties',
  path='/org/freedesktop/FileManager1',
  member='PropertiesChanged'" |
  awk -F '"' '
    $2 ~ "^/org/gnome/Nautilus/window/[[:digit:]]+$" {
      window = $2
      sub(".*/", "", window)
      tab = 0
      next
    }
    window && /string / {
      print window"."++tab": "$2
      next
    }
    tab {window = 0}'

prints something like:

2.1: file:///export/home/stephane/Desktop/untitled%20folder
2.2: file:///export/home/stephane/Downloads
1.1: trash:///

(where 2.1 for instance means 2nd window, 1st tab) every time I change folder in any tab of any nautilus window.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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