You are not logged in.

#1 2021-03-05 19:22:41

ohnonot
...again
Registered: 2015-09-29
Posts: 5,383
Website

Openbox pipemenus: Recent files, transmission-daemon, ...

Recent files

I started working on it in this thread but decided on an almost complete rewrite.
There's a few recent files pipemenu scripts out there, but none that pays full attention to icons afaics.
I found that icons are important - not so much for eyecandy, but because they convey information, make it easier to recognize documents at a glance etc.
In the process of writing this I learned a lot about the freedesktop.org icon theme specification (how exactly applications traverse icon directories and Inherits to find suitable icons) and learned to appreciate it (and by extension most of their interoperability specifications).

The bash script

  • sorts the list by access time and updates the entry in recently-used.xbel when you open a file with it, i.e. next time you will see that file at the top of the list.

  • filters out entries that do not exist (anymore) or are unreadable for other reasons.

  • offers to open the file in question with all the applications listed in recently-used.xbel after checking they are present in PATH, and additionally with a mime-opener like 'xdg-open'.

  • assigns icons from the current icon theme and its Inherits, as close as possible to how e.g. Thunar does it.

  • caches icon paths and icons so that subsequent runs are much faster.

  • uses an absolute minimum of external commands & dependencies.

Icon display can be disabled; that speeds it up of course, but on my machine it loads near-instantly with icons too.
On a 5-year old consumer intel desktop I measured 0.019s for a run without icons, 0.047s for a run with cached icons, and 0.129s for the first run after deleting the icon cache.

Anyhow, here it is:
https://notabug.org/ohnonot/openbox-pipemenus/
https://framagit.org/ohnonot/openbox-pipemenus/

Here's its help text:

$> ./recent -h
Openbox pipemenu to create a list of recent files with or without icons.

Usage: ./recent [options]

Options:
-m int  maximum number of results to display. Default: 20
-s str  Consider icon sizes between min-max. Default: 22-64
-n      No icons at all. Default is to use icons.
-f      No full path on menu label, only filename
-x str  Application to mime-open files. xdg-open has some pitfalls when no DE
        is defined, mimeo (xyne.archlinux.ca/projects/mimeo/) might be more
        robust. Default: xdg-open
-r str  Recentfile to parse. Default: ~/.local/share/recently-used.xbel
-i str  Full path to mimetype icon directory to store symlinks to exisiting
        icons. Default: ~/.config/openbox/mimetype_icons
-g str  GTK rc/ini file to extract icon theme from.
        Default: ~/.config/gtk-3.0/settings.ini
-c      Clear the recentfile (access from pipemenu).

-d      Output debug info to stderr
-O str str  Attempt to find an icon for the supplied mimetype and category,
            then exit.

Dependencies:
        xmlstarlet: parsing recentfile
Optional:
        gio (glib2, libglib2.0-bin): get icons

Screenshot

Question: Is jgmenu capable of swallowing pipemenus? Is it capable of icon lookups (beyond XDG menu)?
I'm just wondering if this is even useful for normal Bunsen users, or if I'm re-inventing the wheel...
Anyhow, it was fun to code.

Transmission control

If you use transmission-daemon for downloading torrents, this might be interesting for you.

More pipemenus will be added to the repository...

Last edited by ohnonot (2021-03-07 16:04:09)


Please use CODE tags for code.
Search youtube without a browser: repo | thread
BL quote proposals to this thread please.
my repos / my repos

Offline

#2 2021-03-05 23:47:10

sleekmason
zoom
From: Ozarks
Registered: 2018-05-22
Posts: 570
Website

Re: Openbox pipemenus: Recent files, transmission-daemon, ...

This is pretty sharp. Lots of options to choose from.

I see you fixed the 'gnome-colors' problem by using ~/.config/gtk-3.0/settings.ini to grab the current icon theme? (with options for other locations from the menu! Ha!)

Super fast.  Can't really tell any delay here at all.
The "clear icon cache" buttons makes switching icon themes a breeze.
The "-h "help" menu is a nice touch.
Showing the number of files opened is a neat feature.

I originally had four "unreadable" files before I deleted the caches, but don't really know what they were. Does this simply mean that no program was found to open?

Well done.

Offline

#3 2021-03-06 01:22:10

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 7,851
Website

Re: Openbox pipemenus: Recent files, transmission-daemon, ...

Thanks onn! I'll definitely try this out.

ohnonot wrote:

Question: Is jgmenu capable of swallowing pipemenus?

