WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: wbar (and X.d) questions  (Read 8800 times)

Offline bigpcman

  • Hero Member
  • *****
  • Posts: 719
wbar (and X.d) questions
« on: May 23, 2010, 07:11:49 PM »
I noticed when I hover over the opera wbar icon I get a black line to the right of it. There is nothing there when I'm not hovering. Probably nothing to do with tc3 but that's where I found it.
See attached pic.

Code: [Select]
tc@box:/usr/local$ cat tce.wbar
# The Bar && Font && Font size (11)
i: /usr/share/wbar/osxbarback.png
t: /usr/share/fonts/luxisr/11
c:
i: /usr/share/pixmaps/power.png
t: Exit
c: exec exittc
i: /usr/share/pixmaps/aterm.png
t: Aterm
c: exec aterm
i: /usr/share/pixmaps/cpanel.png
t: Panel
c: exec cpanel
i: /usr/share/pixmaps/appbrowser.png
t: Apps
c: exec appbrowser
i: /usr/local/share/pixmaps/opera10.png
t: Opera_browser-only
c: exec /usr/local/bin/opera -nomail -nolirc
tc@box:/usr/local$


Code: [Select]
tc@box:/usr/local/tce.installed$ ls
Xlibs_support                  mtd-2.6.33.3-tinycore
atk                            openssl-0.9.8
bash                           opera10
bzip2-lib                      pango
cairo                          pixman
dbus                           pycairo
dbus-glib                      pygobject
dbus-python                    pygtk
expat2                         python
filesystems-2.6.33.3-tinycore  qt-4.x-base
fontconfig                     shared-mime-info
glib2                          sqlite3
graphics-libs-1                tcl_tk
gtk2                           ttf-bitstream-vera
libcroco                       urwid
libffi                         wavemon
libglade                       wicd
libgsf                         wireless-2.6.33.3-tinycore
libiconv                       wireless_tools
librsvg                        wpa_supplicant
libxml2                        x11vnc

« Last Edit: March 28, 2023, 01:16:49 AM by Rich »
big pc man

Offline ^thehatsrule^

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 1726
Re: wbar (and X.d) questions
« Reply #1 on: May 24, 2010, 01:46:52 AM »
[edit: unrelated in new thread]

@bigpcman: It's most likely a wbar related issue.  I have seen something similar to it before with longer-than-icon text labels.
« Last Edit: May 28, 2010, 07:50:54 PM by ^thehatsrule^ »

Offline bigpcman

  • Hero Member
  • *****
  • Posts: 719
Re: wbar (and X.d) questions
« Reply #2 on: May 24, 2010, 03:23:27 PM »
@bigpcman: It's most likely a wbar related issue.  I have seen something similar to it before with longer-than-icon text labels.
You are right. I changed the wbar opera label to just opera and the black line went away.
big pc man

Offline bigpcman

  • Hero Member
  • *****
  • Posts: 719
wbar (and X.d) questions
« Reply #3 on: May 27, 2010, 12:12:38 PM »
Just curious why "wbar" is not executable?

Code: [Select]
tc@testbox:~/.X.d$ ls -al
total 4
drwxr-xr-x    2 tc       staff           60 May 27 10:07 ./
drwxr-sr-x    6 tc       staff          340 May 27 10:58 ../
-rw-r--r--    1 tc       staff           43 Apr 21 18:03 wbar
big pc man

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11044
Re: wbar (and X.d) questions
« Reply #4 on: May 27, 2010, 12:49:30 PM »
Just curious why "wbar" is not executable?

Code: [Select]
tc@testbox:~/.X.d$ ls -al
total 4
drwxr-xr-x    2 tc       staff           60 May 27 10:07 ./
drwxr-sr-x    6 tc       staff          340 May 27 10:58 ../
-rw-r--r--    1 tc       staff           43 Apr 21 18:03 wbar


