Coder Social home page Coder Social logo

webketje / tuxedo-backlight-control Goto Github PK

View Code? Open in Web Editor NEW
43.0 3.0 9.0 156 KB

Minimal Linux (Debian) CLI & UI for TUXEDO / Clevo computers Keyboard Backlight

License: MIT License

Shell 20.30% Python 79.70%
clevo system76 sager tuxedo keyboard keyboard-backlight backlight

tuxedo-backlight-control's Introduction

Warning

The main keyboard backlight drivers this software provides control to and depends on previously developed at https://github.com/tuxedocomputers/tuxedo-keyboard have been brought under https://gitlab.com/tuxedocomputers/development/packages/tuxedo-drivers. While it will still work with the versions documented here, you may prefer to follow a newer setup procedure with the newest drivers. Development of a new version is planned but on hold.

TUXEDO Backlight Control

Minimal Linux distro CLI & UI for TUXEDO / Clevo computers Keyboard Backlight

This utility automates toggling keyboard backlight state for TUXEDO / Clevo computers on Linux. It can toggle the keyboard backlight off, set any modes defined here and set a single or multiple colors in Color (custom) mode. Default available colors are:

Available colors

Usage

UI

Search for TUXEDO Backlight Control from the Super (Start) menu.

CLI

backlight <command> [<option>]
Usage:
    -h, --help            Display this message

    -v, --version         Display app version

    ui                    Start the TUXEDO Backlight Control UI

    off                   Turn off keyboard backlight

    <mode>                Set the keyboard backlight to <mode>, one of:
                          breathe, cycle, dance, flash, random, tempo, wave

    color  <color>{1,4}   Set the keyboard backlight to a single color, one of:
                          white, silver, gray, yellow, orange, red, maroon, crimson,
                          fuchsia, purple, rose, cyan, turquoise, teal, blue, navy,
                          olive, lime, green, OR any valid color_name=hex_value pairs
                          defined in /etc/tuxedo-backlight-control/colors.conf

                          Alternatively, set the keyboard to 4 distinct colors,
                          in the order: left, center, right, extra. Only regions supported
                          by your keyboard will have effect.

    brightness            Set keyboard backlight brightness from 0-255

Custom Colors

As of 0.5 you can add your own custom colors, by creating a colors.conf file in a directory /etc/tuxedo-backlight-control. The file should have a format like:

my_color1=123456
my_color2=654321

The colors added here will be usable both in the CLI, and appear in the color dropdown in the UI. The values should be valid HEX colors, the keys can only contain alphanumeric characters.

Development of this software is done on Clevo N150-ZU / N151-ZU. Only single color mode is known to work for these the models.

Requirements

Required packages:

  • On Debian / Ubuntu / Linux Mint / PopOS : python3, python3-tk & policykit-1.
  • On Arch Linux / Manjaro : python, tk, polkit

On Debian you can verify if you have these by doing apt show <package-name>.

Required modules: tuxedo-keyboard
Download it from the repository or git clone as below:

git clone https://github.com/tuxedocomputers/tuxedo-keyboard.git
cd tuxedo-keyboard

Follow the instructions at tuxedo-keyboard under the section "The DKMS route"

Alternative options

On Arch Linux / Manjaro:

You can install the "tuxedo-keyboard" Package from the AUR

On Ubuntu (Linux Mint and Debian are not tested):

You can download and install the TUXEDO Keyboard .deb Package from http://deb.tuxedocomputers.com/ubuntu/pool/main/t/tuxedo-keyboard-dkms/


Install

Note: You might have to execute some of the commands below with sudo

Debian & derivatives (Ubuntu, Linux Mint, PopOS, ...)

Download and double-click the .deb package from the releases, or run

dpkg -i tuxedo-backlight-control_0.8.0-1_amd64.deb

from the folder where you downloaded it.

Arch Linux / Manjaro

Download the .pkg.tar.xz package from the releases, and run

pacman -U tuxedo-backlight-control-0.8.0-1.pkg.tar.xz

from the folder where you downloaded it.