Of course @malm is the canonical source of information on jgmenu, but as a user I can report that jgmenu has both native pipemenus (a script that produces a csv menu) and displays OpenBox XML pipemenus too, via a library.
The native pipemenus should be faster, and are also easier to write (esp if you use the functions in /usr/lib/bunsen/common/bl-includes) but OB pipemenus are perfectly usable and BunsenLabs still ships some (eg the "Places" menu).

Is it capable of icon lookups (beyond XDG menu)?

Sorry, I've no idea about how jgmenu handles icons. I certainly appreciate the point about extra visual info for the user, but BL menus display no icons by default - like CrunchBang. (We should think about how to make it easy to enable them for users who don't mind the extra system/visual load.)

I'm just wondering if this is even useful for normal Bunsen users, or if I'm re-inventing the wheel...

An OB pipemenu like this is perfectly usable for BL users with jgmenu. We do though, already have a recent files pipemenu (written in lua) which might well be tweakable to add the improvements in your script, possibly without icons though.

---
I might try some day to rewrite part of your script as a native jgmenu pipemenu, unless you'd like to do it yourself? It shouldn't be too hard as the syntax is simpler, if anything, than XML.

it was fun to code

smile


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), idle Twitterings and GitStuff )

Introduction to the Bunsenlabs Lithium Desktop

Offline

#4 2021-03-07 16:01:43

ohnonot
...again
Registered: 2015-09-29
Posts: 5,383
Website

Re: Openbox pipemenus: Recent files, transmission-daemon, ...

Thanks for your kind comments.

johnraff, feel free to rewrite it all you wish, it's GPL anyhow.

I have also worked on the other pipemenu in that repo, to whom it may concern.


Please use CODE tags for code.
Search youtube without a browser: repo | thread
BL quote proposals to this thread please.
my repos / my repos

Offline

#5 2021-03-08 03:12:05

DeepDayze
Like sands through an hourglass...
From: In Linux Land
Registered: 2017-05-28
Posts: 1,197

Re: Openbox pipemenus: Recent files, transmission-daemon, ...

The current script for recent files as in Lithium does not show the icons for the items in that menu.


Real Men Use Linux

Offline

#6 2021-03-08 04:12:21

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 7,851
Website

Re: Openbox pipemenus: Recent files, transmission-daemon, ...

^No, none of the current BL menus have icons. That tradition goes back to CrunchBang, and many users prefer the "cleaner" look of a text-only menu. But it's true that icons add a visual clue for users to quickly find the item they're looking for.

jgmenu itself (and openbox), though, does support icons, and it's not hard to make the BL main menu display them.


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), idle Twitterings and GitStuff )

Introduction to the Bunsenlabs Lithium Desktop

Offline

#7 2021-03-08 04:27:52

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 7,851
Website

Re: Openbox pipemenus: Recent files, transmission-daemon, ...

ohnonot wrote:

In the process of writing this I learned a lot about the freedesktop.org icon theme specification  and learned to appreciate it (and by extension most of their interoperability specifications).

Thanks for the useful link! I always seem to be searching for XD -thisorthat and have to do a lot of clicking to get to the True Word. This has it all on one page, cool
In particular, a link from there to the current standards for that recently-used.xbel file: https://www.freedesktop.org/wiki/Specif … mark-spec/


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), idle Twitterings and GitStuff )

Introduction to the Bunsenlabs Lithium Desktop

Offline

#8 2021-03-08 07:14:47

ohnonot
...again
Registered: 2015-09-29
Posts: 5,383
Website

Re: Openbox pipemenus: Recent files, transmission-daemon, ...

^ ah, thanks. I will have to look at that evtl. - right now I think I'm taking a break from this project.

DeepDayze wrote:

The current script for recent files as in Lithium does not show the icons for the items in that menu.

And including icons was the hardest part in mine!


Please use CODE tags for code.
Search youtube without a browser: repo | thread
BL quote proposals to this thread please.
my repos / my repos

Offline

#9 2021-03-08 14:14:59

DeepDayze
Like sands through an hourglass...
From: In Linux Land
Registered: 2017-05-28
Posts: 1,197

Re: Openbox pipemenus: Recent files, transmission-daemon, ...

ohnonot wrote:

^ ah, thanks. I will have to look at that evtl. - right now I think I'm taking a break from this project.

DeepDayze wrote:

The current script for recent files as in Lithium does not show the icons for the items in that menu.

And including icons was the hardest part in mine!

No doubt and I bet the coding for that is not that trivial.


Real Men Use Linux

Offline

Board footer

Powered by FluxBB