diff options
Diffstat (limited to 'keyboard/monctl')
| -rwxr-xr-x | keyboard/monctl | 38 | 
1 files changed, 38 insertions, 0 deletions
diff --git a/keyboard/monctl b/keyboard/monctl new file mode 100755 index 0000000..116974f --- /dev/null +++ b/keyboard/monctl @@ -0,0 +1,38 @@ +#!/bin/sh + +display=$2 +input_vcp=0x60 +input_local=0x11 +input_other=0x0f +power_vcp=0xD6 +power_on=0x01 +power_off=0x05 +sleep_multiplier=.1  # Set this as low as you can get away with + +# DDC/CI stuff +ddcutil="ddcutil --noverify --sleep-multiplier $sleep_multiplier --display $display"  # Make sure user is in group i2c + +getstate() { $ddcutil getvcp $1 | grep -o '0x[0-9a-f]*' | tail -n1 ; } + +in_other() { $ddcutil setvcp $input_vcp $input_other ; } +in_local() { $ddcutil setvcp $input_vcp $input_local ; } +pw_on()    { $ddcutil setvcp $power_vcp $power_on    ; } +pw_off()   { $ddcutil setvcp $power_vcp $power_off   ; } + +in_toggle() { [ `getstate $input_vcp` = $input_local ] && in_other || in_local ; }  # Default to input_local +pw_toggle() { [ `getstate $power_vcp` = $pw_on       ] && pw_off   || pw_on    ; }  # Default to power_on + +case $1 in +	inputother)  in_other  ;; +	inputlocal)  in_local  ;; +	inputtoggle) in_toggle ;; +	poweron)     pw_on     ;; +	poweroff)    pw_off    ;; +	powertoggle) pw_toggle ;; +	getinput)    getstate $input_vcp ;; +	getpower)    getstate $power_vcp ;; +	*) +		echo "'$1' is not a recognized option" +		echo "$(basename "$0") [inputother|inputlocal|inputtoggle|poweron|poweroff|powertoggle] display_num" +	;; +esac  | 
