Skip to content

Instantly share code, notes, and snippets.

@lexicalunit
Last active February 23, 2021 21:41
Show Gist options
  • Save lexicalunit/b82ed1f317f4d6bc6b896769c0af211b to your computer and use it in GitHub Desktop.
Save lexicalunit/b82ed1f317f4d6bc6b896769c0af211b to your computer and use it in GitHub Desktop.
Some bash script utilities for working with BlinkStick
#!/bin/bash
# Source this file to import these utilites into your scripts.
BLINK_LOCK="/tmp/.blinkstick-toggle"
touch "$BLINK_LOCK"
# Choose the python needed for blinkstick and the path to blinkstick
BS="/usr/bin/python /usr/local/bin/blinkstick"
blink_reset() {
rm "$BLINK_LOCK"
}
blink_is_color() {
test "$(cat "$BLINK_LOCK" 2>/dev/null)" == "$1"
}
blink_is_red() {
blink_is_color red
}
blink_is_green() {
blink_is_color green
}
blink_is_busy() {
blink_is_color busy
}
blink_set_color() {
echo "$1" > "$BLINK_LOCK"
eval "$BS --set-color '$1'"
}
blink_set_busy() {
echo "busy" > "$BLINK_LOCK"
eval "$BS --set-color '$1'"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment