#!/bin/bash # # redshifter # # 2020-03-20, 2018-03-13 Tom Wizetek # GPL # # Wrapper for 'redshift' http://jonls.dk/redshift/ # Requires 'bc' for floating point math. # # Configuration saved in ~/.config/redshifter # # Example key bindings in DE/WM: # # Super+\ redshifter # Super+] redshifter + # Super+[ redshifter - # Super+/ redshifter / / # Super+. redshifter = + # Super+, redshifter = - # showHelp() { cat < ${min_brightness}") -eq 1 ]] then set_brightness=$(bc <<< ${set_brightness}-.02) fi ;; "+") if [[ $(bc <<< "${set_brightness} < ${max_brightness}") -eq 1 ]] then set_brightness=$(bc <<< ${set_brightness}+.02) fi ;; [0-9]*) set_brightness=${2} ;; "/") set_brightness=${max_brightness} ;; esac # # Color temperature # case ${1} in "=") : # no-op ;; "-") if [[ ${set_colortemp} -gt ${min_colortemp} ]] then ((set_colortemp-=100)) fi ;; "+") if [[ ${set_colortemp} -lt ${max_colortemp} ]] then ((set_colortemp+=100)) fi ;; [0-9]*) set_colortemp=${1} ;; "/") set_colortemp=${colortemp_array[0]} ;; "") for array_item in ${colortemp_array[@]} do if [[ ${array_item} -lt ${set_colortemp} ]] then break # set_colortemp=1200, array_item=6500 elif [[ ${set_colortemp} -eq ${colortemp_array[-1]} ]] then break fi done set_colortemp=${array_item} ;; *) showHelp exit 1 ;; esac # # Execute # ${cmd_path} ${cmd_arg_colortemp} ${set_colortemp} ${cmd_arg_brightness} ${set_brightness} # # Save values to conf file # echo "colortemp=${set_colortemp}" > ${conf_file} echo "brightness=${set_brightness}" >> ${conf_file} # eof