That is very clever. Thanks for sharing it with all of us. Daniel
William Shackleton <[email protected]> wrote: I wrote a similar program to control the brightness; it's a C program which sets the value and can be run through awesome's run command. The advantage of writing a simple C program to do this (and storing it in /usr/local/bin) is that the setuid bit can be set; this makes the program run as root no matter who runs it. Shell scripts can't have the setuid bit set. Here is the C program: #include<stdio.h> int main(int argc, char **argv) { if(argc <= 1) { return 0; } char* bright = argv[1]; char buf[300]; int n = snprintf(buf, 300, "sh -c \"echo %s > /sys/class/backlight/acpi_video0/brightness\"", bright); if(n < 0 || n > 300) { puts("Error formatting string\n"); return 1; } system(buf); return 0; } Compile this, copy it to /usr/local/bin, then run 'sudo chmod u+s <program>' to set the setuid bit, allowing it to run as root. Please feel free to use this program from your lua script. Will Shackleton On 25 October 2011 16:58, Daniel Hilst Selli <[email protected]> wrote: Hey, I build a little class to control brithness, but for it I have to read and write to /sys/class/backlight/acpi_video0/brightness. Only root can do it.. and the permissions are reset on reboot.. Here is the code http://ideone.com/lhFDQ Any idea?? Thanks! -- To unsubscribe, send mail to [email protected].
