Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Sun 17 Nov 2019, 07:57
All times are UTC - 4
 Forum index » House Training » HOWTO ( Solutions )
How to show Recently Used Documents on JWM's Start Menu
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 2 of 3 [37 Posts]   Goto page: Previous 1, 2, 3 Next
Author Message
PeterRJG


Joined: 23 Feb 2013
Posts: 12
Location: Northern NSW, Australia

PostPosted: Tue 18 Oct 2016, 20:33    Post subject:  

Edit - I'll ask this in the right place.
Back to top
View user's profile Send private message Visit poster's website 
B.K. Johnson

Joined: 12 Oct 2009
Posts: 773

PostPosted: Mon 29 Jul 2019, 12:24    Post subject:  

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.

_________________
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

Back to top
View user's profile Send private message 
BarryK
Puppy Master


Joined: 09 May 2005
Posts: 9069
Location: Perth, Western Australia

PostPosted: Tue 30 Jul 2019, 05:16    Post subject:  

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.

_________________
http://bkhome.org/news/
Back to top
View user's profile Send private message Visit poster's website 
B.K. Johnson

Joined: 12 Oct 2009
Posts: 773

PostPosted: Tue 30 Jul 2019, 10:27    Post subject:  

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.

_________________
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

Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1925
Location: Japan

PostPosted: Wed 31 Jul 2019, 01:16    Post subject:  

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...
Back to top
View user's profile Send private message 
B.K. Johnson

Joined: 12 Oct 2009
Posts: 773

PostPosted: Wed 31 Jul 2019, 23:01    Post subject:  

MochiMoppel wrote:
Quote:
...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).

Misinterpretation Mochi. Yes, titles of some web pages may be long, but I wasn't suggesting that they would be so long as to be problematic. What would be a problem is the path to a 6/7/8 level directory plus the long web page title.

Quote:
So here your idea wouldn't help, right?

No, wrong!
Quote:
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

Here is a list of files with long titles I recently downloaded.
Backyard Woodfire Pizza Oven 10 Steps (with Pictures)-1.mp4
EaseUS-How to Create a Portable Windows 10_8_7 USB Drive.html
Is it Safe to Share My Internet Connection with My Neighbor_ - Ask Leo! (2019-07-31 10_52_13 PM).html
Is it Safe to Share My Internet Connection with My Neighbor_ - Ask Leo!.html

The first "Is it Safe ...", I renamed to the shorter title below it. It still is the longest at 74 characters. If you insist on a number, the old 80 col card length will suffice. Even such a length is unnecessary. The user has a good idea what he/she is looking for and should recognize it in 40 characters, I would think. The ideal would be:
Code:
if file_length < 40, display all.
else make name consisting of a substring of the first 40 chars +"..."+ extension.

Quote:
and should full path names be shown if they fit within the limit?

No! Why complicate matters. Why mix apples and oranges (paths and filenames)? But if you really want work, make the path to the directory a tooltip. Idea
Quote:
Lots of questions remain...

I don't think so. Unless you have more to pose. Wink

_________________
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

Back to top
View user's profile Send private message 
B.K. Johnson

Joined: 12 Oct 2009
Posts: 773

PostPosted: Wed 31 Jul 2019, 23:27    Post subject:  

Duplicate deleted
_________________
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

Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1925
Location: Japan

PostPosted: Thu 01 Aug 2019, 08:27    Post subject:  

This is a slightly improved (?) version of my initial script. It will display only existing files and only the basenames, not the full paths. While this keeps the menu items short it can pose problems after opening/editing files with same name from different directories. This will result in a menu with multiple identical labels ... not good! The script tries to solve this problem by adding tooltips, containing the full paths. JWM allegedly supports tooltips since version 2.3.3.
I tested with 2.3.7., but I see no tooltips. Does anybody have an idea how to make them work?

Code:
#!/bin/bash
XBEL_PATH=$HOME/.local/share/recently-used.xbel
if [[ -e $XBEL_PATH ]];then
    MAX_ITEMS=20
    IFS=$'\n'
    ITEMS=$(awk -F'"' '/file:\/\//  { sub("file://","",$2); print $2}' $XBEL_PATH)
    printf -v ITEMS "${ITEMS//%/\\x}"               #convert UTF-8
    ITEMS=$(find $ITEMS   | tail -n $MAX_ITEMS)     #remove non-existent files, cut list off at MAX_ITEMS
    ITEMS=$(echo "$ITEMS" | sed  -r 's_(.*/)(.*)_<Program label="\2" tooltip="\1\2">rox -s "\1\2"</Program>_')
