forked from pirate/mac-keyboard-brightness
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblink
executable file
·29 lines (24 loc) · 1.03 KB
/
blink
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash
# Nick Sweeting 2017
# MIT License
if [[ "$1" == "-h" || "$1" == "--help" || "$1" == "help" ]]; then
echo "Flash the keyboard [1] times with a [0.15]s delay, between [0] and [1] brightness levels"
echo "Usage:"
echo " blink [times] [duration] [low_brightness] [high_brightness]"
exit 0
fi
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # get the full path to the directory ./blink is in
kbrightness="$DIR/kbrightness" # full path to the kbrightness binary
flashes=${1:-'1'} # how many flashes
duration=${2:-'0.15'} # duration of each flash in seconds
low_level=${3:-'0'} # lowest brightness level, 0.0 -> 1.0
high_level=${4:-'1'} # highest brightness level, 0.0 -> 1.0
before=$("$kbrightness") # get the current brightness level
for i in $(seq 1 $flashes); do
"$kbrightness" $low_level
sleep $duration
"$kbrightness" $high_level
sleep $duration
done
# set keyboard back to existing brightness level before blink ran
"$kbrightness" $before