How to show Recently Used Documents on JWM's Start Menu

How to do things, solutions, recipes, tutorials
Message
Author
User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

How to show Recently Used Documents on JWM's Start Menu

#1 Post by MochiMoppel »

This is in response to this 5 years old post asking "is there a way to display my most recently used files on my Puppy menu?".

For JWM certainly a case of "mission impossible" at the time of the post, but JWM has evolved and now it's fairly easy and a good excuse to play with the new <dynamic> feature.

For this demo I read the content of the file recently-used.xbel. Many, but not all gtk applications use this file. It may not even exist. If it exists then the content is also visible in the "Open File" dialog (see screenshot)

Requirements: JWM version 2.3 or newer. How do you know which version you are running? You may try the command jwm -v, but most Puppybuilders don't ship final versions and the command might output a cryptic number like vgit-871. A simple workaround: Press Alt+F1. This should open the main menu. If the menu opens under the mouse pointer, it's v2.3. If the menu opens in the top left corner, you'll have to upgrade JWM to make below solution work.

Step 1: Create a script:

Code: Select all

#!/bin/sh
XBEL_PATH=/root/.local/share/recently-used.xbel
MAX_ITEMS=20

if [[ -e $XBEL_PATH ]];then
	ITEMS=$(sed -rn 's_.*file://([^"]*).*_<Program label="\1">rox -s "\1"</Program>_ p' "$XBEL_PATH")
else 
	ITEMS="<Program label=\"File ${XBEL_PATH##*/} not found!\"></Program>" 
fi
echo    "<JWM>"
echo -e "${ITEMS//%/\\x}" | tail -n $MAX_ITEMS
echo    "</JWM>"
Step2: Save the script with any name and make it executable. For the purpose of this demo I named it dynamicmenu_recent.sh and saved it to folder /root/.jwm (any other folder would also be fine but this script makes only sense in the context of JWM, so I add it to the other JWM config files).

Step3. Edit /etc/xdg/templates/_root_.jwmrc and add 1 line:
  • <?xml version="1.0"?>
    <JWM>
    <!-- IMPORTANT, ONLY EDIT /etc/xdg/templates/_root_.jwmrc -->
    <!-- jwm menu for puppy Linux -->
    <RootMenu label="Menu" labeled="false" height="24" onroot="3">
    <Dynamic label="Recently used">exec: /root/.jwm/dynamicmenu_recent.sh</Dynamic>
    PUPPYMENU jwm-xdgmenu /etc/xdg/menus/puppy-desktop.menu
Step3: Save and then in console run
fixmenus
jwm -reload

That's it. Your Puppy menu should have a new menu item "Recently used".
Clicking on a menu item will show the location in a ROX-Filer window.

