Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Desktop modes
- declare -A attach
- attach[5]='0x1b'
- attach[8]='0x0f'
- declare -A detach
- detach[5]='0x0f'
- detach[8]='0x11'
- wait_time=1
- wait_counter=10
- case $ACTION in
- add)
- for key in $(echo "${!attach[@]}" | xargs -n1 | sort -g)
- do
- counter=0
- while [[ $counter -lt $wait_counter ]]
- do
- counter=$((counter+1))
- if [[ -c "/dev/i2c-${key}" ]]
- then
- ddcutil setvcp --bus $key 60 ${attach[$key]}
- break
- fi
- sleep $wait_time
- done
- done
- ;;
- remove)
- for key in $(echo "${!detach[@]}" | xargs -n1 | sort -g -r)
- do
- counter=0
- while [[ $counter -lt $wait_counter ]]
- do
- counter=$((counter+1))
- if [[ -c "/dev/i2c-${key}" ]]
- then
- ddcutil setvcp --bus $key 60 ${detach[$key]}
- break
- fi
- sleep $wait_time
- done
- done
- ;;
- esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement