
{"id":44315,"date":"2023-09-07T15:13:50","date_gmt":"2023-09-07T15:13:50","guid":{"rendered":"https:\/\/ubuntuhandbook.org\/?p=44315"},"modified":"2023-09-07T15:13:50","modified_gmt":"2023-09-07T15:13:50","slug":"file-chooser-default-current","status":"publish","type":"post","link":"https:\/\/ubuntuhandbook.org\/index.php\/2023\/09\/file-chooser-default-current\/","title":{"rendered":"How to Make File Chooser Dialog default to Current Working Directory"},"content":{"rendered":"<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/11\/file-manager-icon.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-thumbnail wp-image-35890\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/11\/file-manager-icon-250x250.webp\" alt=\"\" width=\"250\" height=\"250\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/11\/file-manager-icon-250x250.webp 250w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/11\/file-manager-icon-300x300.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/11\/file-manager-icon-600x600.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/11\/file-manager-icon-768x768.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/11\/file-manager-icon.webp 1200w\" sizes=\"auto, (max-width: 250px) 100vw, 250px\" \/><\/a><\/p>\n<p>This simple tutorial shows how to replace &#8216;<i>Recent Used<\/i>&#8216; with current working directory as default in GTK file chooser in Ubuntu.<\/p>\n<p>Many apps use &#8220;<i>Recent Used<\/i>&#8221; as default in their &#8220;Open File&#8221; dialog. It&#8217;s great, but there&#8217;s a choice to make it default to the directory of current editing files.<\/p>\n<div id=\"attachment_44316\" style=\"width: 610px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/09\/gtk4-file-chooser-dialog.webp\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-44316\" class=\"size-large wp-image-44316\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/09\/gtk4-file-chooser-dialog-600x395.webp\" alt=\"\" width=\"600\" height=\"395\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/09\/gtk4-file-chooser-dialog-600x395.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/09\/gtk4-file-chooser-dialog-300x198.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/09\/gtk4-file-chooser-dialog-768x506.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/09\/gtk4-file-chooser-dialog.webp 1121w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><p id=\"caption-attachment-44316\" class=\"wp-caption-text\">GTK4 File Chooser<\/p><\/div>\n<p>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 &#8216;Recently Used&#8217;.<\/p>\n<h2>For GTK2 Apps<\/h2>\n<p>There are still some popular applications, such as GIMP, use GTK2 toolkit for their user interface.<\/p>\n<p>1. First, open &#8216;Files&#8217; (the file browser), press <b>Ctrl+H<\/b> to show hidden files\/folders. Then navigate to <code>.config -&gt; gtk-2.0<\/code>.<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/09\/gtk2-filechooserini.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-44317\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/09\/gtk2-filechooserini-600x321.webp\" alt=\"\" width=\"600\" height=\"321\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/09\/gtk2-filechooserini-600x321.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/09\/gtk2-filechooserini-300x161.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/09\/gtk2-filechooserini-768x411.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/09\/gtk2-filechooserini.webp 925w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>2. In that folder, click edit the &#8216;<code>gtkfilechooser.ini<\/code>&#8216; file. When file opens, change <b>StartupMode=recent<\/b> to <b>StartupMode=cwd<\/b> and save the file.<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/09\/gtk2-startupmode-cwd.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-44318\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/09\/gtk2-startupmode-cwd-600x362.webp\" alt=\"\" width=\"600\" height=\"362\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/09\/gtk2-startupmode-cwd-600x362.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/09\/gtk2-startupmode-cwd-300x181.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/09\/gtk2-startupmode-cwd-768x463.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/09\/gtk2-startupmode-cwd.webp 776w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<h2>For GTK3\/GTK4 Apps<\/h2>\n<p>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.<\/p>\n<p><b>Option 1: Use gsettings command<\/b><\/p>\n<p>For those who are OK with Linux commands, just press <b>Ctrl+Alt+T<\/b> on keyboard to open a terminal window.<\/p>\n<p>When terminal opens, run command to set current working directory as default for GTK3 file chooser:<\/p>\n<pre>gsettings set org.gtk.Settings.FileChooser startup-mode 'cwd'<\/pre>\n<p>For GTK4 applications, run this command instead in terminal window:<\/p>\n<pre>gsettings set org.gtk.gtk4.Settings.FileChooser startup-mode 'cwd'<\/pre>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/09\/gsettings-gtkfilechooser.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-44319\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/09\/gsettings-gtkfilechooser-600x193.webp\" alt=\"\" width=\"600\" height=\"193\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/09\/gsettings-gtkfilechooser-600x193.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/09\/gsettings-gtkfilechooser-300x97.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/09\/gsettings-gtkfilechooser-768x247.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/09\/gsettings-gtkfilechooser.webp 786w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p><b>Option 2: Use Dconf Editor (Graphical)<\/b><\/p>\n<p>For graphical way, first search for and install &#8216;<b>Dconf Editor<\/b>&#8216; in Ubuntu Software:<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/dconf-editor-focal.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-33935\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/dconf-editor-focal-600x346.jpg\" alt=\"\" width=\"600\" height=\"346\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/dconf-editor-focal-600x346.jpg 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/dconf-editor-focal-300x173.jpg 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/dconf-editor-focal-768x442.jpg 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/dconf-editor-focal.jpg 887w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>or run command in terminal to install the tool, in case the Software App does not work for you:<\/p>\n<pre>sudo apt install dconf-editor<\/pre>\n<p>Then, search for and launch the &#8216;Dconf Editor&#8217; tool:<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/09\/launch-dconf-editor.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-44320\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/09\/launch-dconf-editor.webp\" alt=\"\" width=\"547\" height=\"274\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/09\/launch-dconf-editor.webp 547w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/09\/launch-dconf-editor-300x150.webp 300w\" sizes=\"auto, (max-width: 547px) 100vw, 547px\" \/><\/a><\/p>\n<p>When it opens, navigate to <i>&#8216;org.gtk.Settings.FileChooser&#8217;<\/i>. Finally, click &#8216;<i>startup-mode&#8217;,<\/i>turn off &#8216;Use default value&#8217; and set custom value to &#8216;cwd&#8217;.<\/p>\n<p>Also, navigate to <i>&#8216;org.gtk.gtk4.Settings.FileChooser&#8217;<\/i> and change the value of &#8216;startup-mode&#8217; to &#8216;cwd&#8217; for GTK4 file chooser.<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/09\/dconf-editor-gtkfilechooser.webp\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/09\/dconf-editor-gtkfilechooser-600x349.webp\" alt=\"\" width=\"600\" height=\"349\" class=\"aligncenter size-large wp-image-44321\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/09\/dconf-editor-gtkfilechooser-600x349.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/09\/dconf-editor-gtkfilechooser-300x175.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/09\/dconf-editor-gtkfilechooser-768x447.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2023\/09\/dconf-editor-gtkfilechooser.webp 1294w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>After making the changes, all your GTK file chooser dialog should use current working directory as default instead of &#8216;Recently Used&#8217; immediately!<\/p>","protected":false},"excerpt":{"rendered":"<p>This simple tutorial shows how to replace &#8216;Recent Used&#8216; with current working directory as default in GTK file chooser in Ubuntu. Many apps use &#8220;Recent Used&#8221; as default in their &#8220;Open File&#8221; dialog. It&#8217;s great, but there&#8217;s a choice to make it default to the directory of current editing files. This is quite useful when [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":35890,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[2084],"class_list":["post-44315","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-howtos","tag-gtk"],"_links":{"self":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/44315","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/comments?post=44315"}],"version-history":[{"count":0,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/44315\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/media\/35890"}],"wp:attachment":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/media?parent=44315"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/categories?post=44315"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/tags?post=44315"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}