Last active
December 27, 2015 22:19
-
-
Save keinajar/7398527 to your computer and use it in GitHub Desktop.
Sets OS X display temperature using Flux. Requires Flux: http://justgetflux.com/
Inspired by Kelvin: http://apple.stackexchange.com/a/51589/1453 Be sure to check "Custom" as "Lighting at night" preference in Flux.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Sets OS X display temperature using Flux. | |
# Requires Flux: http://justgetflux.com/ | |
# Inspired by Kelvin: http://apple.stackexchange.com/a/51589/1453 | |
# Be sure to check "Custom" as "Lighting at night" preference in Flux. | |
declare l r d n night day | |
while getopts ":hlrd:n:" opt; do | |
case $opt in | |
l) | |
defaults read org.herf.Flux | |
exit 0 | |
;; | |
r) | |
r=1 | |
;; | |
d) | |
d=1 | |
day=$OPTARG | |
;; | |
n) | |
n=1 | |
night=$OPTARG | |
;; | |
h) | |
echo "flux-temp [-hlr] [-d temp] [-n temp] [temp] | |
-h shows this help | |
-l shows current Flux settings | |
-r kills Flux | |
-d temp sets day temperature | |
-n temp sets day temperature | |
Running flux-temp without options (e.g. flux-temp 3000) sets both night and day temperature; effectively setting the current display temperature no matter what time it is. | |
" | |
exit 0 | |
;; | |
\?) | |
"Invalid option: -$OPTARG" >&2 | |
exit 1 | |
;; | |
:) | |
echo "Missing argument for -$OPTARG" >&2 | |
exit 1 | |
;; | |
esac | |
done | |
killall Flux > /dev/null 2>&1 | |
[ ! -z "$r" ] && exit 0 | |
[[ -z "$n" && -z "$d" && ! -z "$1" ]] && night=$1 && day=$1 | |
[[ -z "$night" && -z "$day" ]] && echo "Provide a temperature between 2300 and 6500 (rounded to nearest 100)." && exit 1 | |
[[ ! -z "$d" || ( -z "$d" && -z "$n" ) ]] && defaults write org.herf.Flux dayColorTemp -int "$day" | |
[[ ! -z "$n" || ( -z "$d" && -z "$n" ) ]] && defaults write org.herf.Flux nightColorTemp -int "$night" && defaults write org.herf.Flux customNightColorTemp -int "$night" | |
open /Applications/Flux.app | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment