Add A JWM Bookmarks Menu or Submenu/Messing Around With JWM

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

#76 Post by MochiMoppel »

Puppus, if you have followed the earlier example to create a separate menu (mymenu, to be opened by middle click), the following script would replace your current mymenu with the ROX bookmarks. You can run this whenever your ROX bookmarks change:

Code: Select all

#!/bin/sh
MENUPATH="/path/to/mymenu"
sed 's|^[ \t]*||g' /root/.config/rox.sourceforge.net/ROX-Filer/Bookmarks.xml | tr -d "\n" |
sed '
s|<bookmarks>|\n<JWM>\n<RootMenu onroot="2">\n|
s|</bookmarks>|</RootMenu>\n</JWM>|
s|<bookmark title=|<Program label=|g
s|</bookmark>|"</Program>\n|g
s|\(<Program label[^>]*>\)|\1rox "|g
' > "$MENUPATH"
jwm -reload
If you follow the route of greengeek and musher0, i.e. to integrate the bookmarks into the main menu, you could use this script to create a file places_submenu

Code: Select all

#!/bin/sh
MENUPATH="/path/to/places_submenu"
sed 's|^[ \t]*||g' /root/.config/rox.sourceforge.net/ROX-Filer/Bookmarks.xml | tr -d "\n" |
sed '
s|<bookmarks>|\n<JWM>\n<Menu label="Places" icon="/usr/local/PupControl/icons/gtkicons20.png">\n|
s|</bookmarks>|</Menu>\n</JWM>|
s|<bookmark title=|<Program label=|g
s|</bookmark>|"</Program>\n|g
s|\(<Program label[^>]*>\)|\1rox "|g
' > "$MENUPATH"
jwm -reload
EDIT1: Changed code to accomodate various file formats created by ROX
EDIT2: Changed code to handle directory names containing spaces


Include above submenu in /etc/xdg/templates/_root_.jwmrc like this:

<RootMenu label="Menu" labeled="false" height="24" onroot="3">
<Include>/path/to/places_submenu</Include>
PUPPYMENU jwm-xdgmenu /etc/xdg/menus/puppy-desktop.menu
PUPPYMENU jwm-xdgmenu /etc/xdg/menus/puppy-system.menu


Run fixmenus once and you are done with fixmenus and _root_.jwmrc. You'll never have to touch this file again :lol:
Running above script will update the main menu with your ROX bookmarks.
Attachments
places_submenu.png
(11.07 KiB) Downloaded 456 times
Last edited by MochiMoppel on Sat 24 May 2014, 12:41, edited 2 times in total.

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

#77 Post by Puppus Dogfellow »

MochiMoppel wrote:Puppus, if you have followed the earlier example to create a separate menu (mymenu, to be opened by middle click), the following script would replace your current mymenu with the ROX bookmarks. You can run this whenever your ROX bookmarks change:

Code: Select all

#!/bin/sh
MENUPATH="/path/to/mymenu"
sed '
s|<bookmarks>|<JWM>\n<RootMenu onroot="2">|
s|</bookmarks>|</RootMenu>\n</JWM>|
s|<bookmark title=|<Program label=|
s|</bookmark>|</Program>|
s|\(<Program label[^>]*>\)|\1rox |
' /root/.config/rox.sourceforge.net/ROX-Filer/Bookmarks.xml > "$MENUPATH"
jwm -reload
If you follow the route of greengeek and musher0, i.e. to integrate the bookmarks into the main menu, you could use this script to create a file places_submenu

Code: Select all

#!/bin/sh
MENUPATH="/path/to/places_submenu"
sed '
s|<bookmarks>|<JWM>\n<Menu label="Places" icon="/usr/local/PupControl/icons/gtkicons20.png">|
s|</bookmarks>|</Menu>\n</JWM>|
s|<bookmark title=|<Program label=|
s|</bookmark>|</Program>|
s|\(<Program label[^>]*>\)|\1rox |
' /root/.config/rox.sourceforge.net/ROX-Filer/Bookmarks.xml > "$MENUPATH"
jwm -reload
Include above submenu in /etc/xdg/templates/_root_.jwmrc like this:

<RootMenu label="Menu" labeled="false" height="24" onroot="3">
<Include>/path/to/places_submenu</Include>
PUPPYMENU jwm-xdgmenu /etc/xdg/menus/puppy-desktop.menu
PUPPYMENU jwm-xdgmenu /etc/xdg/menus/puppy-system.menu


Run fixmenus once and you are done with fixmenus and _root_.jwmrc. You'll never have to touch this file again :lol:
Running above script will update the main menu with your ROX bookmarks.
Mochi, that second script creates the submenu and populates it with the Rox bookmarks? :shock: if so, that's amazing. if not, it's still great to have both options. thanks yet another ton...

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

#78 Post by MochiMoppel »

Puppus Dogfellow wrote:that second script creates the submenu and populates it with the Rox bookmarks?
Yes.

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

#79 Post by Puppus Dogfellow »

MochiMoppel wrote:
Puppus Dogfellow wrote:that second script creates the submenu and populates it with the Rox bookmarks?
Yes.
holy crap is that great. :lol:

just out of curiosity, does the "submenu" in "places_submenu" change how the item gets treated by jwm or could it have been named anything?

and really, thanks again.

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

#80 Post by MochiMoppel »

No, you can name it anything you like.

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

#81 Post by Puppus Dogfellow »

MochiMoppel wrote:No, you can name it anything you like.
cool, but i stuck with your title.

ran into some sort of problem on a fresh installation. it only did some of the bookmarks and required a reboot to show up in the menu, though i didn't try an x-restart, just a few reloads and fixmenus. anyway, here's the "/root/places_submenu" file:

Code: Select all

<?xml version="1.0"?>
<JWM>
<Menu label="Places" icon="/usr/local/PupControl/icons/gtkicons20.png">
  <Program label="/mnt/sda1/dwnldsfff/pets">rox /mnt/sda1/dwnldsfff/pets</Program>
<Program label="/root/Startup">rox /root/Startup</Program><bookmark title="/root/Downloads">/root/Downloads</bookmark><bookmark title="/usr/share/applications">/usr/share/applications</bookmark><bookmark title="/root/puppy-reference">/root/puppy-reference</bookmark></Menu>
</JWM>
and the (backup, see below) rx2mm file that generated it:

Code: Select all

#!/bin/sh
MENUPATH="/root/places_submenu"
sed '
s|<bookmarks>|<JWM>\n<Menu label="Places" icon="/usr/local/PupControl/icons/gtkicons20.png">|
s|</bookmarks>|</Menu>\n</JWM>|
s|<bookmark title=|<Program label=|
s|</bookmark>|</Program>|
s|\(<Program label[^>]*>\)|\1rox |
' /root/.config/rox.sourceforge.net/ROX-Filer/Bookmarks.xml > "$MENUPATH"
jwm -reload
what did i do wrong? to give it another go, all i need do is erase that "includes" line from _root_.jwmrc and fixmenus/jwm reload, right? because now that i think about it, i think the script i actually ran it from was called "places_submenu," which in turn got overwritten as the xml file, and that seems like enough of a mistake to have caused the problem. was it?

thank you for your patience.

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

#82 Post by MochiMoppel »

Puppus Dogfellow wrote:what did i do wrong?
Nothing. My Bookmarks.xml has one line for each bookmark. It appears that different ROX versions use the same syntax, but different file formats.
I changed the code (see my previous updated post) and it should be OK now for all versions. Could you please give it a test run? It works for me.

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

#83 Post by Puppus Dogfellow »

MochiMoppel wrote:
Puppus Dogfellow wrote:what did i do wrong?
Nothing. My Bookmarks.xml has one line for each bookmark. It appears that different ROX versions use the same syntax, but different file formats.
I changed the code (see my previous updated post) and it should be OK now for all versions. Could you please give it a test run? It works for me.
works for me, too. updates instantly. you're a Wizard, Mochi.

:D

i dragged the update (/create) script to the desktop and gave it an icon. doubt i'd ever set up a puppy without putting this in place. really excellent.

User avatar
RSH
Posts: 2397
Joined: Mon 05 Sep 2011, 14:21
Location: Germany

#84 Post by RSH »

This is interesting.

Is there a solution to do this for the recently used files (file: recently-used.xbel)?
[b][url=http://lazy-puppy.weebly.com]LazY Puppy[/url][/b]
[b][url=http://rshs-dna.weebly.com]RSH's DNA[/url][/b]
[url=http://murga-linux.com/puppy/viewtopic.php?t=91422][b]SARA B.[/b][/url]

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

#85 Post by musher0 »

RSH wrote:This is interesting.

Is there a solution to do this for the recently used files (file: recently-used.xbel)?
Hello, RSH.

Here's an appetizer to what you're looking for, based on aemenu.
http://murga-linux.com/puppy/viewtopic. ... 613#737639

Best regards.

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

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

#86 Post by Puppus Dogfellow »

musher0 wrote:
RSH wrote:This is interesting.

Is there a solution to do this for the recently used files (file: recently-used.xbel)?
Hello, RSH.

Here's an appetizer to what you're looking for, based on aemenu.
http://murga-linux.com/puppy/viewtopic. ... 613#737639

Best regards.

musher0
another needed (or at the very least, excellent) tweak. your script works great in precise 571, musher (i upped it and the aemenu dependency to my repo). it's a new setup, so maybe i haven't set it up as completely as i think, but in rox, odt opens with LO; your script opens it with abi. is there a way to change it? (as i said, i may not have adjusted the defaults...) anyway, seems pretty easy to add your script to the jwm menu or tray, as a popup if not a rollup. (roll down?--trying to remember what term you used).

anyway, very cool. very nice.

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

#87 Post by musher0 »

Puppus Dogfellow wrote:
musher0 wrote:
RSH wrote:This is interesting.

Is there a solution to do this for the recently used files (file: recently-used.xbel)?
Hello, RSH.

Here's an appetizer to what you're looking for, based on aemenu.
http://murga-linux.com/puppy/viewtopic. ... 613#737639

Best regards.

musher0
another needed (or at the very least, excellent) tweak. your script works great in precise 571, musher (i upped it and the aemenu dependency to my repo). it's a new setup, so maybe i haven't set it up as completely as i think, but in rox, odt opens with LO; your script opens it with abi. is there a way to change it? (as i said, i may not have adjusted the defaults...) anyway, seems pretty easy to add your script to the jwm menu or tray, as a popup if not a rollup. (roll down?--trying to remember what term you used).

anyway, very cool. very nice.
Hello, Puppus D.

Thanks for the flower! It's simple enough to adapt it. In the file
/usr/local/bin/defaultwordprocessor, change the executable < abiword > to < soffice >.

Of course, double check that a < soffice > link or executable is somewhere in one of
the following binary paths: /usr/bin, /usr/local/bin or /root/my-applications/bin.

Please note that my script works most of the time. Some extensions are still not
recognized, nothing will happen when you'll click on those. I couldn't figure out why.
Are Puppy's MIME-types wanting? Or maybe Puppy doesn't have enough default-this-
and-that-executable in /usr/local/bin?

Maybe RSH can apply his powerful brain :) to solving the rest of this mystery!

In any case, we're lucky to have something, because before, there was nothing. :)
(That's profound, don't you think?! I'm feeling philosophical this morning!) :)

BFN.

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

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

#88 Post by Puppus Dogfellow »

musher0 wrote:
Thanks for the flower! It's simple enough to adapt it. In the file
/usr/local/bin/defaultwordprocessor, change the executable < abiword > to < soffice >.

Of course, double check that a < soffice > link or executable is somewhere in one of
the following binary paths: /usr/bin, /usr/local/bin or /root/my-applications/bin.

Please note that my script works most of the time. Some extensions are still not
recognized, nothing will happen when you'll click on those. I couldn't figure out why.

Are Puppy's MIME-types wanting? Or maybe Puppy doesn't have enough default-this-
and-that-executable in /usr/local/bin?

Maybe RSH can apply his powerful brain :) to solving the rest of this mystery!

In any case, we're lucky to have something, because before, there was nothing. :)
(That's profound, don't you think?! I'm feeling philosophical this morning!) :)

BFN.

musher0
i was about to report that the text files stopped responding. on the bright side, one such file's last mortal twitch was to open up geany with a file that had the info for default word processor ("take me instead"?). i didn't notice if it was the same file you specified above, but i changed it to "libreoffice4.2 --writer" and those files now work with no problem, it seems.

and yes, it's good to have something to work with--a ladder functions better against a wall than thrown down a well. also, real ladders are often sturdier than their imaginary counterparts.

[i'm feeling more groggy than philosophical, but you deserve the flower and your comment echoes the development of cultures. and many manufactured goods.]

:)


and i agree: RSH taking an active interest in this is certainly a good omen.

on a related note, i wonder if Mochi's xml brilliance works with xbel files... (as perhaps was RSH).

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

#89 Post by musher0 »

A simple cure for those file ailments would be to have, in the defaultwordprocessor file:
soffice --writer || abiword .
That means : if soffice is present in your binary paths, use it; if not, fall back on abiword.

That way, if the user does not have LO or aOO installed, the file will open in abiword.
But the user who has Libre Office won't be frustrated!

Same goes for gnumeric.
soffice --calc || gnumeric

In defaultbrowser, perhaps
seamoney || firefox || palemoon || midori || opera

I'm sure you're getting the idea.

Why no Puppyist has thought of this simple trick before, only God knows! :)

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

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

#90 Post by Puppus Dogfellow »

musher0 wrote:A simple cure for those file ailments would be to have, in the defaultwordprocessor file:
soffice --writer || abiword .
That means : if soffice is present in your binary paths, use it; if not, fall back on abiword.

That way, if the user does not have LO or aOO installed, the file will open in abiword.
But the user who has Libre Office won't be frustrated!

Same goes for gnumeric.
soffice --calc || gnumeric

In defaultbrowser, perhaps
seamoney || firefox || palemoon || midori || opera

I'm sure you're getting the idea.

Why no Puppyist has thought of this simple trick before, only God knows! :)

BFN.
thanks for the syntax lesson, musher.

uh, where on the keyboard is that pipe character?

edit: nevermind. only the logitech keyboard had it labeled as itself broken in the middle. still shows up as | regardless.

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

a winning solution for rox bookmarks on the JWM menu

#91 Post by Puppus Dogfellow »

for any who've been following this thread, or for any new to it, MochiMoppel's second script atop the previous page beautifully and simply adds a bookmarks menu to your existing JWM menu. easiest way to implement it is probably to just change the "/path/to/places_submenu" part of it to "/root/places_submenu".

copy the script to a leafpad or geany document, name it mbm or something similarly brief, and put it in a bin folder of some sort or another. right click it to change permissions (if text is not already green). you can then activate it again (to update the list should you modify your existing bookmarks in some way) by typing that brevity into a terminal and pressing enter, or by simply clicking on it. i gave my copy a little icon after dragging it to the desktop. it's unobtrusive and updates the list in the amount of time it takes to move from a left click on the file to a right click off of it (on blank desktop real estate).

helpful hint: mtpaint can make invisible icons. you can set one up in a corner or between your drive icons for this purpose.

here's a template for an invisible icon, which you can doodle up and resize if you like.

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

#92 Post by MochiMoppel »

The King of Keyboard Shortcuts using desktop icons? :shock: But you are right: There has to be something on the desktop with all these directory icons gone...

You can also put the shortcut into be "Places" submenu. Might come handy when the desktop icon is buried under a pile of open windows.
Just add one line to the script:

s|</bookmark>|"</Program>\n|g
s|\(<Program label[^>]*>\)|\1rox "|g

s|</Menu>|<Separator/>\n<Program label="Refresh me!" icon="mini-turn.xpm">\"'$(realpath $0)'\"</Program>\n</Menu>|
' > "$MENUPATH"
jwm -reload


The line replaces the </Menu> tag with 2 new menu items ( a separator line and a <Program..../Program> part which links to the script ), then reattaches the </Menu> tag. The $(realpath $0) stuff will be replaced by the script with its own path. You don't have to change anything here.

If everything went well and you named your script mbm, the resulting file /root/places_submenu would look like this:

Code: Select all

<?xml version="1.0"?>
<JWM>
<Menu label="Places" icon="/usr/local/PupControl/icons/gtkicons20.png">
<Program label="/usr/share">rox "/usr/share"</Program>
<Program label="/usr/local">rox "/usr/local"</Program>
<Program label="/usr/local/bin">rox "/usr/local/bin"</Program>
<Separator/>
<Program label="Refresh me!" icon="mini-turn.xpm">"/usr/bin/mbm"</Program>
</Menu>
</JWM>
Attachments
places_submenu_refresh.png
(12.73 KiB) Downloaded 608 times

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

#93 Post by Puppus Dogfellow »

MochiMoppel wrote:The King of Keyboard Shortcuts using desktop icons? :shock: But you are right: There has to be something on the desktop with all these directory icons gone...

You can also put the shortcut into be "Places" submenu. Might come handy when the desktop icon is buried under a pile of open windows.
Just add one line to the script:

s|</bookmark>|"</Program>\n|g
s|\(<Program label[^>]*>\)|\1rox "|g

s|</Menu>|<Separator/>\n<Program label="Refresh me!" icon="mini-turn.xpm">"'$(realpath $0)'"</Program>\n</Menu>|
' > "$MENUPATH"
jwm -reload


The line replaces the </Menu> tag with 2 new menu items ( a separator line and a <Program..../Program> part which links to the script ), then reattaches the </Menu> tag. The $(realpath $0) stuff will be replaced by the script with its own path. You don't have to change anything here.

If everything went well and you named your script mbm, the resulting file /root/places_submenu would look like this:

Code: Select all

<?xml version="1.0"?>
<JWM>
<Menu label="Places" icon="/usr/local/PupControl/icons/gtkicons20.png">
<Program label="/usr/share">rox "/usr/share"</Program>
<Program label="/usr/local">rox "/usr/local"</Program>
<Program label="/usr/local/bin">rox "/usr/local/bin"</Program>
<Separator/>
<Program label="Refresh me!" icon="mini-turn.xpm">"/usr/bin/mbm"</Program>
</Menu>
</JWM>
Nice tweak, Mochi, and a better and more elegant solution than the desktop icon, i must say. as to the shortcut king title and its implications and practicality--alt+space bar (/mnt and the rox bookmarks pull down itself) and F2 (disciple's script) both get me into already updated lists in their own ways so i saw no need to make this into a two step affair--it seemed to defeat the purpose somewhat, though i suppose the updating could be done on the fly and at one's leisure, or in lieu or augmentation of tapping one's fingers, etc.

nicely integrated and pleasant to look at, and also a convenient reminder. as usual, well done, Mochi.

:D

[just tried it out. works well of course. and yes, just copy and paste that line and the program line with the accurate location and title is automatically added... amazing.]

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

#94 Post by MochiMoppel »

Puppus Dogfellow wrote:alt+space bar (/mnt and the rox bookmarks pull down itself) and F2 (disciple's script) both get me into already updated lists in their own ways so i saw no need to make this into a two step affair--it seemed to defeat the purpose somewhat
Not sure if I understand you correctly. It always is a two step affair. Running the update script is always a separate process which needs to be done before you can enjoy an up-to-date menu. I don't see which purpose is defeated. Unfortunately JWM's methods to show menus can't be combined with bash commands, so there is no way to update the menu on-the-fly - only one reason why I would never use any of above MochiMoppel scripts :oops:

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

#95 Post by Puppus Dogfellow »

MochiMoppel wrote:
Puppus Dogfellow wrote:alt+space bar (/mnt and the rox bookmarks pull down itself) and F2 (disciple's script) both get me into already updated lists in their own ways so i saw no need to make this into a two step affair--it seemed to defeat the purpose somewhat
Not sure if I understand you correctly. It always is a two step affair. Running the update script is always a separate process which needs to be done before you can enjoy an up-to-date menu. I don't see which purpose is defeated. Unfortunately JWM's methods to show menus can't be combined with bash commands, so there is no way to update the menu on-the-fly - only one reason why I would never use above MochiMoppel scripts :oops:

I meant to make a shortcut key to update the list is an extra step from an updated list for me because i already have a key that gives me an updated list; it's not using the JWM menu to do it, but it contains a pop up with the same bookmarks, so to have a key update when i could just press the key to get there would eventually--regardless of my enthusiasm for the way the menu has been improved--lead me to wonder why i didn't just click the button that took me to an updated list. if i didn't have keys set up to get me to the filer windows or the gtk box with the combined gtk and rox bookmarks, i would without hesitation make the update script a key. i'm backing off on the keys for a bit because i'm trying to think of a core ten or twenty i could consistently use on all my machines and maybe that had something to do with my response. trying to not have the keys step on the toes of existing or embedded shortcuts, and trying to figure out which i really need and sort out the relative ease of access and ergonomics based on some sort of "logical" hierarchy has apparently distracted me from just doling out shortcuts. at least for the time being.

just ran jwm -p and man are my menus messed up. :lol: i should've listened to you, Mochi. new installs will have less foolishness.

as far as i'm concerned, there's no reason in the world not to use your script. if jwm had come with it in the first place, there's no way i would have spent even a second trying to find out how to improve the menu-bookmark integration situation, though i'm glad to have what i've found and learned from the journey.

how would i go about changing the location of the "Refresh me!" in the menu itself? manually moving it about in the menu file didn't seem to do it and i'm hesitant to touch the script itself. (though the bottom is really only an arrow press from the top, it's a long list and i think i'd rather have it at the top position. top quarter, anyway.)

once again, thank you, MochiMoppel.

Post Reply