[SOLVED] Just a simple background->foreground message system
[SOLVED] Just a simple background->foreground message system
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
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.
- L18L
- Posts: 3479
- Joined: Sat 19 Jun 2010, 18:56
- Location: www.eussenheim.de/
Re: Wanted - Just a simple background->foreground message sy
yad (yet another dialog)ocpaul20 wrote:..
can you point me to a useful resource to allow me to do this
...
or bacon (Basic to C converter, USEC for using C).
Info for both here in Programming.
Hi
I am no coder,
but how about something like this:
CatDude
.
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
.
[img]http://www.smokey01.com/CatDude/.temp/sigs/acer-futile.gif[/img]
- technosaurus
- Posts: 4853
- Joined: Mon 19 May 2008, 01:24
- Location: Blue Springs, MO
- Contact:
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
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
Joe
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
- technosaurus
- Posts: 4853
- Joined: Mon 19 May 2008, 01:24
- Location: Blue Springs, MO
- Contact:
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
and this to jwm_denotify
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)
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
Code: Select all
#!/bin/sh
rm $HOME/.jwmrc-notify && jwm -restart
[ `which $1` ] && $@
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].