As they are sourced, they don't need to be.
The only barriers that can stop you are the ones you create yourself.

Offline bigpcman

  • Hero Member
  • *****
  • Posts: 719
Re: wbar (and X.d) questions
« Reply #5 on: May 27, 2010, 01:43:23 PM »
How do you restart wbar after boot. I tried "wbar.sh" but "echo $ICONS" reports nothing present. Wbar is running and all the standard icons are present.

Perhaps something else is wrong as well:

Code: [Select]
tc@testbox:~$ /usr/bin/wbar.sh
sh: wbar: unknown operand

and if I use brute force:
Code: [Select]
tc@testbox:/usr/bin$ sudo killall wbar
tc@testbox:/usr/bin$ wbar -bpress -config /usr/local/tce.wbar
tc@testbox:/usr/bin$ Couldn't open display
Edit: I made this mistake once before but forgot about it. I've been using ssh to communicate with my eeepc and that is what causes the "Couldn't open display" errors" and the problems with wbar.sh.
« Last Edit: May 27, 2010, 05:24:43 PM by bigpcman »
big pc man

Offline bigpcman

  • Hero Member
  • *****
  • Posts: 719
just out of curiosity why does wbar.sh fail when using sudo?
« Reply #6 on: May 28, 2010, 05:14:07 PM »
Code: [Select]
tc@testbox:~$ sudo wbar.sh
sh: wbar: unknown operand
tc@testbox:~$ wbar.sh
tc@testbox:~$ Xlib:  extension "Generic Event Extension" missing on display ":0.0".

tc@testbox:~$

This seems curious too:

Code: [Select]
tc@testbox:~$ sudo -u tc wbar.sh
Sorry, user tc is not allowed to execute '/usr/bin/wbar.sh' as tc on testbox.
tc@testbox:~$

« Last Edit: May 28, 2010, 05:17:20 PM by bigpcman »
big pc man

Offline ^thehatsrule^

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 1726
Re: just out of curiosity why does wbar.sh fail when using sudo?
« Reply #7 on: May 28, 2010, 07:34:02 PM »
The script expects ICONS to be defined, but it will not be defined due to (default) sudo settings.

Typically, one might quote expected strings or similar to ensure one is evaluated.

Offline maro

  • Hero Member
  • *****
  • Posts: 1228
Re: just out of curiosity why does wbar.sh fail when using sudo?
« Reply #8 on: May 28, 2010, 07:50:17 PM »
If one wants to get more details of what is happening when a shell script gets executed one could run it with the '-vx' options. Those options have the following meaning:
    -v verbose  The shell writes its input to standard error as it is read.
    -x xtrace   Write each command to standard error (preceded by a '+ ') before it is executed.

(1) One should be certain which shell is meant to be used. This is specified in the so called "shebang" line (i.e. the first line of a script starting with '#!"):
Code: [Select]
tc@box:~$ head -1 $( which wbar.sh )
#!/bin/sh
That is not surprising since AFAIK all Core scripts are using '/bin/sh', but extensions are known to also use 'bash'.

(2) Now execute the script with the '-vx' option. Please note that 'sh' requires the full path to the script, hence the use of the command substitution with the 'which' command. If parameters are to be specified for the script they will have to follow outside of the command substitution (e.g. /bin/sh -vx $( which command ) param1 param2).
Code: [Select]
tc@box:~$ sudo /bin/sh -vx $( which wbar.sh )
#!/bin/sh
cd "$HOME"
+ cd /home/tc
if [ $ICONS == wbar ]; then
   WBARPID=$(pidof wbar)
   [ -n "$WBARPID" ] && killall wbar
   [ -e .wbar ] && read OPTIONS < .wbar
   wbar  $OPTIONS  -config /usr/local/tce.wbar  >/dev/null &
fi   
+ [ == wbar ]
sh: wbar: unknown operand
Looking at the problem this way it's quite obvious: The '$ICONS' variable is undefined, and since it is not enclosed in double-quotes the shell produces the warning message.

For me personally as a rule of thumb I always try to enclose shell variables in double-quotes when used in comparisons. Albeit it's easy enough to forget, and warning messages are there to remind one of that.

Furthermore I believe that you were trying to use the wrong command: I'd use su -c COMMAND USER instead of sudo -u USER COMMAND. Therefore it would look like this:
Code: [Select]
tc@box:~$ su -c "/bin/sh -vx $( which wbar.sh )" tc
#!/bin/sh
cd "$HOME"
+ cd /home/tc
if [ $ICONS == wbar ]; then
   WBARPID=$(pidof wbar)
   [ -n "$WBARPID" ] && killall wbar
   [ -e .wbar ] && read OPTIONS < .wbar
   wbar  $OPTIONS  -config /usr/local/tce.wbar  >/dev/null &
fi   
+ [ wbar == wbar ]
+ pidof wbar
+ WBARPID=1490
+ [ -n 1490 ]
+ killall wbar
+ [ -e .wbar ]
+ read OPTIONS
tc@box:~$ + wbar -bpress -config /usr/local/tce.wbar
Xlib:  extension "Generic Event Extension" missing on display ":0.0".

Now whether executing all those commands makes sense is not for me to judge. I was merely attemting to provide some advise of how I'd troubleshoot these sort of problems.

Offline bigpcman

  • Hero Member
  • *****
  • Posts: 719
Re: wbar (and X.d) questions
« Reply #9 on: May 28, 2010, 08:25:31 PM »
If one wants to get more details of what is happening when a shell script gets executed one could run it with the '-vx' options. Those options have the following meaning:
    -v verbose  The shell writes its input to standard error as it is read.
    -x xtrace   Write each command to standard error (preceded by a '+ ') before it is executed.

(1) One should be certain which shell is meant to be used. This is specified in the so called "shebang" line (i.e. the first line of a script starting with '#!"):
Code: [Select]
tc@box:~$ head -1 $( which wbar.sh )
#!/bin/sh
That is not surprising since AFAIK all Core scripts are using '/bin/sh', but extensions are known to also use 'bash'.

(2) Now execute the script with the '-vx' option. Please note that 'sh' requires the full path to the script, hence the use of the command substitution with the 'which' command. If parameters are to be specified for the script they will have to follow outside of the command substitution (e.g. /bin/sh -vx $( which command ) param1 param2).
Code: [Select]
tc@box:~$ sudo /bin/sh -vx $( which wbar.sh )
#!/bin/sh
cd "$HOME"
+ cd /home/tc
if [ $ICONS == wbar ]; then
   WBARPID=$(pidof wbar)
   [ -n "$WBARPID" ] && killall wbar
   [ -e .wbar ] && read OPTIONS < .wbar
   wbar  $OPTIONS  -config /usr/local/tce.wbar  >/dev/null &
fi   
+ [ == wbar ]
sh: wbar: unknown operand
Looking at the problem this way it's quite obvious: The '$ICONS' variable is undefined, and since it is not enclosed in double-quotes the shell produces the warning message.

For me personally as a rule of thumb I always try to enclose shell variables in double-quotes when used in comparisons. Albeit it's easy enough to forget, and warning messages are there to remind one of that.

Furthermore I believe that you were trying to use the wrong command: I'd use su -c COMMAND USER instead of sudo -u USER COMMAND. Therefore it would look like this:
Code: [Select]
tc@box:~$ su -c "/bin/sh -vx $( which wbar.sh )" tc
#!/bin/sh
cd "$HOME"
+ cd /home/tc
if [ $ICONS == wbar ]; then
   WBARPID=$(pidof wbar)
   [ -n "$WBARPID" ] && killall wbar
   [ -e .wbar ] && read OPTIONS < .wbar
   wbar  $OPTIONS  -config /usr/local/tce.wbar  >/dev/null &
fi   
+ [ wbar == wbar ]
+ pidof wbar
+ WBARPID=1490
+ [ -n 1490 ]
+ killall wbar
+ [ -e .wbar ]
+ read OPTIONS
tc@box:~$ + wbar -bpress -config /usr/local/tce.wbar
Xlib:  extension "Generic Event Extension" missing on display ":0.0".

Now whether executing all those commands makes sense is not for me to judge. I was merely attemting to provide some advise of how I'd troubleshoot these sort of problems.


Thank you that was very informative.
big pc man

Offline ^thehatsrule^

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 1726
Re: wbar (and X.d) questions
« Reply #10 on: May 28, 2010, 08:37:37 PM »
sudo -u is a valid command, although the current sudo settings don't seem to allow it.

To try it change the setting to i.e. with visudo
Code: [Select]
tc       ALL=(ALL) NOPASSWD: ALL

Offline bigpcman

  • Hero Member
  • *****
  • Posts: 719
Re: wbar (and X.d) questions
« Reply #11 on: May 28, 2010, 09:21:36 PM »
tc3alph4
Progress report

1.) su -c "/bin/sh -vx $( which wbar.sh )" tc

and

su -c wbar.sh tc

returns:

su: must be suid to work properly


2.) using visudo made the "tc   ALL=(ALL) NOPASSWD: ALL" change

