Skip to content

Instantly share code, notes, and snippets.

@hghwng
Last active September 4, 2017 15:01
Show Gist options
  • Save hghwng/0dd213aa96e5881fa1af11971c6bd002 to your computer and use it in GitHub Desktop.
Save hghwng/0dd213aa96e5881fa1af11971c6bd002 to your computer and use it in GitHub Desktop.
Backlight profile switcher
#!/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
# 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
}
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment