Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

42 lines (35 sloc) 0.742 kb
#include <errno.h>
#include "xbacklight.h"
int get_screen_xbacklight_value() {
FILE * f = popen( "xbacklight", "r" );
if ( f == 0 ) {
fprintf( stderr, "Could not execute\n" );
return -1;
}
const int BUFSIZE = 1000;
char buf[ BUFSIZE ];
while( fgets( buf, BUFSIZE, f ) ) {
;
}
pclose( f );
return atoi(buf);
}
int set_screen_xbacklight_value(int backlight) {
char name[256];
snprintf(name, 256, "xbacklight -set %.3d\n", backlight);
FILE * f = popen(name , "r" );
if ( f == 0 ) {
fprintf( stderr, "Could not execute\n" );
return -1;
}
const int BUFSIZE = 1000;
char buf[ BUFSIZE ];
errno = 0;
while( fgets( buf, BUFSIZE, f ) ) {
;
}
if (errno != 0)
perror("xbacklight");
pclose( f );
return 1;
}
Jump to Line
Something went wrong with that request. Please try again.