Note: Although it is not recommended, you can install dpkg on Arch Linux, and install the .deb package there as you would on Debian OS'es.

Alternatively, you can use the AUR Package from Steven Seifried

Manual

git clone https://github.com/webketje/tuxedo-backlight-control.git
cd tuxedo-backlight-control
./pack.sh

In the dist folder you will find distribution packages built for the supported distro's. If none of these packages fits your distribution you can manually paste the contents of the src/ folder in your system root like so:

cd src
cp -r usr /usr
ln -s -f -T /usr/share/tuxedo-backlight-control/backlight.py /usr/local/bin/backlight

Uninstall:

Note: You might have to execute some of the commands below with sudo

Debian:

dpkg -r tuxedo-backlight-control

Arch Linux / Manjaro:

pacman -Rs tuxedo-backlight-control-git

Manual:

rm -rf /usr/share/tuxedo-backlight-control
unlink /usr/local/bin/backlight
unlink /usr/share/doc/tuxedo-backlight-control/copyright
unlink /usr/share/applications/tuxedo-backlight-control.desktop
unlink /usr/share/polkit-1/actions/webketje.tuxedo-backlight-control.policy
unlink /etc/bash_completion.d/backlight

Maintenance

Test locally

The backlight utility can be run directly from the repo root as $PWD/src/usr/share/tuxedo-backlight-control/backlight.py for quick tests

Run pylint

Run bin/pylint

Create a new release

  1. Change all references to <version> (readme, python, help)
  2. Run bin/pack
  3. Create release on GH and attach to generated archives in dist

tuxedo-backlight-control's People

Contributors

buddy-matt avatar jdtimmerman avatar konstantinhirschfeld avatar stevenseifried avatar webketje avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

tuxedo-backlight-control's Issues

Problems with the tuxedo_keyboard driver

I use Arch.
I installed the tuxedo_keyboard package from the AUR and the tuxedo-backlight-control package from here.
I explicitly loaded the module with modprobe.

$ sudo backlight color white

Traceback (most recent call last):
File "/usr/local/bin/backlight", line 43, in
backlight.state = 1
File "/usr/share/tuxedo-backlight-control/backlight_control.py", line 115, in state
self.set_device_param('state', value)
File "/usr/share/tuxedo-backlight-control/backlight_control.py", line 62, in set_device_param
fh = open(BacklightControl.DEVICE_PATH + prop, mode='r+')
FileNotFoundError: [Errno 2] No such file or directory: '/sys/devices/platform/tuxedo_keyboard/state'

Error when running "backlight ui"

Error:

Traceback (most recent call last):
  File "/usr/local/bin/backlight", line 36, in <module>
    init()
  File "/usr/share/tuxedo-backlight-control/ui.py", line 344, in init
    App(root)
  File "/usr/share/tuxedo-backlight-control/ui.py", line 58, in __init__
    initial_mode = backlight.mode.capitalize()
AttributeError: 'NoneType' object has no attribute 'capitalize'

Also, the app is not working when clicked at.

Investigate bash autocompletion for CLI interface

Would be cool if typing backlight <TAB><TAB> brought up all the commands.
Similarly for backlight color<TAB><TAB> and all the colors.

Something like

complete -p -W "ui off breathe cycle dance flash color random tempo wave -h --help" backlight
complete -p -W "red blue green lime gray white yellow olive cyan magenta pink (etc)" "backlight color"

Modes other than color don't work?

Before reporting the bug

  • I have looked at existing issues and none solved my problem
  • I have installed the tuxedo_keyboard driver and rebooted
  • I have made sure my laptop model is a TUXEDO / Clevo computer or derivative

Describe the bug

None of the modes work other than color, unless I'm doing something wrong. I tried changing the options in the UI, and nothing changed on my keyboard except the color of the whole keyboard when using the color option. Again in summary:

Works:

backlight off
backlight ui
backlight color blue

Does not work:

Using the UI to change to any mode. Or these probably pathetic attempts:

backlight color blue red blue red   # this just changes everything to blue, even though my keyboard should hypothetically have 3 regions
backlight dance
backlight color blue dance
backlight dance blue