reran sudo -u tc wbar.sh and received the
unknown operand error message.

BTW where is the ICON environment variable stored. I thought it was in /home/tc/.profile but I don't see it.
« Last Edit: May 28, 2010, 10:10:55 PM by bigpcman »
big pc man

Offline bigpcman

  • Hero Member
  • *****
  • Posts: 719
Re: wbar (and X.d) questions
« Reply #12 on: May 29, 2010, 05:53:12 PM »
tc3alpha4

So to sum up, am I right in concluding there is no way to access the value (test value) while a root user either in the terminal or in a script, environment variables like:

$ICONS
$ENV
$BACKUP
$DESKTOP

since both

sudo -u tc ...  and
su -c ... tc    both fail to provide access.
« Last Edit: May 29, 2010, 05:55:09 PM by bigpcman »
big pc man

Offline maro

  • Hero Member
  • *****
  • Posts: 1228
Re: wbar (and X.d) questions
« Reply #13 on: May 29, 2010, 07:03:14 PM »
I'm still not clear what you are trying to achieve by running something like su -c CMD tc but I think your system is "playing up".

The extracts I provided yesterday were from the same system that I've used to produced the following:
Code: [Select]
tc@box:~$ version
tinycore_3.0alpha4

tc@box:~$ echo "ICONS=$ICONS ENV=$ENV BACKUP=$BACKUP DESKTOP=$DESKTOP" 
ICONS=wbar ENV=/home/tc/.ashrc BACKUP=1 DESKTOP=flwm_topside

tc@box:~$ su -c "echo \"ICONS=$ICONS ENV=$ENV BACKUP=$BACKUP DESKTOP=$DESKTOP\"" tc
ICONS=wbar ENV=/home/tc/.ashrc BACKUP=1 DESKTOP=flwm_topside

tc@box:~$ sudo grep tc /etc/sudoers
tc      ALL=(ALL) NOPASSWD: ALL
tc@box:~$ sudo -u tc echo "ICONS=$ICONS ENV=$ENV BACKUP=$BACKUP DESKTOP=$DESKTOP"
ICONS=wbar ENV=/home/tc/.ashrc BACKUP=1 DESKTOP=flwm_topside

If you don't get the same result try booting again with boot code "base norestore" to check your findings against a "plain" TC system.

Furthermore, ICONS is "controlled" by the following piece of code from '/etc/init.d/tc-config':
Code: [Select]
ICONS="wbar"
TCEWBAR="/usr/local/tce.wbar"
if [ -z "$NOICONS" ] && [ -f /usr/share/wbar/dot.wbar ]; then
  echo "$ICONS" > /etc/sysconfig/icons
