<commit_before>#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#define BRIGHTNESS_FILE "/sys/class/leds/smc::kbd_backlight/brightness"
#define MAX_BRIGHTNESS_FILE "/sys/class/leds/smc::kbd_backlight/max_brightness"

void error(const char *msg) {
    fprintf(stderr, msg);
    exit(1);
}

int read_int(const char *path) {
    FILE *f;
    char buffer[256];

    f = fopen(path, "r");
    if(f) {
        if(fgets(buffer, 256, f)) {
            fclose(f);
            return atoi(buffer);
        } else {
            fclose(f);
            error("Error reading\n");
        }
    } else {
        error("Error opening for reading\n");
    }
}

void write_int(const char *path, int value) {
    FILE *f;

    f = fopen(path, "w");
    if(f) {
        if(fprintf(f, "%i", value)) {
            fclose(f);
            return;
        } else {
            fclose(f);
            error("Error writing\n");
        }
    } else {
        error("Error writing\n");
    }
}

int get_brightness() {
    return read_int(BRIGHTNESS_FILE);
}

int get_max_brightness() {
    return read_int(MAX_BRIGHTNESS_FILE);
}

void set_brightness(int brightness) {
    write_int(BRIGHTNESS_FILE, brightness);
}

void inc_brightness() {
    int brightness, max_brightness;

    brightness = get_brightness();
    max_brightness = get_max_brightness();

    if(brightness < max_brightness) {
        set_brightness(brightness + 1);
    }
}

void dec_brightness() {
    int brightness;

    brightness = get_brightness();

    if(brightness > 0) {
        set_brightness(brightness - 1);
    }
}

void zero_brightness() {
    set_brightness(0);
}

void print_brightness() {
    int brightness;
    brightness = get_brightness();<commit_msg>Adjust keyboard brightness by powers of 2<commit_after>#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#define BRIGHTNESS_FILE "/sys/class/leds/smc::kbd_backlight/brightness"
#define MAX_BRIGHTNESS_FILE "/sys/class/leds/smc::kbd_backlight/max_brightness"

void error(const char *msg) {
    fprintf(stderr, msg);
    exit(1);
}

int read_int(const char *path) {
    FILE *f;
    char buffer[256];

    f = fopen(path, "r");
    if(f) {
        if(fgets(buffer, 256, f)) {
            fclose(f);
            return atoi(buffer);
        } else {
            fclose(f);
            error("Error reading\n");
        }
    } else {
        error("Error opening for reading\n");
    }
}

void write_int(const char *path, int value) {
    FILE *f;

    f = fopen(path, "w");
    if(f) {
        if(fprintf(f, "%i", value)) {
            fclose(f);
            return;
        } else {
            fclose(f);
            error("Error writing\n");
        }
    } else {
        error("Error writing\n");
    }
}

int get_brightness() {
    return read_int(BRIGHTNESS_FILE);
}

int get_max_brightness() {
    return read_int(MAX_BRIGHTNESS_FILE);
}

void set_brightness(int brightness) {
    int min_brightness = 0,
        max_brightness = get_max_brightness();
    if(brightness < min_brightness) brightness = min_brightness;
    if(brightness > max_brightness) brightness = max_brightness;
    write_int(BRIGHTNESS_FILE, brightness);
}

void inc_brightness() {
    int brightness = get_brightness();
    set_brightness(brightness == 0 ? 2 : brightness * 2);
}

void dec_brightness() {
    int brightness = get_brightness();
    set_brightness(brightness <= 2 ? 0 : brightness / 2);
}

void zero_brightness() {
    set_brightness(0);
}

void print_brightness() {
    int brightness;
    brightness = get_brightness();
{'fraction_non_alphanumeric': 0.13278827177896815, 'fraction_numerical': 0.007612066535100085, 'mean_word_length': 2.6427104722792607, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2046795', 'n_tokens_mistral': 1310, 'n_tokens_neox': 1216, 'n_words': 245}