Giter Club home page Giter Club logo

x2x0-agan's Introduction

x2x0-agan

Linux driver for agan x220 / x230 fhd mod

Requires nodejs, node-hid and inotifywait.

Usage : while inotifywait -qq -e modify /sys/class/backlight/acpi_video0/actual_brightness ; do ./setbrightness.js; done

x2x0-agan's People

Contributors

boutch55555 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

x2x0-agan's Issues

Windows version

Inspired by the Linux
requires a few Python components (pip install x)

#script that changes brightness on 51NB thinkpad X230 X330 FHD 13.3" LCD modification
#detects changes in Windows system brightness and sends a command to the LCD driver
#change vendor_id and product_ID to fit your hardware device under Device Manager->Human Interface Devices if it doesn't work, also double check soldering
#also turns off monitor on minimum setting



import subprocess
import pywinusb.hid as hid
import wmi
import win32gui
import win32con
import time
from os import getpid, system
from threading import Timer

screenOff = "asd"
   
def sample_handler(data):
    print("Raw data: {0}".format(data))



#turn off LCD
def turnoffLCD():
	def force_exit():
		pid = getpid()
	
	t = Timer(1, force_exit)
	t.start()
	SC_MONITORPOWER = 0xF170
	win32gui.SendMessage(win32con.HWND_BROADCAST, win32con.WM_SYSCOMMAND, SC_MONITORPOWER, 2)
	t.cancel()

#sends HID command between 0-255 to USB LCD controller 
def updateBrightness(brightnesslevel):
    filter = hid.HidDeviceFilter(vendor_id = 0x10C4, product_id = 0x83CE)
    hid_device = filter.get_devices()
    device = hid_device[0]
    device.open()
    device.set_raw_data_handler(sample_handler)
    out_report = device.find_feature_reports()[0]
    cmd = (0,
    brightnesslevel,
    )
    buffer = [0x00] * 2
    i = 0
    for x in cmd:
        buffer[i] = x
        i += 1
    out_report.set_raw_data(buffer)
    out_report.send()
    device.close()

#detects changes in brightness 
def brightnessChangeDetect():
    global screenOff
    c = wmi.WMI(namespace='wmi')
    watcher = c.WmiMonitorBrightnessEvent.watch_for(
      notification_type="Modification",
      delay_secs=1
      )
    event_happened = watcher()
    brightnesslevel = int((event_happened.Brightness)*2.5)
    if brightnesslevel > 0:
        screenOff = 0
    if brightnesslevel == 0 and screenOff == 0:
        turnoffLCD()
        time.sleep(1)
        screenOff = 1
    updateBrightness(brightnesslevel)

#main program
while True:
    
    brightnessChangeDetect()




Do you have display problem in Linux?

Excuse me, I installed the agan's x230 fhd mod too, but my screen is often black after grub, and I have to use nomodeset kernel command line to get the screen work. But Ubuntu gets really slow after using nomodset. And I have tried a lot of method, all doesn't work. By the way, the screen works fine in Windows. I've tried on Ubuntu 18.04, debian stretch and debian buster, all the same problem. Thank you

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.