Describe your OS environment

  • tuxedo-backlight-control version: 0.8.0
  • which tuxedo_keyboard version is installed? 3.0.9
  • Python version: 3.8.10
  • Laptop: Clevo NH55DC
  • OS details:
  Operating System: Linux Mint 20.3
            Kernel: Linux 5.4.0-137-generic
      Architecture: x86-64
  • tuxedo_keyboard SysFS folder is correctly installed:
brightness    color_extra  color_right  driver_override  input     mode   state      uevent
color_center  color_left   driver       extra            modalias  power  subsystem

Additional context
It'd be really helpful to see some example commands, as reading the help info didn't really give me understanding of what a valid mode-changing command would be. backlight dance says no argument was specified for dance.

Not working under Arch Linux

Many thanks for this, but unfortunately it doesn't work under Arch Linux.

Installed with the commands

wget https://github.com/webketje/tuxedo-backlight-control/releases/download/v0.5/tuxedo-backlight-control-0.5-1-any.pkg.tar.xz

sudo pacman -U tuxedo-backlight-control-0.5-1-any.pkg.tar.xz

Error

Traceback (most recent call last): File "/usr/share/tuxedo-backlight-control/ui.py", line 346, in <module> init() File "/usr/share/tuxedo-backlight-control/ui.py", line 340, in init root = tk.Tk() File "/usr/lib/python3.7/tkinter/__init__.py", line 2023, in __init__ self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use) _tkinter.TclError: no display name and no $DISPLAY environment variable

Backlight command not found

Hello, I've installed the AUR package, but I can't run the backlight command. I get this error
Screenshot from 2021-08-10 17-13-53

I got no clue what to do, any tips?

Q: Get current settings

Hi,

Is there any way to get the active setting or color of the backlight?

Thank you for maintaining this!

No module named 'backlight_control'

Fresh install, getting this error on launch:

Traceback (most recent call last):
  File "/usr/local/bin/backlight", line 6, in <module>
    from backlight_control import BacklightControl, backlight
ModuleNotFoundError: No module named 'backlight_control'

No such thing as /sys/devices/platform/tuxedo_keyboard/state on my laptop

backlight color red
Traceback (most recent call last):
File "/usr/local/bin/backlight", line 69, in
backlight.state = 1
File "/usr/share/tuxedo-backlight-control/backlight_control.py", line 122, in state
self.set_device_param('state', str(value))
File "/usr/share/tuxedo-backlight-control/backlight_control.py", line 70, in set_device_param
filehandle = open(BacklightControl.DEVICE_PATH + prop, mode='w')
PermissionError: [Errno 13] Permission denied: '/sys/devices/platform/tuxedo_keyboard/state'
root@ghost:# ls /sys/devices/platform/tuxedo_keyboard/state
ls: cannot access '/sys/devices/platform/tuxedo_keyboard/state': No such file or directory
root@ghost:# lsmod|grep tuxedo
tuxedo_io 20480 0
tuxedo_keyboard 49152 3 tuxedo_io,uniwill_wmi,clevo_wmi
sparse_keymap 16384 2 asus_wmi,tuxedo_keyboard

Can't run backlight control on POPos

Hey I have a tongfang laptop from a brazilian manufacturer, It is similar as the polaris model, and even is called Polaris too, and the model is gk5np50.

I've installed POP Os on it, and I can run tuxedo control center, but when I did it, it freezes my keyboardbacklight, so I downloaded this control, but when I will start the gui, i receive it:

j3ff@pop-os:~$ backlight ui
Traceback (most recent call last):
File "/usr/local/bin/backlight", line 36, in
init()
File "/usr/share/tuxedo-backlight-control/ui.py", line 344, in init
App(root)
File "/usr/share/tuxedo-backlight-control/ui.py", line 58, in init
initial_mode = backlight.mode.capitalize()
AttributeError: 'NoneType' object has no attribute 'capitalize'

tuxedo-backlight-control does not start

