Question

Hey guys, I have written a program to act as a keyboard backlight controller for my MacBook Pro that runs Arch, just like there is natively in OS X. The program itself works great, but the rc.d script I provide with the Arch program package, doesn't seem to open the program correctly ... or so I think.

The source to the Arch package can be found here (rc.d script and PKGBUILD file). I have added "mbpkbdbacklightctl" to the line with daemons in my /etc/rc.conf.

What happens is, that upon start up, I see that the rc.d script starts the program is started without errors, and the backlight on the keyboard is lit on which means the program is also run properly, but then when gdm starts to log in to gnome, the program seems to already have been terminated. I havent been able to find any errors logged, but the program will turn off the backlight if no keyboard or mouse events are registered in 20 or more seconds and turn it back on when one it registered, and this doesnt happen at the gdm and neither in gnome. Also, when I reach gnome and do a pidof -o %PPID /usr/bin/mbpkbdbacklightctl, it returns nothing indicating that the program has been terminated. When gnome is started, I have to restart the rc.d script to make things run properly.

I cant seem to get a grasp on what happens to the program since it is terminated. The source to the program can be found here, though, I believe that the error is in the rc.d script and that it might not start the program properly for it to "survive" through gdm start-up.

Any ideas to what can be going on?

Regards, Chris Buchholz

Was it helpful?

Solution

If you read the source code for mbpkbdbacklightctl.cpp you will see these lines:

95  std::string the_display = ":0.0";
96  Display *x11_display = XOpenDisplay(the_display.c_str());
97  if(x11_display != NULL) {

So it will fail if there is no active X server, this means that you have to start this script after X session starts. So you have to put your script under /etc/X11/xinit/xinitrc.d

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top