Recent Files non-Latin wrong symbols

  • This topic has 29 replies, 5 voices, and was last updated Feb 7-4:22 pm by uxer.
Viewing 15 posts - 1 through 15 (of 30 total)
  • Author
    Posts
  • #38976
    Member
    uxer

    they are originally Cyrillic on the screenshot

    Bonus question: can I have
    icewm menu -> Recent Files -> Recent Files List
    display more than 10 in the 1’st level outright, without resorting to Next 10

    • This topic was modified 11 months, 1 week ago by uxer.
    • This topic was modified 11 months, 1 week ago by uxer.
    #38980
    Member
    PPC
    Helpful
    Up
    0
    :D

    Crap… Hang on a bit, until BobC takes a crack at your problem.

    Until then, if you want to try a workaround, please give this script a shot and tell us if the files are correctly listed… It can be pasted directly into the terminal.
    Always use caution: Do not run random scripts if you are not sure of what they do!!!

    #!/bin/bash
    ### Recent files window- by PPC, 13/1/2020, for use with antiX and MX-fluxbox
    #GPL licence- do what you want with this, but please keep lines about the author, date and licence
    # works on any system with yad and xdg-open installed, optionally: exo-open (see exceptions to the general rule, when launching files, near the end.
    # https://pastebin.com/fSDPR9E1
    #Parse the file that stores the recent used files, send output to recent0.txt
    awk -F"file://|\" " '/file:\/\// {print $2}' ~/.local/share/recently-used.xbel > ~/.recent0.txt
    #reverse contents order, so last file comes first, and so on...
    tac ~/.recent0.txt > ~/.recent.txt
    #function to decode file name (from %20 instead of spaces, etc, from https://unix.stackexchange.com/questions/159253/decoding-url-encoding-percent-encoding
    urldecode() {
        local url_encoded="${1//+/ }"
        printf '%b' "${url_encoded//%/\\x}"
    }
    # Use a undecorated Yad window to select file to be executed
    EXEC=$(yad --title="Recent files" --undecorated --width=450 --height=400 --center --separator=" " --list  --column=" Recent Files:"  < ~/.recent.txt)
    #do decoding on the file name, just in case it has spaces or special characters that come up as %xx
    decoded=$(urldecode $EXEC)
    # general rule: open selected file with the aplication used for its file type
    openwith=xdg-open 
    ###Exceptions to the general rule: LibreOffice Writer ".odt" files - check extension and  force it to open with lowriter; also more exceptions: like open ".sh" files for edition and run ".desktop" files instead of editing them
    check=$(echo -n $EXEC | tail -c 3)
    	if [ "$check" == "odt" ]; then openwith=lowriter ; fi  #this solves bug opening odt files with spaces
    	if [ "$check" == ".sh" ]; then openwith=exo-open ; fi
    	if [ "$check" == "top" ]; then openwith=exo-open ; fi
    #add quotes to the file name, just in case it has spaces
    EXEC2="'"$decoded"'"
    #launch the selected file
    run=$(echo $openwith $EXEC2)
    eval $run
    #39014
    Member
    uxer
    Helpful
    Up
    0
    :D

    give this script a shot and tell us if the files are correctly listed… It can be pasted directly into the terminal.
    Always use caution: Do not run random scripts if you are not sure of what they do!!!

    Not solved.
    But it seems to run till line 16
    EXEC=$(yad --title="Recent files" --undecorated --width=450 --height=400 --center --separator=" " --list --column=" Recent Files:" < ~/.recent.txt)
    and not processing the rest. I am not a bash scripter, though

    • This reply was modified 11 months, 1 week ago by uxer.
    #39023
    Member
    PPC
    Helpful
    Up
    0
    :D

    I took a look at problems bash has with cyrillic characters. This seems quite common (I found this 2 links: https://unix.stackexchange.com/questions/504800/ls-wont-display-cyrillic-characters-properly and https://superuser.com/questions/1479542/cyrillic-symbols-in-linux-file-names )
    If you use the terminal to list files that have cyillic charaters do they display correctly? Examples: Launch SpaceFm > go to folder with the files > f4 > type “ls” without the quotes.
    If “ls” does not display the file names correctly and you feel a bit confortable with the using the temrinal, try the commands from the webpage if that fixes it, I can at least try to addapt my script (by the way the script stops on that line because it’s just waiting for you to select a file-If you just copied and pasted the script to the terminal, probably it woun’t launch anything. I just wanted to check if it displayed the file names correctly. If you want to really use the script, save it with a “.sh” extension, make it executable and then run it (I wrote it because Fluxbox desktop does not allow for the recent files menu).

    P.

    #39028
    Member
    uxer
    Helpful
    Up
    0
    :D

    Cyrillic characters in terminal are OK most of the time, but not always (tmux status bar does not display Cyrillic in my experience, midnight commander – sometimes yes sometimes no).
    Moreover, icewm menu is GUI, not terminal…

    • This reply was modified 11 months, 1 week ago by uxer.
    #39051
    Member
    PPC
    Helpful
    Up
    0
    :D

    Moreover, icewm menu is GUI, not terminal…

    Yes, but the menu is based on a bash script… I did help Bob a little bit with it- initially we had problems processing characters. None of us thought about cyrilic… sorry…

    P

    #51275
    Member
    uxer
    Helpful
    Up
    0
    :D

    Contribution proposal of a better Recent Files

    Continued in the next post in the thread.

    Screenshots:

    #51278
    Member
    uxer
    Helpful
    Up
    0
    :D

    Preamble.
    I had had aforementioned problem with encoding,
    then it long had not been solved by antiX-devs,
    then I stumbled upon the solution and thought that it would be easy for me to fix the problem.
    I started. Then it turned out that pressing Cancel in antiX’ “Change number of files to show” truncates configfile, and Recent Files List goes zero. I thought that I would fix it as well.
    Bit by bit, the thing has grown to what it is now.
    I have done it as my shell learning exercise.
    It is not finished, with loose ends, yet its main functionality seems to work as intended on my antiX and with my filelist.

    Now, since:
    1. Shell proved unappealing to me for scripting purpose;
    2. Writing and esp. debugging takes up time;
    3. I am not sure whether this my work will be useful,
    I would abandon this effort.
    I ask here antiX’ devs and user community whether you find this work worthy and suitable for inclusion into antiX and whether you want me to work on it further to a releasable state.

    What is attached:
    icewm-menu-recentfiles-plus.tar.gz containing:

    The 3 files are the thing itself:
    icewm-menu-recentfiles-plus.sh
    icewm-menu-recentfiles-plus-configure.sh
    icewm-menu-recentfiles-plus.rc.toml

    The 4’th file:
    install-uninstall-icewm-menu-recentfiles-plus.sh

    is for easier installing and uninstalling.
    It installs 2 bundled .sh scripts to /usr/local/bin/ and .rc.toml configfile to $XDG_CONFIG_HOME which is generally your ~/.config/ ; it will backup your ~/.icewm/menu to ~/.icewm/menu.backup-by-icewm-menu-recentfiles-plus and try to edit ~/.icewm/menu so that your IceWM menu Recent Files submenu is provided by newly installed scripts.
    On uninstallation, 2 .sh scripts from /usr/local/bin/ and .rc.toml configfile from $XDG_CONFIG_HOME will be deleted, and your previous backed up ~/.icewm/menu.backup-by-icewm-menu-recentfiles-plus will be restored to ~/.icewm/menu.

    Installation
    1. download the attached (see at the bottom of this post) icewm-menu-recentfiles-plus.tar.gz
    2. untar
    3. make sure the install-uninstall-icewm-menu-recentfiles-plus.sh is granted execution permission (it should retain them by default)
    4. run the install-uninstall-icewm-menu-recentfiles-plus.sh from the terminal like this:
    ./install-uninstall-icewm-menu-recentfiles-plus.sh
    5. press ↵ (Enter)
    6. input your sudo password.

    Uninstallation
    1. run the install-uninstall-icewm-menu-recentfiles-plus.sh from the terminal like this:
    ./install-uninstall-icewm-menu-recentfiles-plus.sh
    2. press ↵ (Enter)
    3. input your sudo password.

    Disclaimer:
    This proposal scripts are distributed in the hope that they will be useful,
    but without any express or implied warranty.

    User, beware of untrusted executables!
    It is risky to install and launch unverified executables.
    If it urges you to install and launch them, you should do it in a virtual machine, container or firejail.

    #51295
    Member
    skidoo
    Helpful
    Up
    0
    :D

    wow (i mean WOW!) what an elegant set of scripts!
    beautiful coding style; amazing attention to detail.

    Tested on antiX19, installs and works as described.

    uxer, I had (prior to testing) intended to ask whether you are aware of the similar effort toward injecting recentlyused into fluxbox menu:
    http://forum.mxlinux.org/viewtopic.php?f=143&t=60813&p=620739&hilit=recent

    …but your solution could surely be adapted (separate scripts, not one, conditional-laden, behemoth script) to inject the menus of window managers other than icewm.

    Others can comment on the desirability of including (or not) a recently-used menu addition. I don’t fit the intended audience.

    I do worry that such a feature will (does, immedietely evident) cause the desktop menu to “lag”. With each visit to the menu, there’s a noticeable delay (not specific to your script) before it will display the dynamically-generated content.

    In the linked MX forum discussion, Girafenaine opined:
    “I do prefer a submenu integrated in [..] menu. I don’t want to have a gtk window popping up.”
    .
    Well, I’m on the other side of the fence. IMO, re-re-re-visiting the menu if wanting to peek multiple recent files would be a nuisance… so, yes, would prefer to interact with a gui “peek” utility which remains running “until I say so”.

    Specific to your attached script, here’s a point of usability feedback:
    User wonders, upon seeing the (?) suffix applied to many, but not all, items… does this indicate a given file may no longer exist, or does the menumaker check each file listed in recentlyused and the questionmark indicates, definitively, “I found this file in the list, but it does not currently exist (may have been renamed/moved).” ?

    Regarding the prospect of fostering facilitating user reliance on recently-used, in general, on an antiX system:

    several of the pre-installed applications do not consult, do not write to, recently-used.xbel

    additionally, many programs which are likely to be added to a system (aka recommended, or popular) do not consult recently-used.xbel

    the system doesn’t provide a pre-installed “trash” folder, but some users will add such… and some programs (e.g. meld?) will autocreate a trash folder if none exists… AND the created “trash” location is not universal (trash vs uppercase TRASH vs trash-1001)

    Even if a “solution” hopes to go the extra kilomile, by sniffing the contents of, for instance “geany’s private list of last-session-used, this-session-used files”…

    we still wind up with the likelihood that a given user, during a given interaction, will wish to specify the opener (aka handler) for “this item, this time”. The menu-based solution probably cannot provide such flexibility (right-clicking an item would expose an action menu, offering an action labeled “Choose” or “OpenWith”). Possibly (I haven’t tested) in certain scenarios, the user could drag the {icewm} menu entry, dropping it on the desktop-resident icon for the desired handler/opener program…

    #51318
    Member
    uxer
    Helpful
    Up
    0
    :D

    Thank you, skidoo, your response is inspiring.
    But don’t pay tribute to me alone — my work is done on top of what was and is already in antiX.

    No, I was not aware of http://forum.mxlinux.org/viewtopic.php?f=143&t=60813&p=620739&hilit=recent
    It is perhaps a right idea to have a unified solution for various window managers.
    But if fluxbox folks want it today or tomorrow, then I am out. If they want me in, I haven’t the faintest idea on when.

    cause the desktop menu to “lag”

    The lag is definitely there and causes poorer user experience. I see 2 solutions:
    run antiX on a quantum computer, which they say is capable of instant answers;
    or a feasible solution — daemonize Recent Files script, so that it constantly watches $XDG_DATA_HOME/recently-used.xbel for modifications, incrementally pre-processes Recent Files menu contents, so that only “does the file exist” is left to be checked upon demand. Or even make that daemon monitor presence of recent files, so that the menu could just read the list without any processing. Will monitoring of dozens of files affect performance?
    But devs maintain “no bloat” position, even when a critical/integral/as-a-matter-of-course functionality gets missed (a power management daemon is absent in antiX (arrgh!), trash is absent (arrgh!), DNS is plain-text instead of DoT/DoH/DoQ (arrgh!); but I diverge), will devs give their consent for another daemon?

    upon seeing the (?) suffix applied to many, but not all, items… does this indicate a given file may no longer exist, or does the menumaker check each file listed in recentlyused and the questionmark indicates, definitively, “I found this file in the list, but it does not currently exist (may have been renamed/moved).” ?

    I don’t catch what is the difference between “may no longer exist” and “does not currently exist”?
    Anyway, marking of not found items is subject to discussion.
    I personally prefer such entries being dimmed/faded/grayed with an explanatory tooltip, but IceWM will not allow for.

    Regarding the prospect of fostering facilitating user reliance on recently-used, in general, on an antiX system:
    several of the pre-installed applications do not consult, do not write to, recently-used.xbel
    additionally, many programs which are likely to be added to a system (aka recommended, or popular) do not consult recently-used.xbel
    the system doesn’t provide a pre-installed “trash” folder, but some users will add such… and some programs (e.g. meld?) will autocreate a trash folder if none exists… AND the created “trash” location is not universal (trash vs uppercase TRASH vs trash-1001)

    Even if a “solution” hopes to go the extra kilomile, by sniffing the contents of, for instance “geany’s private list of last-session-used, this-session-used files”…

    You have hit the right questions. The task is bottomless — it is hard to take into account all the quirks,
    and it is hard to deal with quirks in the shell language. The task is a hellhole.

    Even if a “solution” hopes to go the extra kilomile, by sniffing the contents of, for instance “geany’s private list of last-session-used, this-session-used files”…

    we still wind up with the likelihood that a given user, during a given interaction, will wish to specify the opener (aka handler) for “this item, this time”. The menu-based solution probably cannot provide such flexibility (right-clicking an item would expose an action menu, offering an action labeled “Choose” or “OpenWith”). Possibly (I haven’t tested) in certain scenarios, the user could drag the {icewm} menu entry, dropping it on the desktop-resident icon for the desired handler/opener program…

    IceWM and counterparts are rather bare-bones and “wooden” in terms of modern desktop usability. There is no remedy, except wait for (or make) some IceWM-ng (= next generation).

    Additional options like “open with” could be added by means of IceWM menu’s items that are both clickable and submenu-containing as Logout and some Theme sub-items are (see screenshot below). Manpages are silent on it. Somebody, reveal the recipe!

    #51333
    Moderator
    Brian Masinick
    Helpful
    Up
    0
    :D

    @uxer: I downloaded your script and tried it out. I was able to see the modifications.

    I encourage more dialogue; this is useful, at least to me.

    Brian Masinick

    #51338
    Member
    uxer
    Helpful
    Up
    0
    :D

    I am here for the dialogue

    #51340
    Moderator
    Brian Masinick
    Helpful
    Up
    0
    :D

    I don’t have any good revelation to offer.

    My initial thought is that the code you created is straightforward and useful as is.

    If I were creating similar tools I would probably write a relatively small script for one or two specific capabilities.

    If I later wanted to add some other features I would probably write another script, copying any common logic.

    If, over time I found a lot of common logic, it may cause me to write some common routines to share. Moreover if a script becomes large, I would weigh the benefits and costs of a program or a script.

    This tool, in my view is useful as a script. Also it’s worthwhile to make it possible to have a library of script programs, just in case you ever want to reuse code.

    These are just a few thoughts, but I wouldn’t change anything unless you want it to scale into other efforts.

    Brian Masinick

    #51342
    Member
    skidoo
    Helpful
    Up
    0
    :D

    daemonize Recent Files script

    sudo apt install inotify-tools

    surveillance, toward noting which events are emitted as {Save,SaveAs} events are performed by various editors, and how unreliable // inconsistent are the changes effected upon recently-used.xbel by various programs:

    inotifywait -m $HOME/.local/share/recently-used.xbel

    geany (SaveAs)
    ^—v
    /home/demo/.local/share/recently-used.xbel ATTRIB
    /home/demo/.local/share/recently-used.xbel DELETE_SELF

    leafpad (SaveAs)
    ^—v
    /home/demo/.local/share/recently-used.xbel OPEN
    /home/demo/.local/share/recently-used.xbel ACCESS
    /home/demo/.local/share/recently-used.xbel CLOSE_NOWRITE,CLOSE
    /home/demo/.local/share/recently-used.xbel ATTRIB
    /home/demo/.local/share/recently-used.xbel DELETE_SELF

    pluma (SaveAs)
    ^—v
    ————— NONE ————-

    meld (EMITTED UPON LOADING A FILE)
    ^—v
    /home/demo/.local/share/recently-used.xbel OPEN
    /home/demo/.local/share/recently-used.xbel ACCESS
    /home/demo/.local/share/recently-used.xbel CLOSE_NOWRITE,CLOSE

    meld (EMITTED UPON LOADING 2 FILES FOR SIDE-BY-SIDE INSPECTION)
    ^—v
    /home/demo/.local/share/recently-used.xbel OPEN
    /home/demo/.local/share/recently-used.xbel ACCESS
    /home/demo/.local/share/recently-used.xbel CLOSE_NOWRITE,CLOSE
    /home/demo/.local/share/recently-used.xbel ATTRIB
    /home/demo/.local/share/recently-used.xbel DELETE_SELF

    meld (NONE EMITTED UPON EDITING, THEN SAVING THE 2 FILES)
    ^—v
    ————- none ————
    (EXIT meld AFTERWARD, STILL NOTHING EMITTED)

    ___________________________
    ___________________________
    ___________________________

    inotifywait -m $HOME/.local/share/recently-used.xbel | \
    while read file;do yad –text=”oOo” && sleep 10; done

    The sleep was intended as a debounce, in case multiple, back-to-back events are emitted.
    No joy ~~ swap mymenucontentgenerator.sh in place of yad and we would wind launching multiple racy instances of the generator script.

    #51343
    Moderator
    Brian Masinick
    Helpful
    Up
    0
    :D

    Your suggestion is much more specific than mine Skidoo. Thanks for your excellent help with this and many other efforts.

    Brian Masinick

Viewing 15 posts - 1 through 15 (of 30 total)
  • You must be logged in to reply to this topic.