Hello all,
I managed to get puppy 2.15CE running with OpenVPN, rdesktop and tightvnc to a server. So far so good but I'd like to put some icing on the cake.
It could take up to 5 minutes for the VPN to be established due to dynamic IPs. I'd like to find some way to notify the user that the VPN link is up and the coolest way I can think of is to change the desktop icon from a grey icon to full color. Is there any way to do that in Icewm?
Kirk
Can desktop icons be changed based on an event?
- Dougal
- Posts: 2502
- Joined: Wed 19 Oct 2005, 13:06
- Location: Hell more grotesque than any medieval woodcut
Yes, when the vpn is established, I assume a script will finish running or something, right? All you need to do is add the appropriate SOAP code for changing the Rox icon (the "SetIcon" command).
The Rox manual has info on that.
The Rox manual has info on that.
What's the ugliest part of your body?
Some say your nose
Some say your toes
But I think it's your mind
Some say your nose
Some say your toes
But I think it's your mind
Thanks. I pieced the following code together from the ROX manual. It works a treat. I'm just fumbling around here so if there's an easier way, I'm all ears.
Code: Select all
#!/bin/sh
rox --RPC << EOF
<?xml version="1.0"?>
<env:Envelope xmlns:env="http://www.w3.org/2001/12/soap-envelope">
<env:Body xmlns="http://rox.sourceforge.net/SOAP/ROX-Filer">
<SetIcon>
<Path>/usr/bin/mybinary</Path>
<Icon>/usr/local/lib/X11/pixmaps/disk.xpm</Icon>
</SetIcon>
</env:Body>
</env:Envelope>
EOF
- Dougal
- Posts: 2502
- Joined: Wed 19 Oct 2005, 13:06
- Location: Hell more grotesque than any medieval woodcut
You will have to change the icon to the "off" icon at bootup, since this sets the "on" icon permanently.kirk22 wrote:Thanks. I pieced the following code together from the ROX manual. It works a treat. I'm just fumbling around here so if there's an easier way, I'm all ears.
I put the first half of the SOAP code into a variable HEAD, the second half into TAIL and then whenever I need to change an icon I just do
Code: Select all
echo -e "$HEAD\n<Path>/usr/bin/mybinary</Path>\n<Icon>$MYICON</Icon>\n$TAIL" | rox -R
Note that to do this, you'll probably need the code that runs in the background, getting the connection running, to start with
Code: Select all
until pidof ROX-Filer >/dev/null ; do sleep 1 ; done
Then run the command that sets the "off" icon
(this will make the setting up of connection delayed by a few seconds...)
What's the ugliest part of your body?
Some say your nose
Some say your toes
But I think it's your mind
Some say your nose
Some say your toes
But I think it's your mind
- Dougal
- Posts: 2502
- Joined: Wed 19 Oct 2005, 13:06
- Location: Hell more grotesque than any medieval woodcut
I've had another idea: you can create a simple daemon, run from xinitrc, that checks the network status and updates the icon accordingly...
(Note that is HAS to run from xinitrc, so that it can interact with Rox. Running it from somewhere like rc.local will not work, even if you wait for Rox to start! It seems like they need to both be sub-processes of the same X session...)
Here's an example of how it should look:
Note 1: when you set MYICON, you can also set the interval to a different value.
For example, when the status is "off" you can set it to 10, so it checks more frequently, but when it's on, set it to a larger value, so it doesn't check so frequently.
Note 2: You can also just terminate the script the moment the network is up - I added a line to uncomment.
(Note that is HAS to run from xinitrc, so that it can interact with Rox. Running it from somewhere like rc.local will not work, even if you wait for Rox to start! It seems like they need to both be sub-processes of the same X session...)
Here's an example of how it should look:
Code: Select all
# time (in seconds) to pause between checks
INTERVAL=60
# icons to use
ONICON=
OFFICON=
# application the icon is assigned to
MYAPP=/usr/bin/myapp
# set initial value of status to nothing (so first round of loop will set icon)
OLDSTATUS=""
# SOAP code for setting icon:
HEAD='<?xml version="1.0"?>
<env:Envelope xmlns:env="http://www.w3.org/2001/12/soap-envelope">
<env:Body xmlns="http://rox.sourceforge.net/SOAP/ROX-Filer">
<SetIcon>'
TAIL=' </SetIcon>
</env:Body>
</env:Envelope>'
# function to set the icon
# application and icon passed as parameters
set_icon(){
echo -e "$HEAD\n <Path>$1</Path>\n <Icon>$2</Icon>\n$TAIL" | rox -R
}
# wait for Rox to start running.
until pidof ROX-Filer >/dev/null
do sleep 1
done
##### run the loop
while true ; do
# check the network status : should tell you if it's on or off
NEWSTATUS=(results of your test)
# see if status has changed
if [ "$NEWSTATUS" != "$OLDSTATUS" ] ;then # need to change icon
if [ "$NEWSTATUS" = "off" ] ;then
MYICON=$OFFICON
else
MYICON=$ONICON
fi
# set the icon
set_icon $MYAPP $MYICON
# update the old status
OLDSTATUS="$NEWSTATUS"
fi
# uncomment the following line if to end script when connection is established
# [ "$NEWSTATUS" = "on" ] && break
# wait before checking again
sleep $INTERVAL
done
For example, when the status is "off" you can set it to 10, so it checks more frequently, but when it's on, set it to a larger value, so it doesn't check so frequently.
Note 2: You can also just terminate the script the moment the network is up - I added a line to uncomment.
What's the ugliest part of your body?
Some say your nose
Some say your toes
But I think it's your mind
Some say your nose
Some say your toes
But I think it's your mind
Wow. I'll have to incorporate something like that in the next version.
I ended up loading OpenVPN at the end of .xinitrc. The OpenVPN start script sets the 'off' icons and when a connection is established another script sets the 'on' icons. The major drawback is that it doesn't handle real time updates and changes like your code.
Thanks again for the example. That will certainly come in handy.
I ended up loading OpenVPN at the end of .xinitrc. The OpenVPN start script sets the 'off' icons and when a connection is established another script sets the 'on' icons. The major drawback is that it doesn't handle real time updates and changes like your code.
Thanks again for the example. That will certainly come in handy.