Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Sun 17 Nov 2019, 14:40
All times are UTC - 4
 Forum index » House Training » Users ( For the regulars )
Can desktop icons be changed based on an event?
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [7 Posts]  
Author Message
kirk22

Joined: 03 May 2007
Posts: 15

PostPosted: Thu 10 May 2007, 08:40    Post subject:  Can desktop icons be changed based on an event?  

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
Back to top
View user's profile Send private message 
Dougal


Joined: 19 Oct 2005
Posts: 2504
Location: Hell more grotesque than any medieval woodcut

PostPosted: Thu 10 May 2007, 09:21    Post subject:  

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.

_________________
What's the ugliest part of your body?
Some say your nose
Some say your toes
But I think it's your mind
Back to top
View user's profile Send private message 
Flash
Official Dog Handler


Joined: 04 May 2005
Posts: 13363
Location: Arizona USA

PostPosted: Thu 10 May 2007, 09:55    Post subject:  

Way cool idea. Perhaps it could be incorporated into Puppy so that the "browse" icon lights up or changes color or something when Puppy has established a connection to the internet.
Back to top
View user's profile Send private message 
kirk22

Joined: 03 May 2007
Posts: 15

PostPosted: Thu 10 May 2007, 11:00    Post subject:  

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:
#!/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
Back to top
View user's profile Send private message 
Dougal


Joined: 19 Oct 2005
Posts: 2504
Location: Hell more grotesque than any medieval woodcut

PostPosted: Thu 10 May 2007, 15:40    Post subject:  

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.


You will have to change the icon to the "off" icon at bootup, since this sets the "on" icon permanently.

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:
echo -e "$HEAD\n<Path>/usr/bin/mybinary</Path>\n<Icon>$MYICON</Icon>\n$TAIL" | rox -R


(MYICON is set to the appropriate icon)

Note that to do this, you'll probably need the code that runs in the background, getting the connection running, to start with
Code:
until pidof ROX-Filer >/dev/null ; do sleep 1 ; done

(so it waits for rox to start before running the SOAP command)
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
Back to top
View user's profile Send private message 
Dougal


Joined: 19 Oct 2005
Posts: 2504
Location: Hell more grotesque than any medieval woodcut

PostPosted: Fri 11 May 2007, 06:42    Post subject:  

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:
Code:

# 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


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.

_________________
What's the ugliest part of your body?
Some say your nose
Some say your toes
But I think it's your mind
Back to top
View user's profile Send private message 
kirk22

Joined: 03 May 2007
Posts: 15

PostPosted: Fri 11 May 2007, 08:23    Post subject:  

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.
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [7 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » House Training » Users ( For the regulars )
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0430s ][ Queries: 12 (0.0075s) ][ GZIP on ]