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>"
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
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