LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-08-2005, 06:08 AM   #1
dakien
LQ Newbie
 
Registered: Jun 2005
Posts: 2

Rep: Reputation: 0
daemon exec X-programm


hi folks,

I have written a acpi-daemon that polls my batterylevel. The daemon should start another programm, when my battery is low. Therefore I used "system() " to call my qt-programm which just displays a small window with a button.
I have written the initscript for the daemon and everything works fine, except that there's no popup window.

I don't really now why, because if I start the daemon by hand in a terminal and send to background, the external qt-program is called and there's displayed the warning window.

Is it because no terminal is associated for daemon ??

Anybody a solution?
thx
 
Old 06-08-2005, 07:00 AM   #2
kees-jan
Member
 
Registered: Sep 2004
Distribution: Debian, Ubuntu, BeatrIX, OpenWRT
Posts: 273

Rep: Reputation: 30
Basically, daemons are system services that are running no matter what, so in general they cannot produce output. Not to a terminal, not to an X-server. Simply because it may not be running at that particular time, or it may not have permission to open a window or whatever.

The "nice" thing of solving this problem, is having the deamon not open an x-window. Instead, you write an x-applet that sits in your panel (for example), and connects to the daemon, receiving an update when the power is low. Then it can open a window (since it already has permission to do so.

Then again, there are already lots of applications that do just that.

Anyway. To solve your original problem, the daemon would have to know to which X-server to connect (i.e. its "DISPLAY" environment variable should be set correctly) and it should have permission to show a window. Giving permission can be done in a multitude of ways. One would be to have the daemon run as the same user that is currently logged in (i.e. you), or you could run "xhost +", basically giving anyone permission. Aternatively, you should look into xauth.

When starting the daemon from the shell, both conditions (permission and correct DISPLAY environment variable) are satisfied automatically, which is why it works then. For daemon mode, there is a little bit more work to do.

Groetjes,

Kees-Jan
 
Old 06-08-2005, 07:57 AM   #3
dakien
LQ Newbie
 
Registered: Jun 2005
Posts: 2

Original Poster
Rep: Reputation: 0
thx,



i'll try to do it the nice way, the other stuff is a nice workaround but quite unsafety.
How can I establish a connection to the daemon, since I have closed all filedescriptors. My daemon just posts logs via syslog.h commands.
Do I have to realize this by sockets?
 
  


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
how to compile programm for suse 9.3? moog Linux - Newbie 6 10-16-2005 07:42 PM
Programm like DriveImage? morto Linux - Software 2 02-01-2005 09:18 AM
how to send a pw to a programm?! stefanero Programming 3 04-19-2004 02:25 PM
What Chess Programm Should I Use?? Electronkz Linux - Software 2 04-15-2004 09:22 PM
run programm on startup ichbinesderelch Linux - General 6 08-18-2003 12:26 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:06 PM.

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