From: Todd on
Hi All,

I have a bash script to read my UPS' line voltage:

#!/bin/bash
X=1
while [ "$X" = "1" ]
do
LineVoltage="`/etc/rc.d/init.d/apcupsd status | \
grep -e "LINEV :"`"
echo $LineVoltage
sleep 5
done

Is there is a way to make an updatable pop up with
zenity or the like?

Many thanks,
-T
From: James Michael Fultz on
* Todd <todd(a)invalid.com>:
> Hi All,
>
> I have a bash script to read my UPS' line voltage:
>
> #!/bin/bash
> X=1
> while [ "$X" = "1" ]
> do
> LineVoltage="`/etc/rc.d/init.d/apcupsd status | \
> grep -e "LINEV :"`"
> echo $LineVoltage
> sleep 5
> done
>
> Is there is a way to make an updatable pop up with
> zenity or the like?

Yes, though it seems not immediately documented.

<http://muzso.hu/2009/05/26/zenity-gtk-dialogs-for-shell-scripts>

The following is a basic example of how it could work.

#!/bin/bash
exec 3> >(zenity --notification --listen)
X=1
while [ "$X" = "1" ]
do
LineVoltage="`/etc/rc.d/init.d/apcupsd status | \
grep -e "LINEV :"`"
echo message:$LineVoltage
sleep 5
done
exec 3>&-
From: Todd on
On 02/08/2010 09:08 PM, James Michael Fultz wrote:

> #!/bin/bash
> exec 3> >(zenity --notification --listen)
> X=1
> while [ "$X" = "1" ]
> do
> LineVoltage="`/etc/rc.d/init.d/apcupsd status | \
> grep -e "LINEV :"`"
> echo message:$LineVoltage
> sleep 5
> done
> exec 3>&-

Thank you!
From: Todd on
On 02/08/2010 09:08 PM, James Michael Fultz wrote:
> #!/bin/bash
> exec 3> >(zenity --notification --listen)
> X=1
> while [ "$X" = "1" ]
> do
> LineVoltage="`/etc/rc.d/init.d/apcupsd status | \
> grep -e "LINEV :"`"
> echo message:$LineVoltage
> sleep 5
> done
> exec 3>&-


I had to add ">&3" to the echo line to
remove the echo from the command line.

Now I get:

** (zenity:6403): WARNING **: Notification framework not available

:'(

-T


#!/bin/bash
exec 3> >(zenity --notification --listen)
X=1
while [ "$X" = "1" ]
do
LineVoltage="`/etc/rc.d/init.d/apcupsd status | \
grep -e "LINEV :"`"
echo message:$LineVoltage >&3
sleep 5
done
exec 3>&-
From: James Michael Fultz on
* Todd <todd(a)invalid.com>:
> On 02/08/2010 09:08 PM, James Michael Fultz wrote:
>> #!/bin/bash
>> exec 3> >(zenity --notification --listen)
>> X=1
>> while [ "$X" = "1" ]
>> do
>> LineVoltage="`/etc/rc.d/init.d/apcupsd status | \
>> grep -e "LINEV :"`"
>> echo message:$LineVoltage
>> sleep 5
>> done
>> exec 3>&-
>
>
> I had to add ">&3" to the echo line to
> remove the echo from the command line.

Oops! Yes, I overlooked that.

> Now I get:
>
> ** (zenity:6403): WARNING **: Notification framework not available

Oh, well. I'm not sure when it was added to zenity. I have version
2.28.0 here.