Show folders before files in Files 47.1 (Nautilus)

I have selected to show folders before files in “Files”, but when an application opens it, they are all jumbled up together in alphabetic order. Is it possible to fix that, or can you suggest an alternative file manager?

It’s working for me. Maybe F5 or Ctrl+F5 would get it to reload?

1 Like

There are separate settings for legacy and modern apps:

gsettings set org.gtk.Settings.FileChooser sort-directories-first true
gsettings set org.gtk.gtk4.Settings.FileChooser sort-directories-first true
3 Likes

I don’t know what those keys do, but they didn’t have any effect, neither shift-F5 nor ctrl-shift-F5.

That worked!
[edit] After much experimentation, Nautilus, Writer and myapp all follow
gsettings set org.gtk.gtk4.Settings.FileChooser sort-directories-first true
but none of them set it (I suppose Writer is using Nautilus).
IMHO Nautilus should set it with this option
Preferences>General>Sort folders before files set On
It’s the obvious place, I would think most people would want it to work the same in most apps and apps could choose whether to follow it or not anyway. Since it doesn’t, there should be an option in Gnome Settings or at least in Gnome Tweaks.

If I (reluctantly) use Vladislav’s suggestion to use gsettings on the command line, it works for me, but needs doing every time I start the computer and it’s not much good for the ordinary user.
No doubt someone will let me know if I have misunderstood anything.

It shouldn’t need to be redone when you restart the computer. Are you using a Live image?

Eventually that should work for all programs. Some programs just haven’t “caught up” with the new setting location yet. Keep updating your system and eventually it should start working the “obvious” way.

1 Like

A normal installation.

They have. It’s because Nautilus doesn’t set it.

Nautilus sets it when I toggle the setting:

[/home/gregory]$ gsettings get org.gtk.gtk4.Settings.FileChooser sort-directories-first
true

{ I toggle the setting in GNOME Files }

[/home/gregory]$ gsettings get org.gtk.gtk4.Settings.FileChooser sort-directories-first
false

You’re saying that doesn’t happen when you toggle the switch under Nautilus Preferences?

It works if I use “gsettings…” and apps including Nautilus respect it.
If I switch it using Preferences>General>Sort folders before files set On
it works within Nautilus but not outside.

It might be setting something in here with the intention of not affecting anything else
gsettings list-keys org.gnome.nautilus.preferences
but I couldn’t find anything.

The gsettings man page has this note:

Note that gsettings needs a D-Bus session bus connection to write changes to the dconf database.

Maybe the behavior you describe would happen if Nautilus is failing to connect to the D-Bus session. You didn’t answer my question. Does the setting change show under gsettings when you toggle it with Nautilus?

It wasn’t, but I’ve just checked and it has just done so. I had checked it all extremely carefully, so I am now completely confused. This has happened since I started setting it on startup although I can’t see how.

If gsettings is seeing the change, then I’m confused as well. I don’t see any reason why it would matter which tool you use to change the setting.

I was thinking it wasn’t changing org.gtk.gtk4.Settings.FileChooser, but something exclusive to Nautilus in gsettings list-keys org.gnome.nautilus.preferences, but now I don’t know.

My latest check shows Writer mixing them unless I tick folders-first and taking no notice of the setting by Nautilus - this is what you thought happens. I’ll assume that’s the case from now on and if I have time I might remove my startup setting to see if it affects things.

If Nautilus is setting the flag, that is a good start, but I think apps should follow that flag as a default, but with the option to change it, rather than having mixed as the default as Writer seems to do. Also the switch should have 3 positions - mixed/Nautilus-setting/folders-first.

The GTK4 apps should be using that setting. Maybe the app needs to be restarted to pick up the new setting? Or maybe what you are using isn’t a GTK4 app?

1 Like

Writer looks like GTK4 but I don’t know. GTK4 was the setting I was checking. I have now checked and it follows the old setting and sets it. It’s ignored by Nautilus and vice-versa.
gsettings get org.gtk.Settings.FileChooser sort-directories-first
myapp is GTK4 and follows the GTK4 setting. It doesn’t permit setting anything.
The mist is clearing a little.

ChatGPT says (yes I know :slight_smile: ):

LibreOffice Writer version 24.8.4.2 primarily uses GTK3 for its graphical interface. However, there is an experimental GTK4 integration available through the libreoffice-gtk4 plugin. This plugin enables LibreOffice to integrate into a GTK4 environment, but it is not the default configuration.

The terminal tells me that the plugin is present. Maybe they have updated most of Writer to GTK4 but not got round to changing which flag they use?

To force it to use GTK4, you can try these commands:

cp /usr/share/applications/libreoffice-writer.desktop ~/.local/share/applications
sed -i 's/^Exec=libreoffice\b/Exec=env SAL_USE_VCLPLUGIN=gtk4 libreoffice/' ~/.local/share/applications/libreoffice-writer.desktop
update-desktop-database ~/.local/share/applications

You should be able to confirm that it is picking up the setting by checking Help → About LibreOffice. You’ll see “gtk4” at the end of the “User interface” line.

Good Luck!

1 Like

Phew! That works. I must have also missed something in my original checks, perhaps didn’t exit something before trying. Thanks for your patience in sorting this out.

My only remaining query is why Nautilus doesn’t set both the GTK4 and the earlier setting. I think I’ll update my script to take the value from the GTK4 setting and set the earlier version the same - for any GTK3 apps I might be using.

1 Like