GNOME 48 / Nautilus: how to reliably track a specific window and change its current location from a script? (Debian 13 / Ubuntu 24 / Ubuntu 26)
I am running Debian 13 with GNOME Shell 48.7 on Wayland and Nautilus.
I am trying to automate an existing Nautilus window from a Bash script.
The goal is not to open a new window, but to:
- identify a specific existing Nautilus window
- track that same window reliably
- change the location shown in that window to another URI/path
For example, suppose I currently have several Nautilus windows open:
file:///home/user
file:///home/user/Downloads
sftp://192.168.1.100/root
I can query Nautilus through org.freedesktop.FileManager1.OpenWindowsWithLocations:
gdbus call --session \
--dest org.freedesktop.FileManager1 \
--object-path /org/freedesktop/FileManager1 \
--method org.freedesktop.DBus.Properties.Get \
org.freedesktop.FileManager1 \
OpenWindowsWithLocations
and get a mapping conceptually like:
/org/gnome/Nautilus/window/2 -> file:///home/user
/org/gnome/Nautilus/window/3 -> sftp://192.168.1.100/root
/org/gnome/Nautilus/window/4 -> file:///home/user/Downloads
This lets me identify which Nautilus D-Bus window object currently displays a given URI.
For example, if I know that:
/org/gnome/Nautilus/window/3
currently displays:
sftp://192.168.1.100/root
I would like to tell that exact same Nautilus window to navigate to:
sftp://192.168.1.100/
without opening a new Nautilus window.
I inspected the window object:
busctl --user introspect \
org.gnome.Nautilus \
/org/gnome/Nautilus/window/3 \
org.gtk.Actions
and found actions such as:
go-home
new-tab
close-current-view
close-other-tabs
go-to-tab
For example, this works and makes that specific window go to Home:
busctl --user call \
org.gnome.Nautilus \
/org/gnome/Nautilus/window/3 \
org.gtk.Actions \
Activate \
'sava{sv}' \
'go-home' \
0 \
0
However, I could not find an equivalent action such as:
go-to-location
open-location
set-location
that accepts a URI.
Using:
nautilus 'sftp://192.168.1.100/'
or:
nautilus --new-window 'sftp://192.168.1.100/'
does not solve the problem, because I specifically want to reuse an already identified Nautilus window.
Another issue is tracking the window reliably.
The object paths look like:
/org/gnome/Nautilus/window/N
but I assume these IDs should not be treated as persistent identifiers. If Nautilus exits or restarts, the object paths can change.
So I am looking for the correct way to do both parts:
- reliably identify or track a specific existing Nautilus window
- programmatically change the current location of that exact window
Ideally I would like something conceptually like:
window = find Nautilus window currently showing:
sftp://192.168.1.100/root
navigate that same window to:
sftp://192.168.1.100/
Is there a supported D-Bus, GTK, Nautilus, or other GNOME API for doing this?
In particular:
- Is
OpenWindowsWithLocationsthe right mechanism for identifying an existing Nautilus window? - Is there a supported method or action to navigate a specific Nautilus window to an arbitrary URI?
- Is there another Nautilus D-Bus interface besides
org.gtk.Actionsthat exposes location changes? - Are
/org/gnome/Nautilus/window/Nobject paths safe to use during the lifetime of the Nautilus process? - If not, is there a better way to correlate and track a specific Nautilus window?
I would prefer a solution that does not depend on keyboard simulation, focus, or opening a new Nautilus window.
Environment:
Debian 13
GNOME Shell 48.7
Wayland
Nautilus
PS: note I'm assuming to change an active window location not creating a new one with a specific uri.