gxmessage/yaf-splash not displayed from script
gxmessage/yaf-splash not displayed from script
I have written a script that monitors the connection state of a VPN connection. It basically uses gxmessage to alert the user when the VPN tunnel drops.
I'm trying to call it from the "ip-up" script that automatically runs after vpn connects.
The problem is that the gxmessage doesn't display. The scripts are executing, and test code that prints out to a file from both scripts prints ok (echo "test text 3" >> /etc/ppp/test.out), but the gxmessages will not pop up on the user console.
What am I overlooking here?
Thanks in advance. I've been pulling my hair out for 6 hours on this so far ...
[Update]
WooHoo! I figured it out! gxmessage needed the "-display :0" switch if you are not directly executing the script from the console.
I'm trying to call it from the "ip-up" script that automatically runs after vpn connects.
The problem is that the gxmessage doesn't display. The scripts are executing, and test code that prints out to a file from both scripts prints ok (echo "test text 3" >> /etc/ppp/test.out), but the gxmessages will not pop up on the user console.
What am I overlooking here?
Thanks in advance. I've been pulling my hair out for 6 hours on this so far ...
[Update]
WooHoo! I figured it out! gxmessage needed the "-display :0" switch if you are not directly executing the script from the console.
Last edited by jafadmin on Sun 27 Apr 2014, 16:35, edited 2 times in total.
hmmm odd...but the really useful gxmessage was removed and I am not sure if it ever returned so it may be a hacky gtkdialog script as I use it from scripts all the time and never have had to add that parameter...or gtk has gone weird ...or bash has gone weird? or we have gone weird....
Heres a copy of the 'real' gxmessage.
mike
Heres a copy of the 'real' gxmessage.
mike
- Attachments
-
- gxmessage.tar.gz
- (30 KiB) Downloaded 126 times
The DISPLAY=:0 switch is needed if the script is started before X is started , fx from /etc/init.d/ directory .
Otherwise if dropped into /root/Startup it will start after X has started , so would not need the DISPLAY variable being set .
X will export DISPLAY variable systemwide when started .
Otherwise if dropped into /root/Startup it will start after X has started , so would not need the DISPLAY variable being set .
X will export DISPLAY variable systemwide when started .
Code: Select all
if test -z "$DISPLAY"; then
export DISPLAY=':0'
fi
Great. Here we go again . . .
Ok, so I got this brilliant idea to use yaf-splash (gtkdialog-splash) instead of gxmessage because I can have the notice appear at the top-center of the screen and exit with a mouse-over.
Works great from the command line.
Works great in a script clicked from roxfiler.
works great in a script called from another script clicked by roxfiler.
It doesn't work when called from the ip-up script used by pppd. gxmessage does, though.
I don't get it. There has to be something with permissions or context or scope or something that I can't see.
all the vpn processes run as root. . . .
any ideas?
Ok, so I got this brilliant idea to use yaf-splash (gtkdialog-splash) instead of gxmessage because I can have the notice appear at the top-center of the screen and exit with a mouse-over.
Works great from the command line.
Works great in a script clicked from roxfiler.
works great in a script called from another script clicked by roxfiler.
Code: Select all
yaf-splash -bg green -placement top -timeout 5 -display :0 -text " Your text goes here . . . "
I don't get it. There has to be something with permissions or context or scope or something that I can't see.
all the vpn processes run as root. . . .
any ideas?
Same reason I assume...its lauched before X... in this case you will need gtkdialog 4 options to see if you can use your display fix and hope that the awful yaf-splash script passes them on .... you could use the real yaf-splash but it does not support unicode which is why it should never have appeared in the first place..
Perhaps if binaries were actually what they appear to be, puppy would be more fun to write for
mike
Perhaps if binaries were actually what they appear to be, puppy would be more fun to write for
mike
No, neither of these are situations where scripts are being run before X. This problem appears with puppy fully booted.mikeb wrote:Ah ok ...though you still had the problem which karl referred to
mike
And in the gxmessage problem above, for whatever reason, you MUST put the display parameter in the command line or it won't display.
yaf-splash is the same utility that displays the "puppy saving" messages. Works great in that usage.
Haha. Ok, so on a lark I downloaded the source for yaf-splash and compiled it.mikeb wrote:No clues...I guess puppy gets stranger.... yaf-splash was a standalone binary so you are dealing with a script and gtkdialog pretending to be it.
mike
It works in the script. It only seems to do the one font though, or I'm not getting the syntax right for specifyimg a different one ...
So I figured out that the compiled binary for yaf-splash is still in puppy in the
/usr/X11R7/bin directory. With a little goofing around with parameters I was able to get a halfway decent result with the following:
Maybe not as pretty as the gtkdialog version, but at least I can get it to run from the ip-up script with no problem.
/usr/X11R7/bin directory. With a little goofing around with parameters I was able to get a halfway decent result with the following:
Code: Select all
/usr/X11R7/bin/yaf-splash -bg green -font "Monospace" -placement "top" -margin 15 -outline 0 -display :0 -timeout 5 -text " VPN Monitor is Running . . . "
yaf-splash was phased out not because it can only display pixmap fonts. In fact it can display scalable and TTF fonts easily. It was phased out because it doesn't support unicode.
Fatdog64 forum links: [url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Latest version[/url] | [url=https://cutt.ly/ke8sn5H]Contributed packages[/url] | [url=https://cutt.ly/se8scrb]ISO builder[/url]
Ah I missed that part. In fact, it is quite straightforward to enable yaf-splash to work with UTF-8 string (I just did that). As for the font, it is not chosen, it's because X font is not configured properly (AFAIK Puppy already comes with Dejavu? - which is quite decent).mikeb wrote:yes did mention that ...just also mentioned that ugly fonts seemed to be the ones chosen.
My historical knowledge of Puppy is quite weak since I joined when Puppy 2.x was already on the full swing; so I could be wrong here. But my guess is yaf-splash was chosen because early Puppies didn't include GTK at all (and yaf-splash only depends on xlib). The same reason that jwm was chosen.It was unmaintained for years too iirc..... good choice.
As for maintenance - it is such a small code and its functionality is more or less fixed; it doesn't require maintenance or new feature I compiled yaf-splash 1.02 "as is" (no patch etc) on x86_64, and ARM, no changes needed.
Fatdog64 forum links: [url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Latest version[/url] | [url=https://cutt.ly/ke8sn5H]Contributed packages[/url] | [url=https://cutt.ly/se8scrb]ISO builder[/url]
yaf-splash was introduced around puppy 2.17 iirc, last of the 2 series . GTK2 has been in puppy since at least 1.08.
Xdialog , gxmessage and gtkdialog were used and present before yaf splash. ...xmessage was retained rather than gxmessage cos it looked worse I assume.
So it was brought in when there were perfectly useable, visually pleasant tools, then thrown out again after many scripts were changed over and now there is a very hacky inefficient script to replace it and a series of confusing symlinks and a half hidden original binary.... all seems like a waste of peoples time thats all.
mike
wonder why thats was not done... perhaps because it required more than a bash script ?. In fact, it is quite straightforward to enable yaf-splash to work with UTF-8 string (I just did that)
Xdialog , gxmessage and gtkdialog were used and present before yaf splash. ...xmessage was retained rather than gxmessage cos it looked worse I assume.
So it was brought in when there were perfectly useable, visually pleasant tools, then thrown out again after many scripts were changed over and now there is a very hacky inefficient script to replace it and a series of confusing symlinks and a half hidden original binary.... all seems like a waste of peoples time thats all.
mike
Well, this didn't survive a reboot. It worked for hours, then for some inexplicable reason, just quit after a reboot.jafadmin wrote:So I figured out that the compiled binary for yaf-splash is still in puppy in the
/usr/X11R7/bin directory. With a little goofing around with parameters I was able to get a halfway decent result with the following:Maybe not as pretty as the gtkdialog version, but at least I can get it to run from the ip-up script with no problem.Code: Select all
/usr/X11R7/bin/yaf-splash -bg green -font "Monospace" -placement "top" -margin 15 -outline 0 -display :0 -timeout 5 -text " VPN Monitor is Running . . . "
Now I can't get it to work from a LiveCD.
Weirdness. Absolute weirdness ...
My best guess is that pppd is altering the environment in some way that breaks yaf-splash.
If I just execute the ip-up script stand-alone, yaf-splash works as expected. If the ip-up script is executed by the pppd process, it doesn't.
I'm gonna take up radish farming.