-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxcode_finished.sh
More file actions
executable file
·39 lines (30 loc) · 1.16 KB
/
xcode_finished.sh
File metadata and controls
executable file
·39 lines (30 loc) · 1.16 KB
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
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
# Author: Logan Isitt
function displaytime {
local T=$1
local M=$((T/60))
local S=$((T%60))
[[ $M > 0 ]] && printf '%d minutes' $M
[[ $M > 0 ]] && [[ $S > 0 ]] && printf ' and '
[[ $S > 0 ]] && printf '%d seconds' $S
}
# IFTTT Maker Key - Replace with your Maker key
KEY=AB3dEFGH9Jkl3NOP4_StU
# Get Project Name
PROJECT=$(echo $XcodeProject | sed -e "s/".xcodeproj"/""/g")
# Compute Build Time
START=$(cat `dirname $0`/$PROJECT-timestamp)
END=$(date +%s)
DURATION=`expr $END - $START`
BUILD_TIME=`echo $(displaytime $DURATION)`
# Maximum idle time allowed to supress notification
MAX_IDLE=60
# Get Idle Time
IDLE=$((`ioreg -c IOHIDSystem | sed -e '/HIDIdleTime/ !{ d' -e 't' -e '}' -e 's/.* = //g' -e 'q'` / 1000000000))
# Send notification if idle time is greater than max idle time
if [ $IDLE -ge $MAX_IDLE ]; then
curl -X POST -H "Content-Type: application/json" -d "{\"value1\":\"$PROJECT\", \"value2\":\"$IDEAlertMessage\", \"value3\":\"$BUILD_TIME\"}" https://maker.ifttt.com/trigger/Xcode/with/key/$KEY
fi
echo "`whoami`,$PROJECT,`date +'%Y-%m-%d %H:%M:%S'`,$DURATION" >> `dirname $0`/buildlog.csv
# Clean up
rm `dirname $0`/$PROJECT-timestamp