WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: adriconf.tcz not working for my X  (Read 16177 times)

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14790
Re: adriconf.tcz not working for my X
« Reply #15 on: May 19, 2019, 04:50:12 AM »
What would be helpful (since adriconf apparently will not work with wayland at present) would be to check the following:

As far as I can tell, this is OK as per the freedesktop standard:
Code: [Select]
$ grep Exec /usr/local/share/applications/adriconf.desktop
Exec=env XDG_SESSION_TYPE=x11 adriconf
..and "gtk-launch adriconf" works.

..but:
Code: [Select]
$ cat /home/tc/.wmx/Applications/adriconf
#!/bin/sh
exec env XDG_SESSION_TYPE

$ cat /home/tc/.wbar
...
i: /usr/local/share/pixmaps/br.com.jeanhertel.adriconf.png
t: adriconf
c: exec env XDG_SESSION_TYPE
..so adriconf will not run from the wbar icon nor menu item.

Could somebody better than me at awk take a look at wbar_update.sh and figure out how to correct things so it parses the desktop Exec line as expected?

Offline nick65go

  • Hero Member
  • *****
  • Posts: 832
Re: adriconf.tcz not working for my X
« Reply #16 on: May 19, 2019, 06:47:16 AM »
hi juanito, may I ask: what is wrong with my patch? it works for me, from default flwm:
so the folder tce.install (which is autorun when tce-load -i adriconf.tcz first time) will write/copy this script in ~/.local/bin/adriconf
Code: [Select]
XDG_SESSION_TYPE=x11 /usr/local/bin/adriconfwhich will be executed both from FLWM menu and wbar. (of course, it should be chmod-ed 775 to be executable)
« Last Edit: May 19, 2019, 06:49:58 AM by nick65go »

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14790
Re: adriconf.tcz not working for my X
« Reply #17 on: May 19, 2019, 07:38:43 AM »
There's nothing wrong with your solution, but there does seem to be a problem with wbar, which would affect other desktop files too.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11573
Re: adriconf.tcz not working for my X
« Reply #18 on: September 10, 2020, 04:56:32 PM »
Hi Juanito
I spent some time researching awk and I have some answers for you. The scripts set FS (field separator) to the equal sign.
When you do this:
Code: [Select]
Exec=env XDG_SESSION_TYPE=x11 adriconfawk sees 3 fields due to the extra = sign and only grabs field #2. I formatted the  flwm_topside_menu_common  script
so I could follow what was going on and to add some comments:
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" ' # $TARGET is set by calling program.
BEGIN # This block of code gets executed once before any input is read.
{
FS = "=" # Sets the field separator.
name = ""
exec = ""
}

{ # This block of code gets executed on each line read from the file.
# In this context, $1 and $2 are the fields of the line being read.
if ( $1 == "Name" && name == "") # Match on the Name= line.
{
name = $2
gsub(/ /, "", name) # Removes all space characters (not tabs) from name.
}
else if ( $1 == "Exec" && exec == "") # Match on the Exec= line.
{
#exec = $2
exec = substr($0, index($0, $2)) # index returns character # $2 starts on. substr copies from that
# character # to end of $0 into exec.
test = match(exec,"%") # Return the position of the first % character found.
if ( test )
exec = substr(exec,0,test-1) # Remove all text from the % character to the end of string.
}
else if ( $1 == "Terminal" ) # Match on the Terminal= line.
{
terminal = $2 # Flag used by the END block.
}
}

END # This block of code gets executed once after all input is read.
{ # In awk, the first  print "blah blah" > filename  creates the file.
# Further  print "blah blah" > filename  commands append to the file.
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" # $1 is the file name to be parsed.
}

I did the same for the  wbar_update.sh  script:
Code: [Select]
#!/bin/sh
# (c) Robert Shingledecker 2010
# Called from desktop.sh to update wbar icons.

writeWBARitem()
{
busybox awk -v output="$TMP" -v target="$TARGET" -v wbaricons="$TCEWBAR" '
BEGIN # This block of code gets executed once before any input is read.
{
FS = "=" # Sets the field separator.
name = ""
exec = ""
}

function rtrim(s) { sub(/[ \t]+$/, "", s); return s } # Removes all space characters and tabs from end of string.

{ # This block of code gets executed on each line read from the file.
# In this context, $1 and $2 are the fields of the line being read.
if ( $1 == "Name" && name == "") # Match on the Name= line.
{
name = rtrim($2)
gsub(/ /, "", name) # Removes all space characters (not tabs) from name.
}
else if ( $1 == "Exec" && exec == "") # Match on the Exec= line.
{
#exec = $2
exec = substr($0, index($0, $2)) # index returns character # $2 starts on. substr copies from that
# character # to end of $0 into exec.
test = match(exec,"%") # Return the position of the first % character found.
if ( test )
exec = substr(exec,0,test-1) # Remove all text from the % character to the end of string.
}
else if ( $1 == "X-FullPathIcon" ) # Match on the X-FullPathIcon= line.
{
icon = $2
}
else if ( $1 == "Terminal" ) # Match on the Terminal= line.
{
terminal = $2 # Flag used by the END block.
}
}

END # This block of code gets executed once after all input is read.
{
found = 0
while (( getline item < wbaricons ) > 0 ) # Reading /usr/local/tce.icons.
{
if ( index(item, target) > 0 ) # Check for "$APPNAME".img (why???).
{
found = 1
print "i: " icon >> output # Save to /tmp/wbar.$$.
print "t: " name > output
if ( terminal == "true" )
{
print "c: exec aterm +tr +sb -T \""name"\" -e " exec > output
}
else
{
print "c: exec " exec > output
}
getline item < wbaricons # Purge the next 2 lines.
getline item < wbaricons
}
else
{
print item > output # Save to /tmp/wbar.$$.
}
}
if ( found == 0 ) # found == 0 means this is a new wbar entry.
{
print "i: " icon >> output
print "t: " name > output
if ( terminal == "true" )
{
print "c: exec aterm +tr +sb -T \""name"\" -e " exec > output
}
else
{
print "c: exec " exec > output
}

}
close(wbaricons)
} ' "$1"
sudo mv "$TMP" "$TCEWBAR" # Replace the old /usr/local/tce.icons file with the newly created one.
sudo chmod g+w "$TCEWBAR"
}

# Script starts here.
TCEWBAR="/usr/local/tce.icons"
TCEDIR=/etc/sysconfig/tcedir
APPNAME="$1"
#OnDemand xwbar check
if grep -qw "^t: *${APPNAME}$" "${TCEDIR}"/xwbar.lst 2>/dev/null; then exit 0; fi
TMP=/tmp/wbar.$$

#
FREEDESK=/usr/local/share/applications/"$APPNAME".desktop
if [ -e "$FREEDESK" ]; then
ICONCHECK="$(awk 'BEGIN{FS = "="}$1=="X-FullPathIcon"{print $2}' "$FREEDESK")"
NAMECHECK="$(awk 'BEGIN{FS = "="}$1=="Name"{print $2; exit 0}' "$FREEDESK")"
if grep -qw "^t: *${NAMECHECK// /}$" "${TCEDIR}"/xwbar.lst 2>/dev/null; then exit 0; fi
TARGET="$APPNAME".img
[ -f "$ICONCHECK" ] && writeWBARitem "$FREEDESK" && [ -G /tmp/.X11-unix/X0 ] && wbar.sh
fi

The fix for both files is here:
Code: [Select]
#exec = $2
exec = substr($0, index($0, $2)) # index returns character # $2 starts on. substr copies from that
# character # to end of $0 into exec.
The  exec =  line needs to be changed so it copies from the start of field #2 to the end of $0 (the entire line).
« Last Edit: September 11, 2020, 12:32:55 AM by Rich »

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14790
Re: adriconf.tcz not working for my X
« Reply #19 on: September 11, 2020, 03:38:52 AM »
I'd almost forgotten about that - thanks  :)

