Skip to content

Instantly share code, notes, and snippets.

@ssstonebraker
Last active February 15, 2021 05:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ssstonebraker/fb808b27a688cacabcaca60289f12a59 to your computer and use it in GitHub Desktop.
Save ssstonebraker/fb808b27a688cacabcaca60289f12a59 to your computer and use it in GitHub Desktop.
hue.sh
#!/bin/bash
# Author: Steve Stonebraker
# Date: 11/16/2020
# brakertech.com
WHOAMI=$(whoami)
path_phe=/Users/"$WHOAMI"/Library/cron/philips-hue-experiments
path_log="$PWD"/log/hue.log
path_npm=$(which npm)
# initialize log
mkdir -p log
touch "$path_log"
# Import API Key
# File should contain
# PHILIPS_HUE_USERNAME="<insert API KEY HERE>"
. /Users/"$WHOAMI"/.hue
# Import Path info
. ~/.bash_profile
# log argument passed
function log {
currtimestamp=`date "+%Y-%m-%d--%H-%M"`
echo "$currtimestamp: $1" >> $path_log
}
function lightGreen {
log "green"
cd "$path_phe" && "$path_npm" run set-color -- "#42f581" >> "$path_log"
exit 0
}
function lightRed {
log "red"
cd "$path_phe" && "$path_npm" run set-color -- "d50000" >> "$path_log"
exit 0
}
# Check if in meeting
if pgrep -x "GoToMeeting" &> /dev/null 2>&1; then
lightRed
elif pgrep -x "zoom.us" &> /dev/null 2>&1; then
lightRed
elif pgrep -x "Teams" &> /dev/null 2>&1; then
lightRed
elif pgrep -x "Webex Teams" &> /dev/null 2>&1; then
lightRed
else
lightGreen
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment