WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: look like a bug for openbox makemenu to have %U etc  (Read 9261 times)

Offline simond

  • Newbie
  • *
  • Posts: 8
look like a bug for openbox makemenu to have %U etc
« on: September 08, 2019, 04:39:26 AM »

using openbox,  some apps, if installed  like pcmanfm or netsurf,
will not work using desktop menu.

I find the menu file is /usr/local/tce.openbox.xml
and the command in this file is wrong.
I modified this file and the menu system can work now

but after reboot it revert to that bad state.
even if saved to mydata.tgz by add it to /opt/.filetool.lst

turns out that the menu is dynamicly generated after every reboot

after some further digging,
from command "openbox_makemenu" I see that
it use function "writeMenuItem" from "openbox_menu_common"
to strip out the exec command from *.desktop file
in folder /usr/local/share/applications

the problem is , some freedesktop parameters begin with "%"
seems should NOT be included in the menu

test:
Code: [Select]
tc@box:~$ . /etc/init.d/tc-functions
tc@box:~$ . /usr/local/bin/openbox_menu_common
tc@box:~$ writeMenuItem /usr/local/share/applications/netsurf.desktop
<item label="netsurf"> <action name="Execute"> <command>netsurf-gtk %u</command> </action> </item>
tc@box:~$

as this, the command stripped is "netsurf-gtk %u", which is bad,
this won't work.
need only "netsurf-gtk" this part,

other menu like wbar or jwm don't have such problem

is this a bug or trival thing to be ignored?
seems openbox is old and never get updated.
maybe some kind guy update it a bit?

Quote
Title:          openbox.tcz
Description:    Highly configurable, next generation window manager
Version:        3.5.2
Author:         Dana Jensens, Mikael Magnusson, Derek Foreman, Tore Anderson and others
Original-site:  http://openbox.org
Copying-policy: GPL v2
Size:           254k
Extension_by:   bmarkus
Tags:           WINDOW MANAGER
Comments:       Binaries only
                ----
                Compiled for 5.x
Change-log:     2013/08/06 First version, 3.4.11.2
                2013/08/13 Fixed TC integration
Current:        2013/08/21 Updated to 3.5.2

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11704
Re: look like a bug for openbox makemenu to have %U etc
« Reply #1 on: September 08, 2019, 09:07:57 AM »
Hi simond
Welcome to the forum. Since you already dug into this, maybe you could compare how  jwm  handles this with  openbox  and
suggest a fix. You can fetch  jwm.tcz  to examine the menu scripts without installing it as follows:
Code: [Select]
tce-load -wi squashfs-tools
wget http://tinycorelinux.net/10.x/x86/tcz/jwm.tcz
unsquashfs jwm.tcz
cd squashfs-root/usr/local/bin
editor jwm_menu_common

The  openbox  menu scripts in  /usr/local/bin  are links to a read only squash file system. To edit them so you can try out changes,
you first need to replace the links with actual files like this:
Code: [Select]
sudo busybox cp -f /tmp/tcloop/openbox/usr/local/bin/openbox_menu_common  /usr/local/bin/openbox_menu_common
sudo chown tc:staff /usr/local/bin/openbox_menu_common

Offline simond

  • Newbie
  • *
  • Posts: 8
Re: look like a bug for openbox makemenu to have %U etc
« Reply #2 on: September 08, 2019, 12:28:57 PM »
Since you already dug into this, maybe you could compare how  jwm  handles this with  openbox  and
suggest a fix.

test jwm:
Code: [Select]
tc@box:~$ . /etc/init.d/tc-functions
tc@box:~$ . /usr/local/bin/jwm_menu_common
tc@box:~$ writeMenuItem /usr/local/share/applications/netsurf.desktop
<Program label="netsurf">exec netsurf-gtk </Program>
tc@box:~$

the stripped part is 'netsurf-gtk' , no '%u' :
<Program label="netsurf">exec netsurf-gtk </Program>



after comparing /usr/local/bin/openbox_menu_common
and /usr/local/bin/jwm_menu_common,
I found that they are almost same,
except that jwm_menu_common add 2 lines to remove that ‘%’ part:

else if ( $1 == "Exec" ) {
    exec = $2
    test = match(exec,"%")
    if ( test ) exec = substr(exec,0,test-1)

  } else if ( $1 == "Terminal" ) {
    terminal = $2
  }

so to fix this:
add these 2 lines to /usr/local/bin/openbox_menu_common  after line 15

seems that Robert noticed this and fixed it in jwm, now just need to copy this same procedure to openbox





« Last Edit: September 08, 2019, 12:52:10 PM by simond »

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11704
Re: look like a bug for openbox makemenu to have %U etc
« Reply #3 on: September 08, 2019, 08:16:59 PM »
Hi simond
I just checked my window manager (flwm_topside) and it matches what jwm has:
Code: [Select]
#!/bin/sh
# (c) Robert Shingledecker 2010
# Called from tc-config to setup initial flwm system menu & tce menu

writeFLWMitem() {
busybox awk -v output="$TARGET" '
BEGIN {
  FS = "="
  name = ""
  exec = ""
}
{
  if ( $1 == "Name" && name == "") {
    name = $2
    gsub(/ /, "", name)
  } else if ( $1 == "Exec" && exec == "") {
    exec = $2
    test = match(exec,"%")
    if ( test ) exec = substr(exec,0,test-1)
  } else if ( $1 == "Terminal" ) {
    terminal = $2
  }
}
END {
  print "#!/bin/sh" > output"/"name
  if ( terminal == "true" ) {
     print "exec aterm +tr +sb -T \""name"\" -e " exec > output"/"name
  } else {
    print "exec " exec > output"/"name
  }
  system("chmod +x "output"/"name)
} ' "$1"
}

Please perform the following commands:
Code: [Select]
sudo busybox cp -f /tmp/tcloop/openbox/usr/local/bin/openbox_menu_common  /usr/local/bin/openbox_menu_common
sudo chown tc:staff /usr/local/bin/openbox_menu_common
sudo cp -a /usr/local/bin/openbox_menu_common /usr/local/bin/openbox_menu_common.original

Then edit  /usr/local/bin/openbox_menu_common  to add the required lines and verify it works as intended. Once you are satisfied
with the results, create a  unified diff  like this:
Code: [Select]
diff -u /usr/local/bin/openbox_menu_common.original /usr/local/bin/openbox_menu_common > /usr/local/bin/openbox_menu_common.diffThen attach the  /usr/local/bin/openbox_menu_common.diff  file to your next post so your changes can be applied to the repository.

Offline simond

  • Newbie
  • *
  • Posts: 8
Re: look like a bug for openbox makemenu to have %U etc
« Reply #4 on: September 09, 2019, 01:11:14 AM »
ok, diff attached.

I don't know what's the exact command to generate menu for all loaded apps,
but here's a little test:
Code: [Select]
tc@box:~$ sudo patch /usr/local/bin/openbox_menu_common openbox_menu_common.diff
tc@box:~$ sudo rm /usr/local/tce.openbox.xml
tc@box:~$ sudo openbox_initmenu
tc@box:~$ sudo openbox_makemenu leafpad
tc@box:~$ sudo openbox_restart
tc@box:~$ cat /usr/local/tce.openbox.xml

tce.openbox.xml:
Code: [Select]
<?xml version="1.0" encoding="UTF-8"?>
<openbox_menu xmlns="http://openbox.org/3.4/menu">
<menu id="apps-menu" label="Applications">
<item label="Leafpad"> <action name="Execute"> <command>leafpad </command> </action> </item>
<!-- END_TCE -->
</menu>
</openbox_menu>

<item label="Leafpad"> <action name="Execute"> <command>leafpad </command> </action> </item>
no more "%" variables part
https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-1.0.html#exec-variables


now test in the desktop menu, it's ok now.

-----



but, as I know, the openbox config is located at /home/tc/.config/openbox
but why these local config files are overriden after every reboot,
though they're actually backed up in mydata.tcz ?

aren't the files under /home/tc/.config supposed to be persistent?


from http://wiki.tinycorelinux.net/wiki:persistence_for_dummies
Quote
Getting tinycore to save your documents and settings
Many settings, and all documents, are stored in your home directory called
/home/tc (also called $HOME or ”~” ), and /opt

I trid to create a file in /home/tc/.config/openbox like this:
Code: [Select]
echo test > /home/tc/.config/openbox/demo.txt
and after reboot, this demo.txt still exists,
but other menu files in the same folder are overridden with origin files

strange

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11704
Re: look like a bug for openbox makemenu to have %U etc
« Reply #5 on: September 09, 2019, 09:04:26 AM »
Hi simond
... aren't the files under /home/tc/.config supposed to be persistent? ...
Yes, everything under  /home  and  /opt  is persistent.

