How shorten 'recent files' list

Questions about applications and software
Forum rules
Before you post please read how to get help
User avatar
Welcome
Level 5
Level 5
Posts: 923
Joined: Wed Aug 19, 2020 11:38 am

Re: How shorten 'recent files' list

Post by Welcome »

I think it is too much! :D I did check the source code for the mint menu and the recent applet. But, the code looked fine.

However, I was looking at the most recent version. What I don't know is if your 19.2 system is using the same code, and unfortunately, I don't have an easy way to check....

There are other ways to solve this, like with some custom code. I personally clear the list routinely. Either by clicking "Clear" or running this little bit of code:

Code: Select all

#!/bin/bash
echo "Delete the recent file list (rm ~/.local/share/recently-used.xbel)."
rm ~/.local/share/recently-used.xbel
echo Operation complete! Press Enter to continue...
read x

# eof
Of course, this could be changed to something that would modify the actual file, like to limit it to 7 entries. It'd be some work, since the file is an xml type file. Python would probably be the easiest. But, this kind of thing would take some time to build and test. And, you need someone willing to build it.
3 steps to find an answer: (1) Search forum with unique key words. (2) Search with Google and add site:linuxmint.com to your unique key word query. (3) Search with Google and add either Linux Mint or Ubuntu to your unique key word query.
User avatar
Moem
Level 21
Level 21
Posts: 12552
Joined: Tue Nov 17, 2015 9:14 am
Location: The Netherlands
Contact:

Re: How shorten 'recent files' list

Post by Moem »

AZgl1500 wrote:
Tue Feb 23, 2021 3:32 pm
FWIW, 19.3 Cinnamon does not contain dconf editor.
That is why I assumed it was not present.
Now all I'm wondering about is why it's apparently not working for the OP. The GUI is rather straightforward, once you figure out how to navigate.
But too many cooks spoil the broth, so I'm bowing out.
Image

If your issue is solved, kindly indicate that by editing the first post in the topic, and adding [SOLVED] to the title. Thanks!
User avatar
Welcome
Level 5
Level 5
Posts: 923
Joined: Wed Aug 19, 2020 11:38 am

Re: How shorten 'recent files' list

Post by Welcome »

Question: A user normally modifies the ~/.config/dconf/user file with the dconf editor or commands. What is the /etc/dconf/db file for and does it contain values that can be modified?

Sorry, I'd look this up myself, but I'll be busy until late tomorrow. Might help solve this issue, might not...
3 steps to find an answer: (1) Search forum with unique key words. (2) Search with Google and add site:linuxmint.com to your unique key word query. (3) Search with Google and add either Linux Mint or Ubuntu to your unique key word query.
User avatar
ricardogroetaers
Level 5
Level 5
Posts: 628
Joined: Sat Oct 27, 2018 3:06 am
Location: Rio de Janeiro, Brasil

Re: How shorten 'recent files' list

Post by ricardogroetaers »

Pepper-Mint-Patty wrote:
Tue Feb 23, 2021 7:46 am
@ricardogroetaers
LM19.2 Cinn menu Nemo
I don't have Cinnamon or Nemo. Sorry I can't help.
In Xfce, this is configured with 2 mouse clicks, in the plugin ("Locations") for the panel.

Image
Pepper-Mint-Patty
Level 5
Level 5
Posts: 604
Joined: Fri Dec 20, 2019 4:54 pm
Location: Royston Vasey

Re: How shorten 'recent files' list

Post by Pepper-Mint-Patty »

Moem wrote:
Tue Feb 23, 2021 4:25 pm
AZgl1500 wrote:
Tue Feb 23, 2021 3:32 pm
FWIW, 19.3 Cinnamon does not contain dconf editor.
That is why I assumed it was not present...
Stop this desinformation!
OP is using 19.2 Cinn !!!
Language is a virus.
19.2 Cinn, Nemo
User avatar
Welcome
Level 5
Level 5
Posts: 923
Joined: Wed Aug 19, 2020 11:38 am

Re: How shorten 'recent files' list

Post by Welcome »

Pepper-Mint-Patty wrote:
Wed Feb 24, 2021 7:26 am
Stop this desinformation!
OP is using 19.2 Cinn !!!
Don't worry Pepper-Mint-Patty, I know what you're using. :wink: I think anyone who has read your posts carefully, will know that, too. Of course, you could have been saying that in good humor, in which case, it is humerous. :lol: Anyway, I've got a few minutes now, so I thought I'd let you know a few things. First, that the setting of 7 didn't work for me, too. I'm looking into this further, and I have a few theories to check. Please give me some time, and I'll have a better answer for you when I can, maybe much later today. Unless, of course, another member of the forum already has the answer! :D

By the way, you can turn off the recently used files list in your Privacy settings. Note that this will also remove recently used files listed in some other applications (those that use the GTK2/3 framework). On 20.1, it looks like you can also change the number days to keep files in the recent list...

Edit: Bad news. The “gtk-recent-files-limit” property is no longer available:
GtkSettings:gtk-recent-files-limit has been deprecated since version 3.10 and should not be used in newly-written code. This setting is ignored
Ref: https://developer.gnome.org/gtk3/unstab ... iles-limit :(

So, the solutions at the point are:
(1) Turn off the recent list (in Privacy settings).
(2) Set a lower number of days to keep files in the recent list (in Privacy settings).
(3) Clear the list when desired.
(4) Create a custom script to shorten the list.
3 steps to find an answer: (1) Search forum with unique key words. (2) Search with Google and add site:linuxmint.com to your unique key word query. (3) Search with Google and add either Linux Mint or Ubuntu to your unique key word query.
Pepper-Mint-Patty
Level 5
Level 5
Posts: 604
Joined: Fri Dec 20, 2019 4:54 pm
Location: Royston Vasey

Re: How shorten 'recent files' list

Post by Pepper-Mint-Patty »

Hi Welcome, i could choose for (1) but i was under the impression that you were realising choice 4?!
:)
Welcome wrote:
Wed Feb 24, 2021 8:16 am
(4) Create a custom script to shorten the list.
Language is a virus.
19.2 Cinn, Nemo
User avatar
Welcome
Level 5
Level 5
Posts: 923
Joined: Wed Aug 19, 2020 11:38 am

Re: How shorten 'recent files' list

Post by Welcome »

Edit: Alpha version of script working. Added some improvements and safety features...
Last edited by Welcome on Thu Feb 25, 2021 9:36 am, edited 1 time in total.
3 steps to find an answer: (1) Search forum with unique key words. (2) Search with Google and add site:linuxmint.com to your unique key word query. (3) Search with Google and add either Linux Mint or Ubuntu to your unique key word query.
User avatar
Welcome
Level 5
Level 5
Posts: 923
Joined: Wed Aug 19, 2020 11:38 am

Re: How shorten 'recent files' list

Post by Welcome »

The following code will shorten the Cinnamon recent files list down to 7.

This version is designed to be run in a terminal, but that can be changed.

Instructions:
1. Copy and paste the code into a text file named shorten-recent-list or some other good name of your choice.
2. Make that file executable.
3. Run that file in a terminal.

Warning: I recommend not doing any file operations while the code runs. It should very quickly complete (within seconds depending on hardware).

Disclaimer: ALPHA version - This is virtually untested code (I've only tested it a few times so far). Use at your own risk.

Code: Select all

#!/bin/bash
# shorten-recent-list
# Author: Welcome @ forums.linuxmint.com
# Version: 0.0.4 Alpha

# Set this to the desired maximum number of files in the recent list
maxcnt=7

recentfile="/home/$USER/.local/share/recently-used.xbel"
recentcopy="/tmp/recentcopy.xbel"
tempfile="/tmp/shortrecent.xbel"

if [[ ! -f $recentfile ]]; then         # Make sure this file exists
    echo "Aborting! File not found: $recentfile"
    exit 1
fi
cp $recentfile $recentcopy              # Work on a copy for safety

key="<bookmark href"                    # Key to search for (1 per file)
cnt=$( grep -c "$key" $recentcopy )     # Count the number of files
xtracnt=$(( $cnt - $maxcnt ))           # Calc the number of extra

if [[ $xtracnt -le 0 ]]; then           # Check the xtra count number
    echo "The number of files in the recent list is $cnt. Your limit is $maxcnt."
    exit 0
fi

# Determine the starting and ending lines of the xtra lines to be removed
lines=( $( grep -n "$key" $recentcopy | cut -d':' -f1 | tr '\n' ' ' ) )
lstart=${lines[0]}
lstop=$(( ${lines[$xtracnt]} - 1 ))

sed "${lstart},${lstop}d" $recentcopy > $tempfile      # Remove xtra
sync                                    # Flush file writes
mv $tempfile $recentfile                # Replace original file
echo "The recent file list has been updated."

exit 0
# eof

Enjoy!
3 steps to find an answer: (1) Search forum with unique key words. (2) Search with Google and add site:linuxmint.com to your unique key word query. (3) Search with Google and add either Linux Mint or Ubuntu to your unique key word query.
Post Reply

Return to “Software & Applications”