root@ghost:# python -V Python 3.9.10 root@ghost:# /usr/share/tuxedo-backlight-control/ui.py Traceback (most recent call last): File "/usr/share/tuxedo-backlight-control/ui.py", line 358, in init() File "/usr/share/tuxedo-backlight-control/ui.py", line 353, in init App(root) File "/usr/share/tuxedo-backlight-control/ui.py", line 51, in init 'color_left': tk.StringVar(self, value=backlight.color_left.capitalize()), AttributeError: 'NoneType' object has no attribute 'capitalize'

Stopped working

App stopped working - clicking on icon, but interface does not show up. Reinstall or install different version did not help. Ideas? ๐Ÿ™‚
CLI:
โ”Œ[me_is_meโ˜ฎcompewtur]-(~)
โ””> backlight ui
Traceback (most recent call last):
File "/usr/local/bin/backlight", line 43, in
init()
File "/usr/share/tuxedo-backlight-control/ui.py", line 352, in init
root = tk.Tk()
File "/usr/lib/python3.10/tkinter/init.py", line 2299, in init
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable

Color setting pink is not pink

Hi there!

Just wanted to say, that Pink doesn't show a Pink color for me. Fuchsia though is Fuchsia, so it could work.

Pink is more like a yellowish color.

Example images:

  • Pink (the pink hint on the right comes from the screen)
  • Fuchsia+

My model is a Clevo P775TM1-G. If you need any further information, please ask!

NoneType object has no attribute capitalize

Got this error after tuxedo-keyboard updated to the latest version when attempting to run tuxedo-backlight-control.

  File "/usr/share/tuxedo-backlight-control/ui.py", line 358, in <module>
    init()
  File "/usr/share/tuxedo-backlight-control/ui.py", line 353, in init
    App(root)
  File "/usr/share/tuxedo-backlight-control/ui.py", line 51, in __init__
    'color_left': tk.StringVar(self, value=backlight.color_left.capitalize()),
AttributeError: 'NoneType' object has no attribute 'capitalize'

backlight ui fails with AttributeError: 'NoneType' object has no attribute 'capitalize'

Before reporting the bug

  • I have looked at existing issues and none solved my problem
  • I have installed the tuxedo_keyboard driver and rebooted
  • I have made sure my laptop model is a TUXEDO / Clevo computer or derivative

Describe the bug
A clear and concise description of what the bug is: did it occur on a specific action? did you run tuxedo-backlight-control using the CLI (backlight ui) or the UI directly?
I used the command line command: "backlight ui"

backlight ui
Traceback (most recent call last):
  File "/usr/local/bin/backlight", line 43, in <module>
    init()
  File "/usr/share/tuxedo-backlight-control/ui.py", line 353, in init
    App(root)
  File "/usr/share/tuxedo-backlight-control/ui.py", line 51, in __init__
    'color_left': tk.StringVar(self, value=backlight.color_left.capitalize()),
AttributeError: 'NoneType' object has no attribute 'capitalize'

Describe your OS environment

  • tuxedo-backlight-control version: (run backlight --version and paste the result here)
    0.8.0

  • which tuxedo_keyboard version is installed? (run cat /sys/module/tuxedo_keyboard/version and paste the result here)
    cat /sys/module/tuxedo_keyboard/version ย ๎‚ถย 1ย 
    3.2.5

  • Python version: (run python --version and paste the result here)
    python3 --version
    Python 3.10.6

  • OS details:)

    hostnamectl
     Static hostname: mau-Laptop
         Icon name: computer-laptop
           Chassis: laptop
        Machine ID: f88e2b5a48ce460eb10ef6c394705ea3
           Boot ID: 126785e9553f4d5b91a90550c6198754
           Operating System: Ubuntu 22.04.2 LTS              
            Kernel: Linux 5.19.0-43-generic
      Architecture: x86-64
       Hardware Vendor: Notebook
       Hardware Model: PD5x_7xPNP_PNN_PNT
  • tuxedo_keyboard SysFS folder is correctly installed:

ls /sys/devices/platform/tuxedo_keyboard
driver driver_override input modalias power subsystem uevent


