How to start my GUI program by a daemon?
Greetings
This is Chunhao, I need your help on my problem below:
I wrote a daemon named "key_captured", which is used to catch
some special key presses of Sony Vaio notebook, for instance, when
I press the "DVD" on the keyboard, the daemon will call the media
player "kaffeine", and if I press "Fn + F7", the daemon will show a
GUI named "display_switch", written with Qt by me.
I made a symbolic link of "key_captured" with the command:
#ln -s /usr/sbin/key_captured /root/.kde/Autostart/
so that this daemon starts automatically each time when X starts
(I'm using KDE). I find that this method can work fairly well,
"key_captured" can catch my key press and call the corresponding
GUI applications.
But now, for some reason, I need to add my "key_captured" into
system services to start the daemon automatically, instead of the
method by symbolic link. I find If the daemon is started by system
services, it can NOT catch my key presses under X-Window. I do not
know the exact reason, maybe there is some bug in my daemon
"key_captured", I'm using:
system("kaffeine &");
system("display_switch &");
to execute the GUI programs.
Would you please give me some suggestion on how to solving this
program? Should I use "fork"-like system calls to produce the GUI
process, and make it the child process of X?
Thanks
Best Regards
Chunhao
|