Page 1 of 4 123 ... LastLast
Results 1 to 10 of 38

Thread: Extracting data from recently-used.xbel?

  1. #1
    Join Date
    Sep 2020
    Beans
    9

    Extracting data from recently-used.xbel?

    Hi everyone!


    This is my first world problem: I'm so glad I moved to Xubuntu for the past few weeks - I have optimized everything and learned a lot in the process. But there's something I just can't get used to: in Windows, right-clicking on the task bar Explorer icon will give you a list of the last folders you were active in. This is so useful! Helps not have 15 tabs open while you're working on a bunch of stuff.

    So I spent the day looking for a way to get these folders up and ready to open. And it's no easy task for a newbie like myself. No dock app or file manager offers this option which I find hard to believe!


    Two things I discovered: what I'm looking for is EXACTLY what is displayed when you go there in Xubuntu: desktop right-click > desktop settings > folder > other... > RECENTLY USED...! That's the one. I would love to be able to display this list of folders very quickly.

    The second thing I discovered was the file /home/USER/.local/share/recently-used.xbel which I assume the aformentioned "recently used" folder gets its data from.


    If someone could help me find a way to do this, I would be eternally grateful. Thanks for reading, and stay safe out there.

  2. #2
    Join Date
    Aug 2018
    Location
    England
    Beans
    52
    Distro
    Xubuntu

    Re: Extracting data from recently-used.xbel?

    Google found an answer to this. Open a terminal and type:

    Code:
    sudo apt install gvfs-bin
    Type your password when prompted. Type:

    Code:
    gvfs-open recent:///
    That worked for me, but I got "This tool has been deprecated, use 'gio open' instead. See 'gio help open' for more info." This message has been reported as Ubuntu Bug #1721948.

    You should be able to set up a shortcut key to launch this application:

    HTML Code:
    https://www.unixmen.com/how-to-add-shortcut-keys-in-xfce/
    Last edited by geofftf; September 14th, 2020 at 10:30 AM.

  3. #3
    Join Date
    Sep 2020
    Beans
    9

    Re: Extracting data from recently-used.xbel?

    geoff, thank you immensely for your reply. It will definitely help down the line. Now, I discovered recent:/// yesterday, but what I'm really looking for is recent folders! It only displays files. Of course there is the "location" column, but the long paths, the amount of different files and the right-clicking 'open location' don't really do the trick.

    The fact that what I'm looking for is available in [desktop settings>folder>other] makes it all seem so possible! Any more ideas? Definitely on the right path with the shortcut!

    Thanks again for your kind interest.

  4. #4
    Join Date
    Jul 2005
    Location
    I think I'm here! Maybe?
    Beans
    Hidden!
    Distro
    Xubuntu 22.04 Jammy Jellyfish

    Re: Extracting data from recently-used.xbel?

    You can open those ~/.local/share/recently-used.xbel files, of which I have many, using a text-editor, and you could then get the information you needed, though perhaps not quite in the way you're wanting.

    I am not good enough at bash to give you a command to extract the folders and files shown but there will be ways, I'm pretty sure of that.
    You can start with a simple grep command
    Code:
    grep /yourusername/ .local/share/recently-used.xbel
    (showing your real username of course) which will then show all the lines with pathways to files and folders in your home that you have opened.
    If you've opened files in the root system you can also look for those by replacing the /yourusername/ with /etc/ or /lib/, etc etc.
    Last edited by ajgreeny; September 14th, 2020 at 08:14 PM.

  5. #5
    Join Date
    Aug 2018
    Location
    England
    Beans
    52
    Distro
    Xubuntu

    Re: Extracting data from recently-used.xbel?

    awk would be a better tool than grep. With awk it is possible to split the matched lines into fields, and extract just the path names. It is then possible to sort the resulting lines and remove duplicates using sort and uniq, and concatenate the resulting lines separated by spaces. The resulting string can be added on the end of "thunar ". If you run that as terminal command Thunar should open with all the matched directories as tabs. I am not a terminal command expert (especially late at night), so you would have to fill in the details yourself. You will find some clues here:

    HTML Code:
    https://stackoverflow.com/questions/15580144/how-to-concatenate-multiple-lines-of-output-to-one-line
    Better still, you could write a little Python program to construct the thunar command, and Python can launch the command too. You could also set up a keyboard shortcut to launch the Python program.
    Last edited by geofftf; September 14th, 2020 at 10:09 PM.

  6. #6
    Join Date
    Dec 2014
    Beans
    2,566

    Re: Extracting data from recently-used.xbel?

    With the use of hxselect from the package html-xml-utils (don't know whether or not that's installed by default) you can extract the href-attribute of the bookmark-element in the recently-used.xbel file. With a bit of 'sed' and 'sort -u' this
    Code:
    hxselect -c -s '\n' 'bookmark::attr(href)'<$HOME/.local/share/recently-used.xbel|sed -n 's/\(file:\/\/.*\/\).*/\1/p'|sort -u
    prints out just the directories for all the files as 'file://'-urls. If you execute that line in the xfce4-terminal you can open the directories in thunar by right-clicking on them and selecting an option from the context-menu.

    Holger

  7. #7
    Join Date
    Aug 2018
    Location
    England
    Beans
    52
    Distro
    Xubuntu

    Re: Extracting data from recently-used.xbel?

    That is awesome. I found to sed bit hard to follow. It converts file paths into the corresponding directory paths. Here is another sed command that achieves the same result:

    HTML Code:
    https://unix.stackexchange.com/questions/482477/regex-delete-all-characters-after-the-last-occurrence-of
    With that, the command becomes:

    Code:
    hxselect -c -s '\n' 'bookmark::attr(href)'<$HOME/.local/share/recently-used.xbel | sed 's![^/]*$!!' | sort -u
    I have tested that and it works. It should be possible to set up a keyboard shortcut or .desktop file (to create a menu entry) that kicks the command off.

  8. #8
    Join Date
    Sep 2020
    Beans
    9

    Re: Extracting data from recently-used.xbel?

    You guys, this is amazing -- thank you so much! I didn't think we would get this far so quick!

    Now, I'm left with one last problem: since I'm french, and also using a cloud service, the results look like these: "pr%C3%A9l%C3%A8vements" (because of those éè etc), and can get pretty lengthy too! So in the end I spend as much time reading the results than getting to the folder...!
    Would anyone know of a way to actually open up a folder containing shortcuts? Geoff, it seems like you were definitely close when you said

    Quote Originally Posted by geofftf View Post
    The resulting string can be added on the end of "thunar ". If you run that as terminal command Thunar should open with all the matched directories as tabs
    but I don't quite understand what to do there, and also if opening all of them can be avoided, that would be great too.

    Again, thanks everyone for your help, and when we find a solution I'll definitely be sending it to a good number of people I've found looking for this.
    Last edited by erza-k-rot; September 15th, 2020 at 01:57 PM.

  9. #9
    Join Date
    Aug 2018
    Location
    England
    Beans
    52
    Distro
    Xubuntu

    Re: Extracting data from recently-used.xbel?

    I did not read the man page for Thunar carefully enough. I said it was late at night. Each file path parameter opens a new window. Here is the command, for what it is worth:

    Code:
    hxselect -c -s '\n' 'bookmark::attr(href)'<$HOME/.local/share/recently-used.xbel | sed 's![^/]*$!!' | sort -u | tr '\n' ' ' | awk '{print "thunar ", $0}' | bash
    An interesting exercise, but useless. I think the solution that we already have is the best one. Sorting out the character mapping problem would appear to be the way forward.

  10. #10
    Join Date
    Aug 2018
    Location
    England
    Beans
    52
    Distro
    Xubuntu

    Re: Extracting data from recently-used.xbel?

    I may have a solution for you. Xubuntu 20.04 ships with the Dolphin file manager in addition to Thunar. Dolphin offers the options of modified today and modified yesterday. If that is not enough, there are plenty of other file managers that you could install.

Page 1 of 4 123 ... LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •