[SOLVED] Just a simple background->foreground message system

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
ocpaul20
Posts: 260
Joined: Thu 31 Jan 2008, 08:00
Location: PRC

[SOLVED] Just a simple background->foreground message system

#1 Post by ocpaul20 »

Puppy 4.3.1 frugal

1) program A - running in background waiting for an event to happen.
a) when event happens, a message is created/appended to file ABC which is written to a directory which will be monitored by program B

2) program B - running in background
a) monitors a directory for a file "ABC" appearing. (ie event occurring)
b) When it appears, I want to put up a message dialogue on the screen with the text contents of the file ABC
c) The user acknowledges they have seen the message, clicks OK and the file ABC is deleted.
d) back to 2a)

I can program in php and get the part 1 of this sequence running. In the past I have programmed in C, so I can compile stuff.

It is the part 2 of this, the pop up of a dialogue box which I cannot manage on my own.

Does anyone have any ideas how I can implement this please,
or - can you point me to a useful resource to allow me to do this
or - maybe even write a small amount of code to accomplish it?

I would be most grateful for a bit of help please.
Thanks.
Paul
Last edited by ocpaul20 on Wed 29 Jun 2011, 09:39, edited 1 time in total.

User avatar
tasmod
Posts: 1460
Joined: Thu 04 Dec 2008, 13:53
Location: North Lincolnshire. UK
Contact:

#2 Post by tasmod »

Yaf splash for message.

Gtk dialog message box, spring to mind.

Google both in puppy search.

:lol: That's a bit of help as you requested 8)
Rob
-
The moment after you press "Post" is the moment you actually see the typso 8)

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

Re: Wanted - Just a simple background->foreground message sy

#3 Post by L18L »

ocpaul20 wrote:..
can you point me to a useful resource to allow me to do this
...
yad (yet another dialog)
or bacon (Basic to C converter, USEC for using C).
Info for both here in Programming. :)

User avatar
CatDude
Posts: 1563
Joined: Wed 03 Jan 2007, 17:49
Location: UK

#4 Post by CatDude »

Hi

I am no coder,
but how about something like this:

Code: Select all

#!/bin/sh

while sleep 15
do
if [ -f /path/to/your/file/ABC ]
 then
  MESSAGE=`cat /path/to/your/file/ABC`
  xmessage " `echo $MESSAGE`"
  rm -f /path/to/your/file/ABC
fi
done
CatDude
.
[img]http://www.smokey01.com/CatDude/.temp/sigs/acer-futile.gif[/img]

ocpaul20
Posts: 260
Joined: Thu 31 Jan 2008, 08:00
Location: PRC

#5 Post by ocpaul20 »

OK, thanks. i'll try those suggestions and see how I get on.

That's excellent. I tried Catdude's solution and it works a treat. Thank to all. A useful little utility.

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#6 Post by technosaurus »

I came up with a way to do this using only jwm here:
murga-linux.com/puppy/viewtopic.php?t=51200
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

ocpaul20
Posts: 260
Joined: Thu 31 Jan 2008, 08:00
Location: PRC

#7 Post by ocpaul20 »

I could not get your suggestion to work in my script which is almost an exact copy of the one above. It is not a problem though as the one using xmessage works fine. I would like to tweak the background and foreground colours of the xmessage box, but thats not a big deal either. Anyway, this gets started up at boot time and then sits there checking for the ABC file in /tmp every 30 seconds and deletes the file after showing the contents on the screen and being acknowledged.

Code: Select all

while sleep 30 
 do 
 if [ -f /tmp/ABC ] 
  then 
   MESSAGE=`cat /tmp/ABC` 
#   xmessage " `echo $MESSAGE`" 
  jwm -msg  " `echo $MESSAGE`"
   rm -f /tmp/ABC 
 fi 
 done

big_bass
Posts: 1740
Joined: Mon 13 Aug 2007, 12:21

#8 Post by big_bass »

Hey ocpaul20

you can modify this to your needs

it is in Xdialog and the box auto closes in 5 seconds
10 30 5000
the 10 and 30 are box sizes the 5000 is 5 seconds auto close
remove the 5000 part if you want to force the click

the cat isnt needed if you make the message a string

Code: Select all

#!/bin/bash 

# simulate message string for testing 
echo "whats up doc?" >/tmp/ABC
 
 
# delay preset  of 10 seconds 
sleep 10

if [ -f /tmp/ABC ]

do
 
     MESSAGE=$(</tmp/ABC)
   
     Xdialog --title "Checking" \
        	 --infobox "\n$MESSAGE\n" 10 30 5000
   
     rm -f /tmp/ABC
   fi
done


Joe

ocpaul20
Posts: 260
Joined: Thu 31 Jan 2008, 08:00
Location: PRC

#9 Post by ocpaul20 »

Thanks Big_Bass. It all helps to understand what is possible with all the different message methods.

Yes, I think I need the confirmation that the user has seen the message before I delete the message file ready for the next one.
Cheers,
Paul

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#10 Post by technosaurus »

it wasn't jwm -msg ...
I wrote 2 little scripts called jwm_notify and jwm_denotify that do the same thing without having to recompile jwm (it should work for all versions) ... it uses less resources than even xmessage (as low as 100k if you use dash as the shell) but can display icons, tooltips and multiple messages at a time

just copy this to jwm_notify

Code: Select all

#!/bin/sh 
echo '<JWM><Tray layout="vertical" halign="center" y="1" >' >$HOME/.jwmrc-notify 

while ([ $# -gt 1 ]) do 
SHORTMSG=${1:-JWM_NOTIFICATION} 
LONGMSG=${2:-$SHORTMSG} 
ICON=${3:-mini-dog.xpm} 
JWMNOTIFYCMD=${4:-exit} 
TIMEOUT=${5:-5} 
echo '<TrayButton label="'$SHORTMSG'" popup="'$LONGMSG'" icon="'$ICON'">exec:jwm_denotify' $JWMNOTIFYCMD'</TrayButton>' >>$HOME/.jwmrc-notify 
shift 4 
done 

echo '</Tray></JWM>' >>$HOME/.jwmrc-notify 
jwm -restart 
sleep $TIMEOUT 
[ -e $HOME/.jwmrc-notify ] && jwm_denotify exit
and this to jwm_denotify

Code: Select all

#!/bin/sh 
rm $HOME/.jwmrc-notify && jwm -restart 
[ `which $1` ] && $@
make them executable and put them in /usr/bin

the usage is
jwm_notify "short message to display" "long message that displays with mouseover" /path/to/icon.png "command_to_run_if_clicked" <seconds_to_display_msg(default is 5)>

If invoked with no args, these are the defaults:
SHORTMSG=${1:-JWM_NOTIFICATION}
LONGMSG=${2:-$SHORTMSG}
ICON=${3:-mini-dog.xpm}
JWMNOTIFYCMD=${4:-exit}
TIMEOUT=${5:-5}

I coded it in about 5 minutes, so I haven't made up a pet yet (I've been away from home for a couple months)
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

Post Reply