[Lubuntu] Capture "wall" messages for display on desktop?
John Hupp
lubuntu at prpcompany.com
Tue Oct 30 20:42:55 UTC 2012
On 10/27/2012 5:06 PM, John Hupp wrote:
>
> On 10/27/2012 3:50 PM, John Hupp wrote:
>>
>> On 10/27/2012 1:36 AM, Jonathan Marsden wrote:
>>> John,
>>>
>>> On 10/26/2012 04:52 PM, John Hupp wrote:
>>>
>>>> The only problem is that it only posts warning messages to the
>>>> wall command, which outputs only to console sessions. ...
>>> In my experience, apcupsd is a *lot* more configurable than that -- did
>>> you read its documentation or its scripts before posting?
>>>
>>> You can create scripts for each class of event (onbattery, offbattery,
>>> etc.) handled by /etc/apcupsd/apccontrol that do *whatever* you want
>>> them to do -- turn the message into audio and speak it using a speech
>>> synth, if you really want :)
>>>
>>> You don't even need to edit /etc/apcupsd/apccontrol to do this, it will
>>> notice that your custom scripts exist, and use them instead of its
>>> internal default actions.
>>>
>>> Jonathan
>>>
>>>
>> [Newbie sent scurrying to dig into the "Customizing Event Handling"
>> section of the apcupsd manual, and for some general research on
>> desktop notificationmethods.]
>>
>> OK, I found out that notify-send is a common desktop notification
>> tool, and that one installs the libnotify-bin package to get it. I
>> did so.
>>
>> I have now also created the shell script /etc/apcupsd/annoyme. It is
>> owned by root. I used the Properties: Permissions sheet to give
>> everyone Read & Write permission, and marked it executable.
>>
>> The contents of annoyme:
>> #!/bin/sh
>> notify-send -u critical -t 5000 "The computer is running on
>> battery." "It will shut down shortly. Please save your work and log off."
>> exit 0
>>
>> Running this script manually pops up a nice warning on the desktop
>> for 5 seconds.
>>
>> But when I pull the plug for a UPS test, I do not get any desktop
>> warnings, though apcupsd powers down the PC when expected. But if I
>> log into a console during that time, I see the default onbattery and
>> annoyme wall messages. As I understand it, apccontrol should run my
>> custom annoyme script before running its own default annoyme command.
>>
>> I have not modified apccontrol.
>>
>> Anyone recognize what the problem is?
>>
>> --------------------------
>> I could add parameters from my current configured-for-testing
>> apcupsd.conf:
>>
>> UPSCABLE usb
>> UPSTYPE usb
>> DEVICE
>> LOCKFILE /var/lock
>> SCRIPTDIR /etc/apcupsd
>> PWRFAILDIR /etc/apcupsd
>> NOLOGINDIR /etc
>>
>> ONBATTERYDELAY 6
>> BATTERYLEVEL 5
>> MINUTES 3
>> TIMEOUT 60
>> ANNOY 10
>> ANNOYDELAY 20
>> NOLOGON always
>> KILLDELAY 0
>>
>> NETSERVER on
>> NISIP 0.0.0.0
>> NISPORT 3551
>> EVENTSFILE /var/log/apcupsd.events
>> EVENTSFILEMAX 10
>>
>> UPSCLASS standalone
>> UPSMODE disable
>>
>> STATTIME 0
>> STATFILE /var/log/apcupsd.status
>> LOGSTATS off
>> DATATIME 0
>
> A further test: From a terminal command line I ran:
>
> /etc/apcupsd/apccontrol "annoyme" "" 1 0
>
> And my notify-send desktop notification displayed as envisioned.
I found out that the issue is related to the fact that the apccontrol
script called by the apcupsd daemon runs as root, and
DBUS_SESSION_BUS_ADDRESS is not available to root, which means that the
script does not know where the notify-send output should be displayed.
There are work-arounds, but I did not understand how to use them in
Lubuntu. The more elaborate solutions use functions that sift for the
current user information and then effectively run the command of
interest (notify-send) as that user.
The simplest looking solution, if it works, relies on the procedure for
running GUI apps via cronjobs. The reference is to
https://help.ubuntu.com/community/CronHowto#GUI%20Applications. But even
though the information is there in black-and-white, I didn't understand
how to do it.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/lubuntu-users/attachments/20121030/965da90b/attachment-0001.html>
More information about the Lubuntu-users
mailing list