Technical notes:
JWM expects the script referenced in the <dynamic> tag to output a string in the same format as would be used for an <include> tag. The only difference is that in case of <include> JWM keeps the whole menu in memory and refreshes it only when it receives a jwm -reload command while in case of <dynamic> JWM always performs a reload of the <dynamic> submenu when the user opens the main (!) menu (i.e. even if you place the <dynamic> submenu at the end of the main menu and don't open it, the script will be executed in any case)

Older Puppies may use a different path for the xbel file: /root/.recently-used.xbel
In this case adapt the code or - if in doubt - use
XBEL_PATH=$(find /root -name *recently-used.xbel)

Adapt the value of MAX_ITEMS if you require more/less menu items displayed. There also seems to exist a gtk option 'gtk-recent-files-limit' to control the line numbers but I couldn't get it to work.

Edit1: Changed echo command to avoid JWM crash when no. of items in xbel file greater than MAX_ITEMS
Attachments
recently_menu_opendialog.png
Composite of 2 screenshots taken at different time, so content slightly differs
(53.37 KiB) Downloaded 1418 times
Last edited by MochiMoppel on Sun 25 Sep 2016, 14:22, edited 1 time in total.

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#2 Post by zigbert »

Great stuff!
I have integrated into jwm_config.
https://github.com/puppylinux-woof-CE/w ... 3617124b3a

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#3 Post by musher0 »

@zigbert:
Indeed MM did a great job on this little script, but Puppy does not have a
policy of giving credit to a member for preparatory research on a subject, eh?

MM had the intellectual honesty of mentioning where his script evolved
from, but the github Puppy people are not going to, right? He also had the
consideration of asking on the original thread if someone else would do it
before he started work on it.

That policy of yours, if it is a policy, is frankly insulting, and will be a
detriment to Puppy should it get known in the general Linuxian community
and / or publicly.

I have given credit to Mochi Moppei and others for their comments and
suggestions about my MRUF script inside the script itself and on the thread.

Why can't you from the github Puppy development team have the
generosity of mind to recognize the preliminary research and achievements
that I have done on that subject for non-jwm window managers?

Viewed from here, that attitude coming from one of the Woof-CE majors
looks a lot like a type of chauvinism against non-jwm development.

Regards.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#4 Post by MochiMoppel »

I edited my initial post to fix a bug in the script (see Edit 1).

Regarding the origin of the script : It didn't have to evolve from anywhere. It already existed. I simply copied it (not worth any credits :lol: ) from my earlier application SpeedDials 2.0and adapted it to the JWM syntax. SpeedDials can also show Recent Used files and is also dynamic, but it is not integrated into the menu and has a different purpose.
Attachments
SpeedDialvsDynamicMenu.png
(58.16 KiB) Downloaded 1282 times

mfb

#5 Post by mfb »

Thank you MochiMoppel.

Re: post immediately below - here is a pet of the latest version of jwm - it works for me - but, for safety, backup before trying it.
Attachments
jwm-1553.pet
(143.24 KiB) Downloaded 518 times
Last edited by mfb on Sun 25 Sep 2016, 22:47, edited 1 time in total.

User avatar
LazY Puppy
Posts: 1934
Joined: Fri 21 Nov 2014, 18:14
Location: Germany

#6 Post by LazY Puppy »

...you'll have to upgrade JWM to make below solution work.
How to do this update of jwm to 2.3?

PPM doesn't have a newer version than 2.1 (tahr puppy).

One needs to compile for oneself?
RSH

"you only wanted to work your Puppies in German", "you are a separatist in that you want Germany to secede from Europe" (musher0) :lol:

No, but I gave my old drum kit away for free to a music store collecting instruments for refugees! :wink:

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#7 Post by musher0 »

mfb wrote:Thank you MochiMoppel.

Re: post immediately below - here is a pet of the latest version of jwm - it works for me - but, for safety, backup before trying it.
Hello.

Please mention the URL where you found that exec (on the Internet or on
this forum) if you did not compile it yourself?

If you compiled it yourself, please state where does the source code
come from? The jwm site? Also, the ./config formula: it is important to
know if all functions of the app have been enabled at compile time to
prevent head-scratching later.

Finally, on which Puppy and what glibc library that Puppy had? As you
know, compiling an app on a Pup that has C library 2.19 (Dpup-4.87 or
Librepup, for example) will prevent that app from running on a Puppy
that runs with a lower version of the C library.

TIA.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#8 Post by musher0 »

Hello all.

I just tested the jwm-1553 offered above on the Puduan-6 Pup.

Using it I am sent back to the no X console whenever I try to get the
menu (right-click). I never got a chance to see MM's dynamic script in
action.

Considering that the jwm 2.3.5 that came with the woof-CE does not
decorate the windows correctly (no square buttons to the right for close,
iconify and expand), I'd venture to say that these new jwm's still need
work before being officially released.

By comparison, when Chris Cannam, the author of wmx, puts out a
new version, the user never experiences such frustrations: when a new
version of wmx is released, it is really ready to be presented to the
public.

The jwm version that works well on the Puduan is v. 2.2.2. Period.

Put that in your pipe and smoke it. BFN.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

User avatar
LazY Puppy
Posts: 1934
Joined: Fri 21 Nov 2014, 18:14
Location: Germany

#9 Post by LazY Puppy »

RSH

"you only wanted to work your Puppies in German", "you are a separatist in that you want Germany to secede from Europe" (musher0) :lol:

No, but I gave my old drum kit away for free to a music store collecting instruments for refugees! :wink:

Sailor Enceladus
Posts: 1543
Joined: Mon 22 Feb 2016, 19:43

#10 Post by Sailor Enceladus »

@LazY Puppy: I think Tahrpup already has 2.3? It has the flat look of it with no borders anyway.

User avatar
LazY Puppy
Posts: 1934
Joined: Fri 21 Nov 2014, 18:14
Location: Germany

#11 Post by LazY Puppy »

Sailor Enceladus wrote:@LazY Puppy: I think Tahrpup already has 2.3? It has the flat look of it with no borders anyway.
In tahr 602 at Alt F1 or F12 the JWM menu appears at left/top corner, so regarding MochiMoppels description it says: it is below 2.3. Also it returns a version number 971 git something (or similar). Surely I don't have time to waste, so I wouldn't had tried to compile JWM for tahr 602 if there were alread 2.3 installed. Need to check tahr 605 though.

Edit: checked tahr 605. The JWM menu appears at left/top corner. Returns version vgit 976.

Edit2: checked xenial 704 binary. It returns version 2.3.5, mentioned by musher0 for its issues to not to decorate the windows correctly.

Edit3: Tested the 32bit package in Unicorn 6.0 and Vivid beta2. Works!

Anyway, thanks for that info. Assuming an equal version in tahr64 605 I can't recall ever trying Alt F1 or F12, so I can't say how it works.

Though currently running thar64 605 with the compiled 2.3.6 binary the menu appears under the mouse pointer position.

Checked the jwm binary in /initrd/pup_ro2/usr/bin/jwm returns 2.3.4.

Code: Select all

root# /initrd/pup_ro2/usr/bin/jwm -version
unrecognized option: -version
JWM v2.3.4 by Joe Wingbermuehle
compiled options: confirm fribidi icons jpeg nls png shape svg xbm xft xinerama xpm xrender 
system configuration: /etc/system.jwmrc
usage: jwm [ options ]
  -display X  Set the X display to use
  -exit       Exit JWM (send _JWM_EXIT to the root)
  -f file     Use specified configuration file
  -h          Display this help message
  -p          Parse the configuration file and exit
  -reload     Reload menu (send _JWM_RELOAD to the root)
  -restart    Restart JWM (send _JWM_RESTART to the root)
  -v          Display version information
root#
I think I can keep the .pet packages attached, for named reasons and its new version number, though.
RSH

"you only wanted to work your Puppies in German", "you are a separatist in that you want Germany to secede from Europe" (musher0) :lol:

No, but I gave my old drum kit away for free to a music store collecting instruments for refugees! :wink:

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#12 Post by MochiMoppel »

mfb wrote:here is a pet of the latest version of jwm - it works for me
Thanks, works for me too (Slacko 5.6). I didn't install the pet, I only extracted the jwm binary. That's all we need :lol:
LazY Puppy wrote:How to do this update of jwm to 2.3?
Maybe I shouldn't have mentioned upgrading at all. JWM 2.3 comes with some syntax changes which may require changes in the user's JWM config files, so upgrading only JWM would only be for experienced users. The safest bet is to stay with the version that came with the Puppy.
LazY Puppy wrote:One needs to compile for oneself?
That's what I did because I wanted a final version and not a snapshot. The manual refers to version numbers, not to -vgit numbers. I consider snapshots experimental.
LazY Puppy wrote:checked tahr 605. The JWM menu appears at left/top corner. Returns version vgit 976.
Confirmed. JWM in Tahrpup stays at vgit 976 since 2 years. <Dynamic> is not yet implemented.
musher0 wrote:Using it I am sent back to the no X console whenever I try to get the menu
Looks like you used the original script and not the bugfixed version (see Edit 1)

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#13 Post by musher0 »

@MM
Ah. Thanks for the info. Your edited version works fine now with jwm-2.3.5.

BFN.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

B.K. Johnson
Posts: 807
Joined: Mon 12 Oct 2009, 17:11

#14 Post by B.K. Johnson »

Hey guys
You should be aware that the offering by mfb, though MochiMoppel got it to work and is not recommended for people like me is a snapshot as shown by this excerpt from Joe's website
Download

Current release: JWM v2.3.6 (sig, release notes, older releases)
Latest development snapshot: JWM snapshot 1553 (sig, release notes, older snapshots)
See the ChangeLog for details on what has changed (releases and snapshots are tagged).
[color=blue]B.K. Johnson
tahrpup-6.0.5 PAE (upgraded from 6.0 =>6.0.2=>6.0.3=>6.0.5 via quickpet/PPM=Not installed); slacko-5.7 occasionally. Frugal install, pupsave file, multi OS flashdrive, FAT32 , SYSLINUX boot, CPU-Dual E2140, 4GB RAM[/color]

User avatar
Puppus Dogfellow
Posts: 1667
Joined: Tue 08 Jan 2013, 01:39
Location: nyc

#15 Post by Puppus Dogfellow »

thanks, Mochi. (also thanks to LazyPupy--32 bit jwm 236 pet didn't work in precise (5.7.2), but 64bit worked in tahr64 without a reboot or x restart (precise showed 2.3.6 in response to jwm -v, but it didn't show any traces of the new syntax (my trays should've needed adjusting) or the mouse pointer change that Mochi mentions in the opening post. -reload, -restart --no change. x restart gave me a black screen. reboot gave me a black screen. i removed the dynamic line by accessing the file with another installation. rebooted into the precise install--black screen. anyway, i don't recommend the 32 bit pet in precise, or i am here to say i can't get it to work and seem to have killed that installation)).

8) :P :?

User avatar
PeterRJG
Posts: 12
Joined: Sat 23 Feb 2013, 13:33
Location: Northern NSW, Australia
Contact:

#16 Post by PeterRJG »

Edit - I'll ask this in the right place.

B.K. Johnson
Posts: 807
Joined: Mon 12 Oct 2009, 17:11

#17 Post by B.K. Johnson »

Most Recently Used Documents (MRUD) has a bug arising from failure to check limits during testing.
The screenshot shows a file with a short path. That may not be typical; it certainly isn't for me. My hard drive holds an XP system and to keep it "pure", I keep my files at say /mnt/sda1/Documents and Settings/user/My Documents/Downloads/PUPPIES/bionicpup32-8.0+x-uefi_k4.9.163. Such a long path cannot be fully displayed in MRUD which by default hangs the list of files from the left. Even if Menu is opened from the extreme right, there may still be difficulty. peebee included the application in upupbb, but it is a menu item from "Places" which is near the far left edge and immovable, thereby giving a display area of only about 5 inches.
[color=blue]B.K. Johnson
tahrpup-6.0.5 PAE (upgraded from 6.0 =>6.0.2=>6.0.3=>6.0.5 via quickpet/PPM=Not installed); slacko-5.7 occasionally. Frugal install, pupsave file, multi OS flashdrive, FAT32 , SYSLINUX boot, CPU-Dual E2140, 4GB RAM[/color]

User avatar
BarryK
Puppy Master
Posts: 9392
Joined: Mon 09 May 2005, 09:23
Location: Perth, Western Australia
Contact:

#18 Post by BarryK »

Gee, MochiMoppel posted about this technique in 2016, and I have only today seen it!

It is really great, I will checkout how to put into EasyOS. I note the point about long paths, will think about that.
[url]https://bkhome.org/news/[/url]

B.K. Johnson
Posts: 807
Joined: Mon 12 Oct 2009, 17:11

#19 Post by B.K. Johnson »

Please do Barry
I suggested to Mochi that he limit the display to file name only but retain the full path for execution.
While at it, note that in MM's Speed dial, the progenitor, the list hangs off the right while on MRUD it hangs from the left.
[color=blue]B.K. Johnson
tahrpup-6.0.5 PAE (upgraded from 6.0 =>6.0.2=>6.0.3=>6.0.5 via quickpet/PPM=Not installed); slacko-5.7 occasionally. Frugal install, pupsave file, multi OS flashdrive, FAT32 , SYSLINUX boot, CPU-Dual E2140, 4GB RAM[/color]

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#20 Post by MochiMoppel »

B.K. Johnson wrote:I suggested to Mochi that he limit the display to file name only but retain the full path for execution.
...which would be very easy, but you also told me that even the basenames of your files may be very long (e.g.web page article titles). So here your idea wouldn't help, right? And if the number of characters should be limited, what would this maximum number be and how should the name be truncated if it exceeds the limit and should full path names be shown if they fit within the limit? Lots of questions remain...

Post Reply