Browse Source

initial commit

master
Milan 2 years ago
commit
629ce8c2a8
  1. 10
      Makefile
  2. 5
      x330backlight-sync
  3. 38
      x330backlight.cpp

10
Makefile

@ -0,0 +1,10 @@
ifeq ($(PREFIX),)
PREFIX := /usr/local
endif
all:
g++ -lhidapi-hidraw x330backlight.cpp -o x330backlight
install: all
install -Dm755 x330backlight $(PREFIX)/bin/x330backlight
install -Dm755 x330backlight-sync $(PREFIX)/bin/x330backlight-sync

5
x330backlight-sync

@ -0,0 +1,5 @@
#!/usr/bin/env bash
while inotifywait -qq -e modify /sys/class/backlight/acpi_video0/actual_brightness
do
x330backlight $(cat /sys/class/backlight/acpi_video0/actual_brightness)
done

38
x330backlight.cpp

@ -0,0 +1,38 @@
#include <stdio.h>
#include <stdlib.h>
#include <hidapi/hidapi.h>
#include <sstream>
#include <string>
#include <iostream>
#define MAX_STR 255
int main(int argc, char* argv[])
{
int brightness;
std::stringstream(argv[1]) >> brightness;
brightness++;
brightness *= 0xF;
int res;
unsigned char buf[2];
wchar_t wstr[MAX_STR];
hid_device *handle;
int i;
// Initialize the hidapi library
res = hid_init();
// Open the device using the VID, PID,
// and optionally the Serial number.
handle = hid_open(0x10c4, 0x83ce, NULL);
buf[0] = 0x06;
buf[1] = brightness;
res = hid_write(handle, buf, 2);
res = hid_exit();
return 0;
}
Loading…
Cancel
Save