LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-13-2015, 09:45 AM   #1
Gordoon
LQ Newbie
 
Registered: Jun 2015
Posts: 5

Rep: Reputation: 0
Desktop Notifications From Script


I am running an APC UPS for my home VOIP equipment. My Ubuntu 14.04 LTS computer with apsupsd is also plugged into this UPS, and I have modified apcupsd's onbattery script to shutdown the computer 1 minute after the UPS goes on battery. I want to send a desktop notification to warn when the computer is set to shut down. I have tried adding notify-send, zenity and xmessage lines to the onbattery script - they all send a notifications successfully when I run the onbattery script from terminal, but none work when apccontrol calls the script when the UPS goes on battery. The shutdown command in the onbattery script does work when I unplug the UPS. Why would notifications work when I run the script from terminal and not when script is run from apccontrol?

Code:
#!/bin/sh
#
# This shell script if placed in /etc/apcupsd
# will be called by /etc/apcupsd/apccontrol when the UPS
# goes on batteries.
#
sudo shutdown -P 1
exit 0
 
Old 06-14-2015, 08:15 PM   #2
ljb643
Member
 
Registered: Nov 2003
Posts: 524

Rep: Reputation: Disabled
To work, notify-send needs to send a message over the D-bus session bus to a notification server such as xfce4-notifyd. I don't know that much about it, but as far as I know it is not possible for a process which is not part of the session (a child or descendent of the first post-login process, or something like that) to do that. Your apcupsd runs outside the session, of course, so I don't think it has any way to talk to the session D-bus.

Different problem for Xmessage, but still, it would need to communicate with the X server, and permissions are set up to prevent that - using the Xauthority mechanism.

I realize this isn't much help at all.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Mirror Android Notifications on Linux Desktop with LinConnect LXer Syndicated Linux News 0 01-23-2014 04:10 PM
Shell script remote notifications a2326 Programming 21 11-22-2012 06:50 AM
LXer: Ubuntu Distributor Wants to Overhaul Linux Desktop Notifications LXer Syndicated Linux News 0 12-24-2008 03:20 AM
LXer: Gnubiff mail notifications on your desktop LXer Syndicated Linux News 0 08-22-2008 05:00 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:08 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration