Code Monkey home page Code Monkey logo

macbook-lighter-nvidia's Introduction

Fork of macbook-lighter

macbook-lighter-nvidia

Table of Contents

Description

MacBook keyboard and screen backlight adjust on the ambient light with nvidia graphic card. Internally, macbook-lighter-nvidia reads the following files:

# /sys/devices/platform/applesmc.768/light
# /sys/class/backlight/nv_backlight/brightness
# /sys/class/backlight/nv_backlight/max_brightness
# /sys/class/leds/smc::kbd_backlight/brightness
# /sys/class/leds/smc::kbd_backlight/max_brightness

So you're expected to install corresponding Nvidia/Intel drivers first.

Setup

With sudo

All commands including macbook-lighter-kbd, macbook-lighter-screen will be available with sudo privilege once macbook-lighter-nvidia finished install.

Without sudo

Method: 1

To use in non-root environment such as xbindkeys, it's recommended to setup an "udev" rule to allow users in the "video" group to set the backlights. Place a file /etc/udev/rules.d/90-backlight.rules containing:

SUBSYSTEM=="backlight", ACTION=="add", \
  RUN+="/bin/chgrp video /sys/class/backlight/%k/brightness", \
  RUN+="/bin/chmod g+w /sys/class/backlight/%k/brightness"

And a file /etc/udev/rules.d/91-leds.rules containing:

SUBSYSTEM=="leds", ACTION=="add", \
  RUN+="/bin/chgrp video /sys/class/leds/%k/brightness", \
  RUN+="/bin/chmod g+w /sys/class/leds/%k/brightness"

Method: 2 Create/Add these commands to /etc/rc.local file to change the backlight file mode bits:

# /etc/rc.local
.
.
.
chmod 777 /sys/class/leds/smc::kbd_backlight/brightness
chmod 777 /sys/class/backlight/nv_backlight/brightness
.
.
. exit 0

Note: If you dont have /etc/rc.local file and rc-local.service (Check by executing sudo systemctl status rc-local), follow these steps to create one or both files:

  1. Create /etc/rc.local file by running sudo vim /etc/rc.local and paste these:
# /etc/rc.local

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

# <Add terminal commands here without sudo>
chmod 777 /sys/class/leds/smc::kbd_backlight/brightness
chmod 777 /sys/class/backlight/nv_backlight/brightness

exit 0
  1. Make the file executable using sudo chmod +x /etc/rc.local

  2. If you don't have rc-local service too, then:

    a. Create one by executing sudo vim /etc/systemd/system/rc-local.service and paste these

       # /etc/systemd/system/rc-local.service
    
       [Unit]
       Description=/etc/rc.local Compatibility
       ConditionPathExists=/etc/rc.local
    
       [Service]
       Type=forking
       ExecStart=/etc/rc.local start
       TimeoutSec=0
       StandardOutput=tty
       RemainAfterExit=yes
       SysVStartPriority=99
    
       [Install]
       WantedBy=multi-user.target
    

    b. Enable it to start with system by running sudo systemctl enable rc-local and reboot. Check the status of your service file by executing sudo systemctl status rc-local.

Usage

# Increase keyboard backlight by 50
macbook-lighter-kbd --inc 50
# Increase screen backlight by 50
macbook-lighter-screen --inc 50
# Set screen backlight to max
macbook-lighter-screen --max
# start auto adjust daemon
systemctl start macbook-lighter
# start auto adjust interactively, root previlege needed
macbook-lighter-ambient

Tested Versions

  • MacBook Pro Mid 2010 13" (7,1)

License

MIT License

macbook-lighter-nvidia's People

Contributors

harttle avatar ashwamegh avatar

Stargazers

Roman avatar

Watchers

James Cloos avatar

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.