An idea… IceWM Dynamic Desktop Menu

Forum Forums New users New Users and General Questions An idea… IceWM Dynamic Desktop Menu

  • This topic has 99 replies, 7 voices, and was last updated Oct 13-5:02 am by BobC.
Viewing 15 posts - 46 through 60 (of 100 total)
  • Author
  • #27077

    Yes, omits from the menu filenames with spaces in them. I’ll have to look again more closely. If at first you don’t succeed, try, try again…

    Thanks for including


    In the repos, anti. Let me know if there is any feedback on them.


    Still having trouble… Not sure if this will post correctly. I got the file to open string, but not allowed to print it with a printf statement from the script appears to be the problem

    $ tail -n 350 ~/.local/share/recently-used.xbel | grep "<bookmark href=" | sed 's/.*href=//g' | sed 's/ .*//' | tac

    Here is the program using that to feed it

    ### - dynamic menu of recent files to open via xdg-open
    ### BobC 09/04/19
    ### --- example output ---
    export TERMCMD='desktop-defaults-run -t'
    while read recentfile
        if [ -d "$recentfile" ]; then
            printf "prog \"  ${basename} - xdg-open $recentfile\n"
            ### if .desktop need to figure out what to run, otherwise use xdg-open
            if [[ "$entry_fileext" != "desktop" ]]; then
                printf "prog \"  ${basename} - xdg-open $recentfile\n"
                ### this entry is a .desktop, so get execution string, and whether to run in terminal or not
                entry_exec=$( grep '^Exec' $recentfile | tail -1 | sed 's/^Exec=//' | sed 's/%.//' )
                if grep -q '^Terminal=true' $recentfile; then
                    ### use terminal to execute
                    entry_exec="$TERMCMD $entry_exec"
                    # printf "Terminal based Entry_exec: ${entry_exec}\n"
                printf "prog \"  ${basename} - $entry_exec\n"
    done < <(tail -n 350 ~/.local/share/recently-used.xbel | grep "<bookmark href=" | sed 's/.*href=//g' | sed 's/ .*//' | tac)

    But look at the errors in the output when it hits the ones with spaces

    $ ./ 
    prog "" - xdg-open "file:///home/bobc/icewm-menu-3/"
    prog "  1440x900-Screen" - xdg-open "file:///home/bobc/Desktop/ScreenLayout/1440x900-Screen"
    ./ line 17: printf: 

    m’: invalid format character
    prog ” test 0x0p+0 it./ line 17: printf: `m’: invalid format character
    prog ” test 0x0p+0 it./ line 17: printf: `m’: invalid format character
    prog ” test 0x0p+0 itprog ” screenshot-for-moddit.jpg” – xdg-open “file:///home/bobc/screenshot-for-moddit.jpg”
    prog ” screenshot-for-rej-after-change.jpg” – xdg-open “file:///home/bobc/screenshot-for-rej-after-change.jpg”
    ./ line 17: printf: `r’: invalid format character
    prog ” screenshot 0.000000orprog ”” – xdg-open “file:///home/bobc/”
    prog ” antix19b3withrecentfiles.jpg” – xdg-open “file:///home/bobc/antix19b3withrecentfiles.jpg”
    prog ”” – xdg-open “file:///home/bobc/icewm-menu/icewm-menu/”
    prog ” menu” – xdg-open “file:///home/bobc/icewm-menu-2/menu”
    prog ”” – xdg-open “file:///home/bobc/icewm-menu-2/”
    prog ”” – xdg-open “file:///home/bobc/icewm-menu-2/”
    prog ”” – xdg-open “file:///home/bobc/icewm-menu-2/”
    prog ”” – xdg-open “file:///home/bobc/icewm-menu-2/”
    prog ”” – xdg-open “file:///home/bobc/”
    prog ”” – xdg-open “file:///home/bobc/icewm-menu/”
    prog ”” – xdg-open “file:///home/bobc/icewm-menu/”
    prog ” menu” – xdg-open “file:///home/bobc/icewm-menu/icewm-menu/menu”
    prog ” menu-mod” – xdg-open “file:///home/bobc/icewm-menu/menu-mod”
    prog ” debian-live-10.1.0-amd64-xfce.iso” – xdg-open “file:///home/bobc/Downloads/debian-live-10.1.0-amd64-xfce.iso”
    prog ” index.theme” – xdg-open “file:///usr/share/icons/default/index.theme”
    prog ”” – xdg-open “file:///home/bobc/icewm-menu/”
    prog ” menu-save-20190817″ – xdg-open “file:///home/bobc/.icewm/menu-save-20190817″
    prog ” menu-bobc” – xdg-open “file:///home/bobc/.icewm/menu-bobc”
    prog ” menu.dpkg-old” – xdg-open “file:///home/bobc/.icewm/menu.dpkg-old”
    prog ” menu” – xdg-open “file:///home/bobc/icewm-menu/menu”

    • This reply was modified 8 months, 2 weeks ago by BobC.
    • This reply was modified 8 months, 2 weeks ago by BobC.

    Still having trouble…

    Maybe this can help you, Bob:
    if I add ‘%s\n’ right after printf and then the rest of the command- even files with long names show up! But, clicking the files on the recent menu then does not make them run…

    This idea comes from my googling skills, that lead me to this page:

    Hope this helped you a bit…



    That was a good clue. Some more tries eventually yielded improved results.

    I don’t understand why this doesn’t work. It looks to me like the if statement isn’t working

    • This reply was modified 8 months, 2 weeks ago by BobC. Reason: removed code, it didnt work anyway

    The REAL problem is that I don’t know the darned correct syntax to do what I’m trying to do. It is all scrambled in my brain from so many different systems having different script syntax. Every little nuance is potential for trouble. So many troubles the cumulative permutations of all of them. So if I literally can’t COPY working code from someplace it becomes a big experiment…

    • This reply was modified 8 months, 2 weeks ago by BobC.

    I thought I had found a solution, but the code provided still didn’t work, and I don’t know why. I think I have wasted way too much time on filenames with spaces, and should just test for them and IGNORE them. None of the code I have found on the web has worked. Here is the final attempt. I’m completely frustrated at this point after spending many hours trying. Not sure what i’ll do with it from here. Normally I NEVER give up, but maybe its time. I left my debugs in in case it might help. The icons issue remains as well. I never did find a good way to find the icon quickly.

    • This reply was modified 8 months, 2 weeks ago by BobC. Reason: removed the code, it didnt work anyway

    Ok, its fixed. It can’t handle filenames with spaces in them, but seems to be doing well otherwise. Any ideas on the quick icon finding would be appreciated… For not, I just am not putting icons on the entries and its very fast on old machines that way, but not as pretty.

    Let me know if anyone finds problems or has ideas…


    It can’t handle filenames with spaces in them

    Hi Bob… I think I fixed that “spaces” in file name problem…
    just edit the recent script’s “localfile” variable to look like this:

    localfile=$( echo ${recentfile} | sed 's/file:\/\///g' | sed 's/\"//g' |sed 's/%20/ /g')

    the script now shows and runs, file names with spaces!!!

    I tested the solution using this simple script:

    echo $string
    string2=$( echo $string|sed ‘s/%20/ /g’ )
    echo $string2`

    We need to know the codes that sed as to convert to characters- example: “%20%E2%80%93%20” is “-”
    the codes, needed to do the conversion are here:

    we can use the “sed” command like this:
    sed 's/%20/ /g'|sed 's/%E2%80%93/ -/g'|sed 's/%E2%80%A6/ .../g'
    and so on… (this last example did not produce a file that the system could run…)

    “Any ideas on the quick icon finding would be appreciated”

    -First: the script seems fine as is (dispite the problem with some characters that still remains), with one exception- I remove the “Open” that starts each line…
    But if the “missing” icons are really bugging you, you can check the icewm-toolbar-icon-manager script (the “add icon” final part) – that is if the files on the menu are .desktop.
    As for all other files, I don’t know how file managers get the icons corresponding to each extension type (ex: jpg, txt, etc) . Probably they use the icon that corresponds to the program associated to that particular file type…
    You could do it manually- if the file extension is “jpg, png, bmp, etc- use a generic image icon, and so on, but that would be hard work and the results would not be optimal
    One particular icon that’s really easy to do is for .sh files- I would just use a gears icon…

    Curious, I used my google-fu in a quick search: “file extension icons linux” that took me to
    Run “sudo -H geany /etc/mime.types” to check all file types… and “/usr/share/icons/[iconThemeName]/mimetypes”- in antiX case, something like:


    Using the info from both these files- parse the dynamic menu entry go get the file extension, then parse “mime.types” to get the category of the file type and finally look for that category icon’s on the icons folder…
    Like I said… too much hard work for “eye candy”???



    I tested, and your solution for the filename seems to work, so I built that in.

    I added the word “Open” or “Run” as part of the display test so you would know if it is going to try to open a document, file or URL, or whether it was going to Run a desktop entry’s exec command.

    I don’t know the criteria for when IceWM will find the icon or not, but I think if it dooesn’t find it, it won’t display the menu line.

    Lunchtime is over, LOL


    I found a way to get a filename and mimetype, but how can I translate the mimetype into what icon filename to display, quickly?

    tail -n 326 ~/.local/share/recently-used.xbel | grep -e "<bookmark href=" -e "<mime:mime-type type=" | sed 's/\<bookmark href\=//g' | sed 's/mime\:mime\-type type\=//g' | sed 's/\" .*/\"/' | sed 's/<//g' | sed 's/\/>//g' | sed 'N;s/\n/ /g' | sed 's/ */ /g' | tac

    `”file:///home/bobc/.icewm/menu-bobc” “application/octet-stream”
    “file:///home/bobc/.icewm/menu-save-20190817” “application/octet-stream”
    “file:///home/bobc/icewm-menu/” “application/x-shellscript”
    “file:///usr/share/icons/default/index.theme” “text/plain”
    “file:///home/bobc/Downloads/debian-live-10.1.0-amd64-xfce.iso” “application/x-cd-image”
    “file:///home/bobc/icewm-menu/menu-mod” “text/plain”
    “file:///home/bobc/icewm-menu/icewm-menu/menu” “application/octet-stream”
    “file:///home/bobc/icewm-menu/” “application/x-shellscript”
    “file:///home/bobc/icewm-menu/” “application/x-shellscript”
    “file:///home/bobc/” “application/zip”
    “file:///home/bobc/icewm-menu-2/” “application/x-shellscript”
    “file:///home/bobc/icewm-menu-2/” “application/x-shellscript”
    “file:///home/bobc/icewm-menu-2/” “application/x-shellscript”
    “file:///home/bobc/icewm-menu-2/” “application/x-shellscript”
    “file:///home/bobc/icewm-menu-2/menu” “text/plain”
    “file:///home/bobc/icewm-menu/icewm-menu/” “application/x-shellscript”
    “file:///home/bobc/antix19b3withrecentfiles.jpg” “image/jpeg”
    “file:///home/bobc/” “application/zip”
    “file:///home/bobc/screenshot%20for%20rej.jpg” “image/jpeg”
    “file:///home/bobc/screenshot-for-rej-after-change.jpg” “image/jpeg”
    “file:///home/bobc/screenshot-for-moddit.jpg” “image/jpeg”
    “file:///home/bobc/zcrap/” “application/x-shellscript”
    “file:///home/bobc/zcrap/test%20a%20bit%20more.txt” “text/plain”
    “file:///home/bobc/Desktop/ScreenLayout/test%20a%20bit%20more.txt” “text/plain”
    “file:///home/bobc/Desktop/ScreenLayout/1440×900-Screen” “application/x-shellscript”
    “file:///home/bobc/icewm-menu-3/” “application/x-shellscript”


    how can I translate the mimetype into what icon filename to display, quickly?

    Hi, Bob
    Once again I think I can provide some assistance… unfortunately, not solve your “problem”, but point you to what I believe is the correct path:

    -The command you are using returns the “mimetype”… according to my limited testing, you can use that, in conjunction to the default mimetype icon set to get the correct icon to be displayed.
    – in antiX 19, we can use as mimetype icons, the icons on the following location:
    – In reality you want the output to be something like:
    “file:///usr/share/icons/default/index.theme” “/usr/share/icons/papirus-antix/22×22/mimetypes/text-plain.png”
    instead of “file:///usr/share/icons/default/index.theme” “text/plain”

    General steps to achieve this, in a fast way:

    1- Set a variable (ex: $iconpath) to “/usr/share/icons/papirus-antix/22×22/mimetypes”
    2- Divide the sed parsing- do it separately to first get the file’s full path, and then to get the mimetype. This is needed so you can parse the mimetype, converting any “/” to “-“m with sed.
    3- add the extension “.png” to the end result of the icon’s path and name (ex: you can use a variable like “$extension” if you want to, to allow for future use of .svg icons, for example).
    4- Check if there’s a existing icon that matches the iconpath + parsed mimetype + extension exists, using something like:
    if [[ -f “$iconpath$parsedmimetype$extension” ]]; then $icon = $iconpath$parsedmimetype$extension
    else $icon= defaulticon ## If the icon does not exist, use a general icon instead (like “gears”)

    Using this, most of the times you get a existing icon (I manually tested with .txt, shellscript, .zip and .jpg files, from your output example)
    However, that does not work on the very first line from your example output because I did not find any icon for “application/octet-stream”. You’ll have to use a default icon…

    You are almost there, Bob, I hope I managed to help you again…

    P.S.- Yeah… I said the icon’s “eye candy” in the dynamic menus was not worth the work and ended up sucked into this too 🙂


    • This reply was modified 8 months, 1 week ago by PPC.

    Yeah, the last things I looked at last night were your toolbar manager script and Dave’s app select.

    I worry that on a Pentium III it will really slow it down though.

    I am thinking of initially doing it in a modular manner where I limit the functionality to one level per module. They will be easy to combine if performance will be reasonable, but if not then could be done in advance when you login.

    I dont know how to run something when IceWM restarts, but that would be optimal. I could then also use those same lookups either way for my desktop apps dynamic menu as well.

    I’m just thinking aloud, but remember well how slow dynamic menus were back 20 years ago anytime they had to go figure out what icon to use.


    And ps, yes a thanks is in order because we are way beyond my comfort level at this point and I really do appreciate the help.


    I got Recent Files and Drives working well, but I’m still working on getting icons for Desktop Apps. I didn’t use your method. I only look in one place. To run reasonably and not cause painful delays on old machines requires quick lookups, and the more lookups are required, the slower it will get.

    Drives now tries to open the mount, but if not mounted, just opens the file manager in your home directory so you can use root authority to mount it if you wish, but not attempt to do it automatically.

    Recent Files is very nice at this point. I’m quite happy with it. I did remove the Open and Run, and the icons are working and not slow. Neet to retest on the old Pentiums when done to be sure.

    I’ll post good code by the weekend.


    Ok, I am liking this…

    One thing I needed to do to make the desktop folder and recent files options work normally was that I had to increase the number of places IceWM looks for icons because it was setup to display the antiX startup and shutdown icons, and app icons, but not the ones for mime types, so I needed to add those to the lookup list. I expect that for finding icons for mimetypes it will be slower as it will have more searching to do, but there isn’t much I can do to speed it up unless the commonly used ones were moved higher in the IconPath list.

    Preferences change:

    #  Icon search path (colon separated)

    I will need to test it on the antique Pentium III. Antiques cars at least are typically defined as ones over 20 years old, so I guess its an appropriate designation. To me it’s an honor that I built it well enough back in 1998 that it has survived and still runs well today. It remains to be seen whether these dynamic menus are efficient enough to run on an antique. With the Drives option, I hard coded the icon to folder (after the pic below was taken) since I didn’t want to increase the default search any wider. Perhaps a better icon could be found within the standard folders, but the inode ones were not goodd looking at all…

    So, here are pic of each of the 3 and the zip file. Note that the IceWM menu is included as well and includes the fix for the IceWM help and FAQ.

    LOL, while making the pics I hit a bug, so need to fix, retest and rezip before I upload the code. The problem I had was it wouldn’t play the movie with spaces in the name, but I have resolved it, now.

    • This reply was modified 8 months, 1 week ago by BobC.
Viewing 15 posts - 46 through 60 (of 100 total)
  • You must be logged in to reply to this topic.