else
    ITEMS="<Program label=\"File ${XBEL_PATH##*/} not found!\"></Program>"
fi
echo  "<JWM>
$ITEMS
</JWM>"


Some technical notes: According to the freedesktop specification the location of the xbel file should be $XDG_USER_DATA/recently-used.xbel, however at least in my system the $XDG_USER_DATA variable is not defined. The spec also sheds a little light on the confusing fact that recently-used.xbel does not contain data according to the Recent File Storage Specification, instead apparently uses this spec.

[EDIT] Changed code. Made more consistent with initial demo. Tested with JWM version vgit-1553. Still no tooltips.
Back to top
View user's profile Send private message 
BarryK
Puppy Master


Joined: 09 May 2005
Posts: 9069
Location: Perth, Western Australia

PostPosted: Sat 03 Aug 2019, 07:34    Post subject:  

This will display only existing files, including if have space characters, and will truncate lines exceeding 70 characters (actually, 70 bytes) by pre-pending "...":

Code:
#!/bin/sh
echo  "<JWM>"
while read aFILE
do
 if [ -e "$aFILE" ];then
  if [ ${#aFILE} -gt 70 ];then
   echo "<Program label=\"...${aFILE:(-70):70}\">rox -s \"${aFILE}\"</Program>"
  else
   echo "<Program label=\"${aFILE}\">rox -s \"${aFILE}\"</Program>"
  fi
 fi
done <<EOF
$(tac ~/.local/share/recently-used.xbel | grep -m 20 -o '"file://[^"]*' | cut -c 9-)
EOF
echo  "</JWM>"


However, I won't use it, as the is a very noticeable delay when click the Menu button, before the menu pops up.

_________________
http://bkhome.org/news/

Last edited by BarryK on Sat 03 Aug 2019, 11:06; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1925
Location: Japan

PostPosted: Sat 03 Aug 2019, 08:35    Post subject:  

BarryK wrote:
This will display only existing files, including if have space characters
Are you sure? recently-used.xbel uses UTF-8 encoding, e.g. %20 for space characters. In order to display spaces or accented characters or Japanese kanji you first must convert them

Quote:
, and will truncate lines exceeding 90 characters (actually, 90 bytes) by pre-pending "...":
no, not bytes, it's really characters

Quote:
However, I won't use it, as the is a very noticeable delay when click the Menu button, before the menu pops up.
Hmm, not here. Menu pops up without any noticeable delay, but this may well depend on the size of recently-used.xbel . Mine is relatively small but if your's is huge then I can imagine that it becomes unusable.
Back to top
View user's profile Send private message 
BarryK
Puppy Master


Joined: 09 May 2005
Posts: 9069
Location: Perth, Western Australia

PostPosted: Sat 03 Aug 2019, 11:03    Post subject:  

MochiMoppel wrote:
BarryK wrote:
This will display only existing files, including if have space characters
Are you sure? recently-used.xbel uses UTF-8 encoding, e.g. %20 for space characters. In order to display spaces or accented characters or Japanese kanji you first must convert them

Quote:
, and will truncate lines exceeding 90 characters (actually, 90 bytes) by pre-pending "...":
no, not bytes, it's really characters

Quote:
However, I won't use it, as the is a very noticeable delay when click the Menu button, before the menu pops up.
Hmm, not here. Menu pops up without any noticeable delay, but this may well depend on the size of recently-used.xbel . Mine is relatively small but if your's is huge then I can imagine that it becomes unusable.


I did test with a text file that had spaces, it was stored in recently-used.xbel as-is, with the space characters.

I thought that I read that online somewhere, that ${VAR:(-70):70} is offsets in bytes, not characters. OK, good if it is characters.

I'm running a different computer right now, so don't know how big that recently-used.xbel was. Is there any way to limit it's size? If so, that would solve my problem. I suppose there must be a size limit, it surely can't just keep growing.

_________________
http://bkhome.org/news/
Back to top
View user's profile Send private message Visit poster's website 
disciple

Joined: 20 May 2006
Posts: 6988
Location: Auckland, New Zealand

PostPosted: Sat 03 Aug 2019, 17:54    Post subject:    

Hi Barry, if menu delay is a problem, why not just include a separate utility like mochimoppel's speed dials, which also gives access to bookmarks?
Although maybe a faster implementation is possible - lxpanelx had a feature for this and I thought it didn't have a big delay.

_________________
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1925
Location: Japan

PostPosted: Sun 04 Aug 2019, 08:58    Post subject:  

BarryK wrote:
I did test with a text file that had spaces, it was stored in recently-used.xbel as-is, with the space characters.

Shocked How did you do this? This is hard to believe. I've never experienced this in any distro. Typical content would look like this:
    <?xml version="1.0" encoding="UTF-8"?>
    <xbel version="1.0"
    xmlns:bookmark="http://www.freedesktop.org/standards/desktop-bookmarks"
    xmlns:mime="http://www.freedesktop.org/standards/shared-mime-info"
    >
    <bookmark href="file:///abc/d/Spaced
    %20filename.txt" added="2019-08-04T11:43:23Z" modified="2019-08-04T11:43:23Z" visited="2019-08-04T11:43:23Z">
    <info>
    <metadata owner="http://freedesktop.org">
    <mime:mime-type type="text/plain"/>
    <bookmark:applications>
    <bookmark:application name="Leafpad" exec="&apos;leafpad %u&apos;" modified="2019-08-04T14:23:27Z" count="1"/>
    </bookmark:applications>
    </metadata>
    </info>
    </bookmark>
    </xbel>
Likewise a file /mnt/home/Málaga.txt would be coded as href="file:///mnt/home/M%C3%A1laga.txt". Will not appear in menu unless decoded.

Quote:
Is there any way to limit it's size? If so, that would solve my problem. I suppose there must be a size limit, it surely can't just keep growing.

Answered here. You can't really limit the size, but you can limit the lifetime of items. They will get deleted from the file when they are older than the threshold.

But frankly I don't believe that size is the cause of your delay. I tested with 1000+ items, which increased filesize to 500K, and still no delay. Your code is extremely fast (0.04sec) - because you are cutting corners Wink . Your code greps the last 20 items and stops scanning the file once it has found those 20 items, so it is irrelevant how big the rest of the file is. You then process only these 20 items and check if they still exist. Not quite correct since after the existence check only some or none might make it into the menu. IMO you need to select the last 20 existing files. Compared with your's my code took 0.2sec, still not annoying.
Back to top
View user's profile Send private message 
BarryK
Puppy Master


Joined: 09 May 2005
Posts: 9069
Location: Perth, Western Australia

PostPosted: Mon 05 Aug 2019, 03:14    Post subject:  

MochiMoppel wrote:
BarryK wrote:
I did test with a text file that had spaces, it was stored in recently-used.xbel as-is, with the space characters.

Shocked How did you do this? This is hard to believe. I've never experienced this in any distro.


Yes, my bad. Just tested again, and the file with spaces is now stored with "%20".

Hmmm, don't know how I got the idea it was otherwise.

_________________
http://bkhome.org/news/
Back to top
View user's profile Send private message Visit poster's website 
radky

Joined: 02 May 2010
Posts: 980

PostPosted: Sat 17 Aug 2019, 02:16    Post subject:  

Another iteration of the 'Recently Used' script for JWM.

Code:
#!/bin/bash
#this script is started from $HOME/.jwmrc

XBEL_PATH=$HOME/.local/share/recently-used.xbel
PARSED_ITEMS=40
MAX_ITEMS=20

if [[ -e $XBEL_PATH ]];then
   LANG=C
   ITEMS=$(grep -a file:/// "$XBEL_PATH" | tail -n $PARSED_ITEMS | cut -d '"' -f2 | sed 's%file://%%g')
   printf -v ITEMS "${ITEMS//%/\\x}" #convert UTF-8
   echo -n > /tmp/jwmdocs
   for i in $ITEMS
     do
       [ -f ${i} ] && echo -e "<Program label=\"• ${i}\">xdg-open \"${i}\"</Program>" >> /tmp/jwmdocs
     done
   ITEMS=$(tail -n $MAX_ITEMS /tmp/jwmdocs)
else
   ITEMS="<Program label=\"${XBEL_PATH##*/} not found!\"></Program>"
fi
echo '<JWM>'
echo -e "${ITEMS}"
echo '</JWM>'


EDIT 19 Aug 2019: add line #11 for UTF-8 conversion (thanks MochiMoppel)

_________________
PupMates
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 2 of 3 [37 Posts]   Goto page: Previous 1, 2, 3 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » House Training » HOWTO ( Solutions )
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0714s ][ Queries: 12 (0.0091s) ][ GZIP on ]