Skip to content

Instantly share code, notes, and snippets.

@hghwng
Last active September 4, 2017 15:01
Show Gist options
  • Select an option

  • Save hghwng/0dd213aa96e5881fa1af11971c6bd002 to your computer and use it in GitHub Desktop.

Select an option

Save hghwng/0dd213aa96e5881fa1af11971c6bd002 to your computer and use it in GitHub Desktop.

Revisions

  1. hghwng revised this gist Sep 4, 2017. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions backlight
    Original file line number Diff line number Diff line change
    @@ -22,6 +22,7 @@ function set-color-temp() {

    function set-color-termite() {
    pushd ~/.config/termite > /dev/null
    # place real config sections in "option" file, and color sections in separate "name.color" files
    cat option "$1.color" > config
    pkill -USR1 termite
    popd > /dev/null
  2. hghwng created this gist Sep 4, 2017.
    87 changes: 87 additions & 0 deletions backlight
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,87 @@
    #!/bin/bash

    # Screen brightness and color temperature

    function set-brightness-i2c() {
    sudo ddcutil -l "$1" setvcp 0x10 "$2" &
    }

    function set-brightness-builtin() {
    xbacklight -set "$1" -time 0
    }

    function set-color-temp() {
    if [[ x"$1" == x"" ]]; then
    redshift -x
    else
    redshift -O "$1";
    fi
    }

    # Application color

    function set-color-termite() {
    pushd ~/.config/termite > /dev/null
    cat option "$1.color" > config
    pkill -USR1 termite
    popd > /dev/null
    }

    function set-color-spacemacs() {
    emacsclient -e "(spacemacs/load-theme '$1)"
    }

    function set-color-app-day() {
    set-color-termite solarized-light
    set-color-spacemacs solarized-light
    }

    function set-app-color-night() {
    set-color-termite solarized-dark
    set-color-spacemacs solarized-dark
    }

    # Profiles

    function profile-day() {
    set-color-app-day
    set-color-temp
    set-brightness-builtin 40
    set-brightness-i2c W2242 100
    }

    function profile-sunset() {
    set-color-app-day
    set-color-temp 5000
    set-brightness-builtin 13
    set-brightness-i2c W2242 20
    }

    function profile-night() {
    set-app-color-night
    set-color-temp 4000
    set-brightness-builtin 5
    set-brightness-i2c W2242 5
    }

    function profile-midnight() {
    set-app-color-midnight
    set-color-temp 3500
    set-brightness-builtin 1
    set-brightness-i2c W2242 0
    }

    # "Movie" mode

    function profile-movie-on() {
    set-color-temp
    sudo ddcutil -l W2242 setvcp 0xfc 1 &
    autorandr -l movie
    }

    function profile-movie-off() {
    sudo ddcutil -l W2242 setvcp 0xfc 0 &
    }

    # Eval!
    profile-$1