August 29, 2014

Run script as root after X starts

Hello fellow sysadmins

The problem im having is my laptop will boot up without anyone keyboard backlight but with screen at max brightness. As soon as X starts and I get the login screen, my keyboard backlight is at full brightness too.

I found the "echo # > " one liner that works well on tuning my screen brightness and keyboard brightness, but it does have an effect if I add it to rc.local because X starts and everything gets reset. I've tried putting a sleep in my screen and running it in the background so rc.local can execute, the x session can start and I can login and the timer would be up and the script would run, but no luck.

The distro im currently using is Ubuntu. After I can get Ubuntu to run on this laptop the way I want it, im going to move onto other distros. So what I really need to know is how do I run a script after login but AS ROOT because these commands request root to be able to echo the value to the acpi_video0/brightness file or keyboard backlight file.

Any help would be great. Spent two days on this already and havent gotten anywhere.

Click Here!