Of course an even better fix would be for adriconf to realise for itself whether it was launched from a wayland or x11 session...

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11573
Re: adriconf.tcz not working for my X
« Reply #20 on: September 11, 2020, 11:49:09 AM »
Hi Juanito
I'd almost forgotten about that - thanks  :)
I rediscovered this thread about 6 weeks ago and left an open tab to it in my browser. That solved the forgetting part, but
not the procrastination because I found it difficult to follow and understand the code. You can't fix what you don't understand. ::)
Had I reformatted and commented the code from the get go, I would have been done a lot sooner. :-[

The fix was tested against your example to make sure it was parsed correctly.

I'm guessing all of the following will be affected:
Code: [Select]
fluxbox.tcz /usr/local/bin/fluxbox_menu_common
flwm.tcz /usr/local/bin/flwm_menu_common
flwm_topside.tcz /usr/local/bin/flwm_topside_menu_common
hackedbox.tcz /usr/local/bin/hackedbox_menu_common
icewm.tcz /usr/local/bin/icewm_menu_common
jwm.tcz /usr/local/bin/jwm_menu_common
openbox.tcz /usr/local/bin/openbox_menu_common
« Last Edit: September 17, 2020, 08:03:14 PM by Rich »

aus9

  • Guest
Re: adriconf.tcz not working for my X
« Reply #21 on: September 11, 2020, 06:47:55 PM »
@Rich, I did look to see you have posted in the TC64 forum. Maybe TC32 has this file but not TC64
/usr/local/bin/icewm_menu_common

replaced on TC64 with
Quote
icewm-menu-fdo - This generates IceWM program menus from FreeDesktop .desktop files.
ref https://ice-wm.org/manual/

so hopefully my precious wm won't be affected.


Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11573
Re: adriconf.tcz not working for my X
« Reply #22 on: September 11, 2020, 08:51:59 PM »
Hi aus9
You are correct. I created that list from the 32 bit repository. I figured the same scripts were in the 64 bit versions
since they are Tinycore specific.

So in the 64 bit repository, these window managers do contain the Tinycore menu scripts:
Code: [Select]
fluxbox.tcz /usr/local/bin/fluxbox_menu_common
flwm.tcz /usr/local/bin/flwm_menu_common
flwm_topside.tcz /usr/local/bin/flwm_topside_menu_common
hackedbox.tcz /usr/local/bin/hackedbox_menu_common
jwm.tcz /usr/local/bin/jwm_menu_common

These do not contain the Tinycore menu scripts:
Code: [Select]
icewm.tcz
openbox.tcz

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11573
Re: adriconf.tcz not working for my X
« Reply #23 on: September 12, 2020, 09:34:32 AM »
Hi aus9
... These do not contain the Tinycore menu scripts:
Code: [Select]
icewm.tcz
openbox.tcz

Correction. In the 64 bit repository,  openbox  has the scripts in:
Code: [Select]
openbox-config.tcz
« Last Edit: September 12, 2020, 11:06:59 AM by Rich »

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11573
Re: adriconf.tcz not working for my X
« Reply #24 on: September 17, 2020, 07:59:34 PM »
Hi aus9
I updated all of the window managers in the TC11 x86, x86_64, and ARM repositories except for yours. I don't know
how your extension handles desktop icons and menus and didn't want to risk breaking something.

aus9

  • Guest
Re: adriconf.tcz not working for my X
« Reply #25 on: September 17, 2020, 09:33:41 PM »
Hi Rich

Very considerate of you. If you don't mind, as I am not sure if it affects me or not, can you send me a download link to the "changed" files. I can then try them please.

1) menu handled by new executable as already mentioned, but it knows nothing about "ondemand"
2) desktop icons handled by pcmanfm, if the member elects to download and run it

I have read a number of your posts regarding ondemand, so was not too fussed that users of my TCE will lack that feature. But I can be flexible.  8)

cheers
« Last Edit: September 17, 2020, 09:36:36 PM by aus9 »

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11573
Re: adriconf.tcz not working for my X
« Reply #26 on: September 17, 2020, 10:20:24 PM »
Hi aus9
The 2 files modified are posted in the first 2 code boxes of reply #18. The first file is  flwm_topside_menu_common.
All of the window managers have this file, except the  flwm_  part has the window managers name. For example, icewm
would have  icewm_topside_menu_common. The only thing that changed was this 1 line:
From:
Code: [Select]
exec = $2To:
Code: [Select]
exec = substr($0, index($0, $2))There are actually 6 scripts added to the window manager packages. I think your best bet is to grab these:
Code: [Select]
/usr/local/bin/icewm_initmenu
/usr/local/bin/icewm_makemenu
/usr/local/bin/icewm_menu_common
/usr/local/bin/icewm_ondemand
/usr/local/bin/icewm_restart
/usr/local/bin/icewm_rmitem
from the 32 bit  icewm.tcz  package:
http://tinycorelinux.net/11.x/x86/tcz/icewm.tcz.info

The second file I modified is part of the  wbar.tcz  extension. I fixed all of those so you don't need to worry about it.

aus9

  • Guest
Re: adriconf.tcz not working for my X
« Reply #27 on: September 18, 2020, 01:10:29 AM »
HI Rich,
@Paul_123 (if he reads this arch forum)

First TC64 icewm
unpacked and moved files with root powers into /usr/local/bin and saved all files backup
full reboot no good. I lose  menus.
I manually then loaded a ondemand by
Code: [Select]
$ tce-load -wo ace-of-penguins
That made no difference to the menu. At this stage, as Juanito says few people use TC64 and my menu works without so far any complaints, lets leave it.

a screenshot of before and after for anyone interested, wallpaper removed to avoid copyright issues.
https://imgur.com/1KQZ5NT

2) ARM jwm for 12x (alpha)
I wanted to test ondemand menu and that works great. As its still alpha, maybe let me submit to Paul_123. I am not sure if he reads TC64 forums either. I won't submit anything for 12x for a number of days for time reasons.
« Last Edit: September 18, 2020, 01:27:34 AM by aus9 »

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14790
Re: adriconf.tcz not working for my X
« Reply #28 on: September 18, 2020, 03:07:31 AM »
..as Juanito says few people use TC64...

Did I say that?

aus9

  • Guest
Re: adriconf.tcz not working for my X
« Reply #29 on: September 18, 2020, 03:19:12 AM »
Quote
I presume the same problem exists in the x86 repo, but as hardly anybody uses Core64, the issue hasn't arisen
http://forum.tinycorelinux.net/index.php/topic,24246.msg153375.html#msg153375

I have taken the liberty of assuming Core64 is roughly the same as CorePure64, which I abbreviate to TC64
« Last Edit: September 18, 2020, 03:24:12 AM by aus9 »