How to Make File Chooser Dialog default to Current Working Directory

Last updated: September 7, 2023 — 4 Comments

This simple tutorial shows how to replace ‘Recent Used‘ with current working directory as default in GTK file chooser in Ubuntu.

Many apps use “Recent Used” as default in their “Open File” dialog. It’s great, but there’s a choice to make it default to the directory of current editing files.

GTK4 File Chooser

This is quite useful when working with many files in same directory. For example, when editing image via GIMP, press Ctrl+O (or Ctrl+Alt+O) will open file chooser and automatically open the directory of current image, instead of always ‘Recently Used’.

For GTK2 Apps

There are still some popular applications, such as GIMP, use GTK2 toolkit for their user interface.

1. First, open ‘Files’ (the file browser), press Ctrl+H to show hidden files/folders. Then navigate to .config -> gtk-2.0.

2. In that folder, click edit the ‘gtkfilechooser.ini‘ file. When file opens, change StartupMode=recent to StartupMode=cwd and save the file.

For GTK3/GTK4 Apps

GTK3 file chooser in Ubuntu 22.04/23.10 by default selects current working directory, but GTK4 chooses recent files as default. And, they have hidden option to configure this behavior.

Option 1: Use gsettings command

For those who are OK with Linux commands, just press Ctrl+Alt+T on keyboard to open a terminal window.

When terminal opens, run command to set current working directory as default for GTK3 file chooser:

gsettings set org.gtk.Settings.FileChooser startup-mode 'cwd'

For GTK4 applications, run this command instead in terminal window:

gsettings set org.gtk.gtk4.Settings.FileChooser startup-mode 'cwd'

Option 2: Use Dconf Editor (Graphical)

For graphical way, first search for and install ‘Dconf Editor‘ in Ubuntu Software:

or run command in terminal to install the tool, in case the Software App does not work for you:

sudo apt install dconf-editor

Then, search for and launch the ‘Dconf Editor’ tool:

When it opens, navigate to ‘org.gtk.Settings.FileChooser’. Finally, click ‘startup-mode’,turn off ‘Use default value’ and set custom value to ‘cwd’.

Also, navigate to ‘org.gtk.gtk4.Settings.FileChooser’ and change the value of ‘startup-mode’ to ‘cwd’ for GTK4 file chooser.

After making the changes, all your GTK file chooser dialog should use current working directory as default instead of ‘Recently Used’ immediately!

Twitter

I'm a freelance blogger who started using Ubuntu in 2007 and wishes to share my experiences and some useful tips with Ubuntu beginners and lovers. Please comment to let me know if the tutorial is outdated! And, notify me if you find any typo/grammar/language mistakes. English is not my native language. Contact me via ubuntuhandbook1@gmail.com Buy me a coffee: https://ko-fi.com/ubuntuhandbook1 |

4 responses to How to Make File Chooser Dialog default to Current Working Directory

  1. Hello sir!
    Followed the above said instruction. The default value was “cwd” already. I changed it to custome value with “cwd”. Now the file chooser is showing the “home” folder instead of the current working directory. The “recent files” not opening albeit!
    How to correct further?

    • Try resetting the options:

      gsettings reset org.gtk.Settings.FileChooser startup-mode
      gsettings reset org.gtk.gtk4.Settings.FileChooser startup-mode
    • The developers GTK are fu*ng monkeys, they removed the “last” – last remember folder parameter and left only “recent” – recent folder, and “cwd” – home folder.

  2. Hello sir!
    Not able to reset the options.
    Above given commands result in the error text “failed to commit changes to dconf: The connection is closed” !!! :-(

Leave a Reply

Text formatting is available via select HTML.

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> 

*