**Additional context**
Add any other context about the problem here.

How do I turn keyboard backlight off while booting?

I am on Ubuntu 22.04.2 LTS on Lambda Tensorbook, and I installed my keyboard backlight through this repo. The Fn commands work fine; however, I use my laptop through an external Bluetooth keyboard and mouse. How can I turn off the keyboard backlight whenever the laptop boots? If that is not possible, is there a way I can turn off the keyboard backlight without the Fn + * key? Thank you!

Latest release tuxedo-keyboard changed file-locations

Before reporting the bug

  • [ X ] I have looked at existing issues and none solved my problem
  • [ X ] I have installed the tuxedo_keyboard driver and rebooted
  • [ X ] I have made sure my laptop model is a TUXEDO / Clevo computer or derivative

Describe the bug
Since the latest release the file locations have changed and I cannot change color and brightness anymore.
Tuxedo-Keyboard issues #165

โ”€ /bin/sh -c "/usr/bin/python /usr/share/tuxedo-backlight-control/backlight.py brightness 0"
Traceback (most recent call last):
  File "/usr/share/tuxedo-backlight-control/backlight.py", line 59, in <module>
    backlight.state = 1
  File "/usr/share/tuxedo-backlight-control/backlight_control.py", line 122, in state
    self.set_device_param('state', str(value))
  File "/usr/share/tuxedo-backlight-control/backlight_control.py", line 70, in set_device_param
    filehandle = open(BacklightControl.DEVICE_PATH + prop, mode='w')
PermissionError: [Errno 13] Permission denied: '/sys/devices/platform/tuxedo_keyboard/state'

Describe your OS environment

  • tuxedo-backlight-control version: 0.8.0
  • which tuxedo_keyboard version is installed? 3.2.1
  • Python version: Python 3.10.10
  • OS details:)
    NAME="Arch Linux"
    PRETTY_NAME="Arch Linux"
    ID=arch
    BUILD_ID=rolling
    ANSI_COLOR="38;2;23;147;209"
    
  • tuxedo_keyboard SysFS folder is correctly installed:
    lrwxrwxrwx root root   0 B  Tue Mar 28 19:39:41 2023 ๏’‚ driver@ โ‡’ ../../../bus/platform/drivers/tuxedo_keyboard
    drwxr-xr-x root root   0 B  Tue Mar 28 19:39:41 2023 ๏„• input/
    drwxr-xr-x root root   0 B  Tue Mar 28 19:39:41 2023 ๏„• leds/
    drwxr-xr-x root root   0 B  Tue Mar 28 19:40:38 2023 ๏„• power/
    lrwxrwxrwx root root   0 B  Tue Mar 28 19:39:41 2023 ๏’‚ subsystem@ โ‡’ ../../../bus/platform
    .rwxrwxrwx root root 4.0 KB Tue Mar 28 19:40:00 2023 ๏’‰ driver_override*
    .rwxrwxrwx root root 4.0 KB Tue Mar 28 19:40:00 2023 ๏’‰ modalias*
    .rwxrwxrwx root root 4.0 KB Tue Mar 28 19:40:00 2023 ๏’‰ uevent*
    

Add region control

A lot of keyboards have the separate regions, you've only included the one. If you don't feel like doing it add me as contributor.

Add a troubleshooting section to the README

  • Update de bug reporting template to mention looking at the README troubleshooting guide
  • This should add troubleshooting guides for:
    • _tkinter.TclError: no display name and no $DISPLAY environment variable cf #3, #21, #25
    • Linux Kernel 6.0 support
    • Stellaris/ Polaris support

program cannot read $DISPLAY

/usr/share/tuxedo-backlight-control/ui.py --help
Traceback (most recent call last):
File "/usr/share/tuxedo-backlight-control/ui.py", line 358, in
init()
File "/usr/share/tuxedo-backlight-control/ui.py", line 352, in init
root = tk.Tk()
File "/usr/lib/python3.10/tkinter/init.py", line 2299, in init
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable

echo $DISPLAY
:0

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.