fi 
As you can see the setting is stored in '/etc/sysconfig/icons' and is taken from there on occasion by other scripts.

Please note that '/etc/sysconfig/icons' contains pretty much all stuff related to boot codes and initial system setup. I highly recommend to grab yourself a cup of tea (or whatever else) and study this file and it's inter-working with other scripts really carefully. Since the shell under which all this gets executed has only fairly sparse documentation I'd suggest to use this one here instead.

I'm afraid this is all getting a bit off-topic (you might want to ask hats to split this thread) ...

Offline bigpcman

  • Hero Member
  • *****
  • Posts: 719
Re: wbar (and X.d) questions
« Reply #14 on: May 29, 2010, 09:10:32 PM »
I'm still not clear what you are trying to achieve by running something like su -c CMD tc but I think your system is "playing up".

The extracts I provided yesterday were from the same system that I've used to produced the following:
Code: [Select]
tc@box:~$ version
tinycore_3.0alpha4

tc@box:~$ echo "ICONS=$ICONS ENV=$ENV BACKUP=$BACKUP DESKTOP=$DESKTOP"  
ICONS=wbar ENV=/home/tc/.ashrc BACKUP=1 DESKTOP=flwm_topside

tc@box:~$ su -c "echo \"ICONS=$ICONS ENV=$ENV BACKUP=$BACKUP DESKTOP=$DESKTOP\"" tc
ICONS=wbar ENV=/home/tc/.ashrc BACKUP=1 DESKTOP=flwm_topside

tc@box:~$ sudo grep tc /etc/sudoers
tc      ALL=(ALL) NOPASSWD: ALL
tc@box:~$ sudo -u tc echo "ICONS=$ICONS ENV=$ENV BACKUP=$BACKUP DESKTOP=$DESKTOP"
ICONS=wbar ENV=/home/tc/.ashrc BACKUP=1 DESKTOP=flwm_topside

If you don't get the same result try booting again with boot code "base norestore" to check your findings against a "plain" TC system.

Furthermore, ICONS is "controlled" by the following piece of code from '/etc/init.d/tc-config':
Code: [Select]
ICONS="wbar"
TCEWBAR="/usr/local/tce.wbar"
if [ -z "$NOICONS" ] && [ -f /usr/share/wbar/dot.wbar ]; then
  echo "$ICONS" > /etc/sysconfig/icons
fi  
As you can see the setting is stored in '/etc/sysconfig/icons' and is taken from there on occasion by other scripts.

Please note that '/etc/sysconfig/icons' contains pretty much all stuff related to boot codes and initial system setup. I highly recommend to grab yourself a cup of tea (or whatever else) and study this file and it's inter-working with other scripts really carefully. Since the shell under which all this gets executed has only fairly sparse documentation I'd suggest to use this one here instead.

I'm afraid this is all getting a bit off-topic (you might want to ask hats to split this thread) ...


Maro you are a wealth of information. Thank you for providing your advice.

Here's what I get in the console as root user:
Code: [Select]

root@testbox:/home/tc# echo $ICONS

root@testbox:/home/tc# sudo -u tc echo $ICONS

root@testbox:/home/tc# su -c echo $ICONS tc

root@testbox:/home/tc#
Here's what I get in the console as tc user:
Code: [Select]
tc@testbox:~$ echo $ICONS
wbar
tc@testbox:~$

edit: tc3alpha4 iso base norestore with sudoers modified to [tc      ALL=(ALL) NOPASSWD: ALL]
edit2: I just noticed I should have been using the double quotes in the "su" command as follows: su -c "echo $ICONS" tc
        However, the results are the same.
« Last Edit: May 29, 2010, 09:36:56 PM by bigpcman »
big pc man