-
-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
66885fa
commit 0e20b32
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/bash | ||
# Moves desk up or down. | ||
set -euo pipefail | ||
|
||
COMMAND="${1:-}" | ||
|
||
usage() { | ||
echo "Usage: ${0} <up|down>" >&2 | ||
exit 1 | ||
} | ||
|
||
[ -z "$COMMAND" ] && usage | ||
|
||
POWER_TYPE="$(pmset -g batt | grep -Eo '(Battery|AC) Power')" | ||
[ "${POWER_TYPE}" != "AC Power" ] && exit 0 | ||
|
||
LID_UP="$(ioreg -r -k AppleClamshellState | grep AppleClamshellState | awk '{print $4}')" | ||
[ "${LID_UP}" != "No" ] && exit 0 | ||
|
||
DESK_IP_ADDRESS="10.0.0.45" | ||
|
||
if [ "$COMMAND" == "up" ]; then | ||
DESK_PRESS_URL="http://${DESK_IP_ADDRESS}/button/desk_preset_1/press" | ||
elif [ "$COMMAND" == "down" ]; then | ||
DESK_PRESS_URL="http://${DESK_IP_ADDRESS}/button/desk_preset_2/press" | ||
else | ||
usage | ||
fi | ||
|
||
curl -X POST "${DESK_PRESS_URL}" &>/dev/null |