From 29877b7b775a0b7dc329c2fe191b8d04eb94aa54 Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Wed, 6 Sep 2017 14:01:48 -0400 Subject: Move C code to bin, Makefile, AGPL --- home/.bin/bri.c | 77 --------------------------------------------------------- 1 file changed, 77 deletions(-) delete mode 100755 home/.bin/bri.c (limited to 'home/.bin/bri.c') diff --git a/home/.bin/bri.c b/home/.bin/bri.c deleted file mode 100755 index d085814b..00000000 --- a/home/.bin/bri.c +++ /dev/null @@ -1,77 +0,0 @@ -#if 0 -set -e -bin=$(dirname $0) -cc -Wall -Wextra -pedantic $@ -o $bin/bri $0 -sudo chown root:root $bin/bri -sudo chmod u+s $bin/bri -exit -#endif - -// Backlight brightness control. - -#include -#include -#include -#include -#include -#include -#include - -static const char *CLASS = "/sys/class/backlight"; - -int main(int argc, char *argv[]) { - int error; - - if (argc < 2) errx(EX_USAGE, "usage: bri N | +... | -..."); - - error = chdir(CLASS); - if (error) err(EX_IOERR, "%s", CLASS); - - DIR *dir = opendir("."); - if (!dir) err(EX_IOERR, "%s", CLASS); - - struct dirent *entry; - while (NULL != (errno = 0, entry = readdir(dir))) { - if (entry->d_name[0] == '.') continue; - - error = chdir(entry->d_name); - if (error) err(EX_IOERR, "%s", entry->d_name); - break; - } - if (!entry) { - if (errno) err(EX_IOERR, "%s", CLASS); - errx(EX_CONFIG, "empty %s", CLASS); - } - - char *value = argv[1]; - - if (value[0] == '+' || value[0] == '-') { - FILE *actual = fopen("actual_brightness", "r"); - if (!actual) err(EX_IOERR, "actual_brightness"); - - unsigned int brightness; - int match = fscanf(actual, "%u", &brightness); - if (match == EOF) err(EX_IOERR, "actual_brightness"); - if (match < 1) err(EX_DATAERR, "actual_brightness"); - - size_t count = strnlen(value, 15); - if (value[0] == '+') { - brightness += 16 * count; - } else { - brightness -= 16 * count; - } - - char buf[15]; - snprintf(buf, sizeof(buf), "%u", brightness); - - value = buf; - } - - FILE *brightness = fopen("brightness", "w"); - if (!brightness) err(EX_IOERR, "brightness"); - - int count = fprintf(brightness, "%s", value); - if (count < 0) err(EX_IOERR, "brightness"); - - return EX_OK; -} -- cgit 1.4.1 93f77b10c3707'>unfollow)
Commit message (Expand)Author
2018-10-22Rename status and verbose tagsJune McEnroe
2018-09-16Revert "Race parallel connects"June McEnroe
2018-09-16Race parallel connectsJune McEnroe
2018-09-15Call tls_error when tls_connect_socket failsJune McEnroe
2018-09-15Try successive getaddrinfo resultsJune McEnroe
2018-09-15Render README from chatte.7June McEnroe
2018-09-14Factor out uiPrompt to call on nick changeJune McEnroe
2018-09-14Run test binaries with set -e and semicolonsJune McEnroe
2018-09-14Fail target when any test binary failsJune McEnroe
2018-09-14Run tests in default targetJune McEnroe
2018-09-14Add termEvent testsJune McEnroe
2018-09-14Check width of entire next word including codesJune McEnroe
2018-09-14Remove word handling from formatParseJune McEnroe
2018-09-14Apply consecutive formatting codes at onceJune McEnroe
2018-09-14Add tests for formatParseJune McEnroe
2018-09-13Preview with nick in input windowJune McEnroe
2018-09-13Never send PRIVMSG to TagStatus or TagVerboseJune McEnroe
2018-09-13Move color selection to format.cJune McEnroe
2018-09-13Fix len for format->split at end of stringJune McEnroe
2018-09-13Avoid uninitialized x in uiReadJune McEnroe
2018-09-13Add IRCDefault to colors enumJune McEnroe
2018-09-13Return a format->split even at the end of the stringJune McEnroe
2018-09-13Fix weird tab-complete after commaJune McEnroe
2018-09-13Rewrite UI againJune McEnroe
2018-09-12Add note about C-oJune McEnroe
2018-09-12Use formatParse split to position input cursorJune McEnroe
2018-09-12Factor out IRC formatting parsingJune McEnroe
2018-09-11Add /help equivalent to /manJune McEnroe
2018-09-11Don't render every PM as a pingJune McEnroe
2018-09-11Add urlOpenMatchJune McEnroe
2018-09-10Depend on man.sh for chroot.tar targetJune McEnroe
2018-09-10Set LESSSECURE=1 in man.shJune McEnroe
2018-09-10Add /man commandJune McEnroe
2018-09-10Install man page in chrootJune McEnroe
2018-09-10Install man pageJune McEnroe
2018-09-10Split keys into subsections and document colorsJune McEnroe
2018-09-10Add "blank" lines to chatte.1June McEnroe
2018-09-10Document key bindings in chatte.1June McEnroe
2018-09-08Document slash commands in chatte.1June McEnroe