Quote
... I trid to create a file in /home/tc/.config/openbox like this:
Code: [Select]
echo test > /home/tc/.config/openbox/demo.txt
and after reboot, this demo.txt still exists,
but other menu files in the same folder are overridden with origin files ...
Which shows your  /home  is persistent and something else is overwriting those  .xml  files.

Menus for installed extensions are built from scratch when you boot. It's possible there may be some mechanism for saving
customizations. Looking at the change log of the  jwm  info file:
http://tinycorelinux.net/10.x/x86/tcz/jwm.tcz.info
I see the following entry:
Quote
2009/10/09 Adjusted jwm_initmenu to not overwrite existing
If you still have the unsquashed  jwm.tcz  as described in  Reply #1  it might be worth trying to see what they fixed in:
Code: [Select]
squashfs-root/usr/local/bin/jwm_initmenu
Both  jwm  and  openbox  have startup scripts that you also might want to look at:
Code: [Select]
squashfs-root/usr/local/tce.installed/jwmand:
Code: [Select]
/usr/local/tce.installed/openbox

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11704
Re: look like a bug for openbox makemenu to have %U etc
« Reply #6 on: September 09, 2019, 09:13:06 AM »
Hi simond
I see you've taken the time to look through the Wiki, to which I say kudos to you. If you haven't already found it, here is some highly
recommended reading material:
http://tinycorelinux.net/corebook.pdf

Offline simond

  • Newbie
  • *
  • Posts: 8
Re: look like a bug for openbox makemenu to have %U etc
« Reply #7 on: September 09, 2019, 12:38:40 PM »
ok, checked again the command openbox_initmenu,
and I think there's no problem now.

it actually keeps openbox config file unchanged, include menu.xml and rc.xml,
and regenaretes /home/.config/openbox/system-tools.xml and /usr/local/tce.openbox.xml

yesterday I only changed system-tools.xml, so I found it reverted.
now I tried to changed menu.xml and rc.xml, and the change remains after reboot

this is acceptable.

just that, I think maybe the auto generated system-tools.xml should be placed in folder /usr/local,
not in /home/.config/openbox/, since that's supposed to be persistent. a bit confusing


and yes, I've read that book and FAQ. thank you for your detailed documentation. it's very  useful for us new users

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11704
Re: look like a bug for openbox makemenu to have %U etc
« Reply #8 on: September 09, 2019, 01:03:38 PM »
Hi simond
... just that, I think maybe the auto generated system-tools.xml should be placed in folder /usr/local,
not in /home/.config/openbox/, since that's supposed to be persistent. a bit confusing ...
I don't know about  openbox  so I can't comment on that. There may or may not be a good reason for placing it under  /home/.config/openbox/.

Quote
... and yes, I've read that book and FAQ. thank you for your detailed documentation. it's very  useful for us new users
If you were referring to the book, it was written by curaga, not me. If you were referring to the instructions I posted, you are welcome.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11704
Re: look like a bug for openbox makemenu to have %U etc
« Reply #9 on: September 09, 2019, 01:19:05 PM »
Hi Juanito
simond attached a diff to Reply #4 to fix a menu issue. If the x86_64 version requires the same fix, those scripts are in a separate
extension which  openbox.tcz.info  recommends installing:
http://tinycorelinux.net/10.x/x86_64/tcz/openbox-config.tcz.list
Do you want to apply the patch or do you want me to download the extensions and resubmit them?

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14851
Re: look like a bug for openbox makemenu to have %U etc
« Reply #10 on: September 09, 2019, 02:08:51 PM »
Up to you  :)

I’ll be back the day after tomorrow.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11704
Re: look like a bug for openbox makemenu to have %U etc
« Reply #11 on: September 09, 2019, 04:44:25 PM »
Hi Juanito
OK, I'll take care of it tonight.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11704
Re: look like a bug for openbox makemenu to have %U etc
« Reply #12 on: September 09, 2019, 09:41:59 PM »
Hi Juanito
Packages sent to tcesubmit with updated  .tcz, tcz.info, and .tcz.md5.txt  files.

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14851
Re: look like a bug for openbox makemenu to have %U etc
« Reply #13 on: September 11, 2019, 10:43:43 AM »
Posted - thanks  :)