Disabling GNOME’s recently-used file list, the better way
Updated May 14th, 2020
I never liked the idea of recently-used file lists. I usually know what file I want to use and where it is, so for me there’s no real need for them. Even if I did find them useful, they’re constantly rearranging themselves, so actually locating the one file I want to use in an ever-shifting list of ten or twenty isn’t easy.
It’s also a privacy concern. I’m usually the only one to use my computer, so I only have one user account. I don’t mind if friends or family use it, and they often do to quickly check email or watch a movie while I’m away. Do I really want them seeing what files I’ve opened? Do they really want me to see what files they’ve opened?
In any case, I disable GNOME’s recently-used file list as soon as I set up my computer.
How to disable recently-used files
In the past, it was a little complicated to disable recently-used files. Nowadays, it’s as simple as doing this:
gsettings set org.gnome.desktop.privacy remember-recent-files false
That’s all there is to it. The older ways are preserved below, for posterity; but you probably don’t need to read any further.
Old method #1
This was the first method I found to disable the recently-used file list. It’s definitely easy to do. Run these two commands in the terminal:
echo "" > ~/.local/share/recently-used.xbel
sudo chattr +i ~/.local/share/recently-used.xbel
The first command clears out the recently-used file list. The second command instructs the filesystem to make the recently-used file list “immutable” (hence the “+i”), which means nobody—including programs—can read, write, or delete the file.
To re-enable the recently-used file list, just remove the immutable attribute:
sudo chattr -i ~/.local/share/recently-used.xbel
This method is easy and works pretty well… except, that is, until you launch a GTK application from the terminal. Say, for example, I’ve got my terminal open in a Git repo. I want to launch my GTK Git program, gitg. It launches, I do my thing, and I close it… to find my terminal a mess!
What happened? Well, since GTK can’t touch the recently-used file, it spits out a bunch of warnings and errors to the terminal. That screenshot is me just opening and closing gitg. If you ran, say, Gedit and edited a bunch of files, you’d get way more errors in your terminal.
All that unneeded output messes up my terminal workflow. How do we get around it, while still disabling the recently-used file list?
Old method #2
Lucky for us, in GNOME 3 there’s a handy hidden setting you can write to disable the recently-used file list. If you’re on GNOME 2, skip this section and go to the next one, your life won’t be as easy.
Put the following in ~/.config/gtk-3.0/settings.ini (create the file if it doesn’t exist):
[Settings]
gtk-recent-files-max-age=0
gtk-recent-files-limit=0
Then, remove the file holding recently-used data:
rm ~/.local/share/recently-used.xbel
You can do everything at once with these terminal commands:
mkdir -p ~/.config/gtk-3.0
echo -e "[Settings]\ngtk-recent-files-max-age=0\ngtk-recent-files-limit=0" > ~/.config/gtk-3.0/settings.ini
rm ~/.local/share/recently-used.xbel
And there we go! No more error messages in the terminal. That’s the best way to disable the list in GNOME 3.
Old method #3
As far as I know, GNOME 2 doesn’t have a convenient setting you can write to disable the list. So we’ll have to do something a little more complex.
If we approach the problem differently, we can come up with a better way to disable the list. Our old method simply made the file not-writable. What if we could simply monitor the file for changes, and empty the file whenever it changed?
That would stop GTK from complaining, because it can successfuly write to the file. It would also effectively disable the list, because it would always be empty.
We can achieve this using a special tool called inotifywait. Inotifywait is a small program that monitors the state of a file you specify and lets you know when it changes. Let’s create a script that uses this tool to monitor and empty the recently-used file list.
First, install the inotify-tools package.
sudo apt-get install inotify-tools
Next, create this bash script:
#!/bin/bash
file=$HOME/.local/share/recently-used.xbel
echo "" > "$file"
while inotifywait -e modify -e delete_self "$file" 2> /dev/null; do
echo "" > "$file"
done
You can create it in ~/monitor-recently-used by running this in your terminal:
echo -e "#\!/bin/bash\n\nfile=\$HOME/.local/share/recently-used.xbel\necho \"\" > \"\$file\"\nwhile inotifywait -e modify -e delete_self \"\$file\" 2> /dev/null; do\n\techo \"\" > \"\$file\"\ndone" > ~/monitor-recently-used
Make the script executable:
chmod +x ~/monitor-recently-used
Finally, add it to GNOME’s startup sequence:
mkdir -p ~/.config/autostart/
echo -e "[Desktop Entry]\nType=Application\nExec=~/monitor-recently-used\nX-GNOME-Autostart-enabled=true\nName=monitor-recently-used" > ~/.config/autostart/monitor-recently-used.desktop
All of this is assuming you’re placing the script in your home directory. You’ll probably want to put it somewhere else. Once you log out and log in again, it should be working!
This script uses use inotifywait to monitor the recently-used file. If the file is modified or deleted (GNOME actually seems to delete and recreate the file every time instead of just modifying it), we echo an empty string into the file to clear it out. Simple!
Now you can enjoy a disabled recently-used file list, and no garbage output when launching GTK apps from the terminal.
Comments
yoyo
echo gtk-recent-files-max-age=0 >> ~/.gtkrc-2.0
Palaeksa
yoyo’s command works great with Xfce (4.10) too, tks 😉
YuGiOhJCJ
gtk-recent-files-max-age=0 works 🙂
Peter
Dear Alex
Thank you that you did take the time to describe the solution.
Kind regards from Switzerland
Peter
Paul
Yoyo’s method works for me, under Mate Mint 15 (Olivia) so I guess that must be using Gnome 2. Thanks, all.
susanLBcanada
I know I am commenting a a post made a year ago, but I wanted to thank-you for posting this information. I embraced Linux eight years ago when I became fed up the increasing difficulties in setting up a computer the way I preferred. Over the last couple of years I have become increasingly dismayed with the “Father knows best”, attitude amongst Linux developers. They seem to have forgotten who make up their core user base in the rush to reach the lowest common denominator. If the various developers start to dictate how I set my computer up with no way of using personal settings, I am beginning to feel joining the Luddites on some mountain side is a valid next step in my tech oddessy! ;p
Michael
Well done. Thank you.
Mayhem
Doesnt work under Debian, but this method does: http://dodebian.blogspot.co.uk/2011/12/gnome3-remove-recent-items-from-search.html
rm ~/.local/share/recently-used.xbel
mkdir ~/.local/share/recently-used.xbel
Martin
Thanks for the tip — it came in useful for me. However, note that your command that writes to settings.ini assumes that the file doesn’t exist already. If it did exist, the command would more than likely cause unexpected side effects.
mythiq
thnx Mayhem. And Alex too, of course 🙂
int_ua
It doesn’t really disable writing changes to disk. It just hides it from you:
(meld:3588): Gtk-WARNING **: Attempting to store changes into `/home/user/.local/share/recently-used.xbel’, but failed: Failed to rename file ‘/home/user/.local/share/recently-used.xbel.ZT44NX’ to ‘/home/int/.local/share/recently-used.xbel’: g_rename() failed
Upatissa Thero
I’m running linuxmint 17, a fork of ubuntu 14.04 lts.
I tried the gtk3-0 settings.ini method, and I doesn’t seem to work for me. For example, an .odt file kept showing up after I closed libreoffice.
The chattr +i command works well, but it leaves garbage in the terminal window when the command terminates.
When I delete the ~.local/share/recently-used.xbel file, then create a new directory .local/share/recently-used.xbel/, then LESS garbage appears in the terminal window, and it happens at the beginning of the command, so it doesn’t seem to be as obtrusive.
Any idea when the gnome developers are going to include a “NO RECENT FILES option?
-sadhu!
Draco Metallium
This is what I did. It seams to work.
rm /.local/share/recently-used.xbel
ln -s /dev/null ~/.local/share/recently-used.xbel
Scary Canary
Using gnome 3.14 (December 2014) the following changes gave the following results:
Method A results in no change to Nautilus’ recently used listing (bad).
Ie: modify file ~/.config/gtk-3.0/settings.ini by adding the following:
[Settings]
…blah…
…blah…
gtk-recent-files-max-age=0
gtk-recent-files-limit=0
###
Method B results in no more recently used entries (good) but writes way too many errors to all open terminal console sessions (bad), ie:
rm ~/.local/share/recently-used.xbel
mkdir ~/.local/share/recently-used.xbel
###
Method C results in no more recently used entries (good) and does not write any errors to any open terminal console sessions (good), ie:
rm /.local/share/recently-used.xbel
ln -s /dev/null ~/.local/share/recently-used.xbel
ion_nsk_region
Yoyo’s method works for me, under Mate 1.8.1 Mint 17 with classic (GNOME2 like) menu bar.
Kind regards from Russia.
Thomas
Neither yoyo’s nor Draco’s method work for me (that is neither `echo gtk-recent-files-max-age=0 >> ~/.gtkrc-2.0` nor `ln -s /dev/null ~/.local/share/recently-used.xbel`). I’m on archlinux, using a windowmanager without desktop environment.
I was using the first method so far but finally got annoyed after several years of being shown warnings. I will now use your inotify-tools based approach instead, launching the script from my .xinitrc. By the way ~/bin/monitor-recently-used may be a better location for the script.
Hugo Osvaldo Barrera
Is there any way of removing Recently Used from the file selection dialog (eg: open/save/etc)?
It’s currently even the default in many applications. Is there any way to alter that behaviour and just use the last directory/the home directory?
Total Fix
rm ~/.local/share/recently-used.xbel
mkdir ~/.local/share/recently-used.xbel
Will work with gnome2 and mate
Kenneth Brun Nielsen
According to Gnome Shell (gtk3) documentation, the new method is:
~/.config/gtk-3.0/settings.ini:
gtk-recent-files-enabled=0
I couldnt make it work, though…
https://developer.gnome.org/gtk3/stable/GtkSettings.html#GtkSettings—gtk-recent-files-enabled
David
I had to make regular *and* hidden directories:
rm ~/.local/share/recently-used.xbel
mkdir ~/.local/share/recently-used.xbel
mkdir ~/.local/share/.recently-used.xbel
David
Please disregard my previous post. I was relying on my memory, which was not a good idea. I just confirmed the following with more testing:
(OS is Precise Puppy 5.7.1, which like other Puppies runs as /root.)
Correct path is ~/.local/share/recently-used.xbel.
ln -s /dev/null ~/.local/share/recently-used.xbel doesn’t work. It creates a symlink to /dev/null that’s overwritten by the next “real” recently-used.xbel.
mkdir ~/.local/share/recently-used.xbel appears to be the only good option in this case.
In older Puppies the path is slightly different: ~/.recently-used.xbel.
mkdir ~/.recently-used.xbel will work with some; others *must* auto-generate
recently-used.xbel files, otherwise they won’t allow a current working file to be saved.
Nameless Shoesalesman
I’ve successfully tried the command posted by yoyo. I’am on Ubuntu Mate 16.04 Xenial Xerus:
echo gtk-recent-files-max-age=0 >> ~/.gtkrc-2.0
The “recent document list” is now inactive and no data is stored to recently-used.xbel (or any corresponding temp files) although its time stamp indicates continuous access to the file.
Edu van Dijk
Thanks for the perfect way to disable recent file history!
Works perfect in XUBUNTU 16.04.1 (where i use NEMO as file handler)
Alex Alcides
echo gtk-recent-files-max-age=0 >> ~/.gtkrc-2.0
Worked like a charm! Thanks!
Ubuntu Mate 14.01 lts
Alex Alcides
I meant 14.04 lts 🙂
Peter Backes
@Kenneth Brun Nielsen: gtk-recent-files-enabled is a boolean variable, not an int. Did you try gtk-recent-files-enabled=false instead?
user9000
thank you for this most useful blog posting. Some of us are still searching for these things, even 5 years later.
for fedora 24, mate desktop 1.16, caja 1.16 I confirm the following:
echo -e “[Settings]\ngtk-recent-files-max-age=0\ngtk-recent-files-limit=0” > ~/.config/gtk-3.0/settings.ini
cat /dev/null > ~/.local/share/recently-used.xbel
WORKS to disable the top-level PLACES -> Recent Documents
HOWEVER, caja/nautilus has its own “GO -> history/location” bookmarks which looks like an additional side-quest to kill.
Be it for “privacy” or for “high security” I want and need an OS/Desktop environment which does not know or remember or index or report everywhere I go and every document I open.
We FIGHT to make Firefox and our web browsers behave this way and toss our cookies, and then gnome/mate developers thoughtlessly and automatically recreate the same idioms in the desktop window manager.
Daniel
Thanks, your post helped me disable the recent files on my GNOME (Gtk3.0) programs on Windows 10 (believe it or not).
If you want to add this to your post, go ahead. I’ll leave here what I did.
For me, it worked just like your Gtk3.0 explanation, except the file system is different. I had to create the “setting.ini” file in the following directory “C:\Users\user\AppData\Local\gtk-3.0\”. The “recently-used.xbel” file was located in the “C:\Users\user\AppData\Local\” directory.
Hope this helps somebody else.
Roger Imai
In Debian 9.3 running Gnome Shell 3 (X11) you can now easily turn off Usage and History in the Privacy sheet of Gnome System Settings (a.k.a. gnome-control-center,) also accessible from the far right down-triangle icon in the top bar in the screwdriver-and-wrench icon which is the gnome-control-center, and displays a window called All Settings. Open the Privacy tool, and you can turn on/off recently-used, or set when to auto-purge, or else manually purge. Other Linux distros may have a similar System Settings tool. I actually UNdid all the changes recommended above and still found no history recorded. Then I realized how I originally turned off recently-used. So what I’m saying is, apparently, recently-used activation must be additionally controlled in yet another undisclosed setting. FWIW.
BTW, you can check your version of Gnome in Terminal:
~$ gnome-shell —version
GNOME Shell 3.22.3
Marcin
Once you let the data to be recorded on your HDD it is not as simple as to delete or even overwrite the file to get ride of this. Right, if you want to protect your privacy before your kids, it may work as long as your kids are younger than 10 year old. After that they may realize that deleted/overwritten files are recoverable. If you want to protect really valuable data you can not allow to leave any traces on your disk and this solution will not work at all.
NafN
In ~/.config/gtk-3.0/settings.ini add this line:
gtk-recent-files-enabled=false