#include
void usage()
{
fprintf(stderr, "Usage: lcd-brightness [value]\n");
}
int main(int argc, char *argv[])
{
FILE *fp;
int bright = 0;
const char *kFileName =
"/sys/class/backlight/acpi_video0/brightness";
switch (argc) {
case 1:
fp = fopen(kFileName, "r");
fscanf(fp, "%d", &bright);
printf("%d\n", bright);
break;
case 2:
fp = fopen(kFileName, "w");
bright = atoi(argv[1]);
fprintf(fp, "%d\n", bright);
break;
default:
usage();
return -1;
}
fclose(fp);
return 0;
}
sa-l salvam undeva in path cu numele brightness si acum putem mapa niste taste in kde care sa-l apeleze:
Iar ca si command scriem:
brightness $(expr $(brightness) - 1); kdialog
--passivepopup "Decrease Brightness to `cat
/sys/class/backlight/acpi_video0/brightness`" 1
- asta va da un frumos notification pop-up cand este apelat:Evident, trebuie mapata o combinatie si pentru Brightness up, care va face +1 in loc de -1 in comanda.