Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cleaner version of location awareness and adium updater
- Loading branch information
1 parent
8959ab4
commit b19cc62
Showing
2 changed files
with
84 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,46 @@ | ||
#!/bin/bash | ||
# Start Date: Wednesday April 1, 2009 | ||
# Current Version: 0.9 | ||
# Author: Joseph Pecoraro | ||
# Contributor: Sean McDermott - RIT Host Idea | ||
# Contact: joepeck02@gmail.com | ||
# Decription: Automatically update my status | ||
# By determining where I am, and what time it is. | ||
|
||
# Debug mode just means provide any cmd lne argument | ||
DEBUG=$1 | ||
|
||
# My Location Storing File | ||
LOCATION_FILE='/Users/joe/.location' | ||
|
||
# My Location thanks to outside scripts | ||
LOCATION=$(cat $LOCATION_FILE) | ||
[ -n "$DEBUG" ] && echo $LOCATION; | ||
|
||
# Exit Immediately if Adium is not running | ||
check=$(/usr/bin/osascript -e 'tell application "Finder" to name of processes' | /usr/bin/grep Adium) | ||
if [ -z "$check" ]; then | ||
[ -n "$DEBUG" ] && echo "Adium Not Running" | ||
exit 1 | ||
fi | ||
|
||
# Mac Address of my Router At Home | ||
if [ "$LOCATION" = "home" ]; then | ||
[ -n "$DEBUG" ] && echo '@Home' | ||
/usr/bin/osascript -e 'tell application "Adium" to go online with message "@Home (testing applescript)"' | ||
|
||
# Monday and Wednesday Classes and Times | ||
elif [ "$LOCATION" = "class" ]; then | ||
[ -n "$DEBUG" ] && echo '@Class' | ||
/usr/bin/osascript -e 'tell application "Adium" to go away with message "@Class (testing applescript)"' | ||
|
||
# RIT Hostname should only exist when at rit | ||
elif [ "$LOCATION" = "rit" ]; then | ||
[ -n "$DEBUG" ] && echo '@RIT' | ||
/usr/bin/osascript -e 'tell application "Adium" to go online with message "@RIT (testing applescript)"' | ||
|
||
# Default | ||
else | ||
[ -n "$DEBUG" ] && echo '@Unknown' | ||
/usr/bin/osascript -e 'tell application "Adium" to go online with message "@Unknown (testing applescript)"' | ||
fi |
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,38 @@ | ||
#!/bin/bash | ||
# Start Date: Wednesday April 1, 2009 | ||
# Current Version: 0.9 | ||
# Author: Joseph Pecoraro | ||
# Contributor: Sean McDermott - RIT Host Idea | ||
# Contact: joepeck02@gmail.com | ||
# Decription: Store my location in a file that | ||
# any other script of mine can access! | ||
|
||
# Debug mode just means provide any cmd-line argument | ||
DEBUG=$1 | ||
|
||
# My Location Storing File | ||
LOCATION_FILE='/Users/joe/.location' | ||
|
||
# Used for School comparison | ||
day_hour=`/bin/date +"%A %H"` | ||
|
||
# Mac Address of my Router At Home | ||
if [ -n "$(/usr/sbin/arp -a | /usr/bin/grep 0:1e:2a:76:17:98)" ]; then | ||
[ -n "$DEBUG" ] && echo 'home' | ||
echo "home" > $LOCATION_FILE | ||
|
||
# Monday and Wednesday Classes and Times | ||
elif [ -n "`echo {Monday\ {12,13,16,17},Wednesday\ {12,13,16,17}} | /usr/bin/grep \"$day_hour\"`" ]; then | ||
[ -n "$DEBUG" ] && echo 'class' | ||
echo "class" > $LOCATION_FILE | ||
|
||
# RIT Hostname should only exist when at rit | ||
elif [ "0" -ne "$(/sbin/ping -c 1 jpecoraro.rit.edu | wc -l | tr -d ' ')" ]; then | ||
[ -n "$DEBUG" ] && echo 'rit' | ||
echo "rit" > $LOCATION_FILE | ||
|
||
# Default | ||
else | ||
[ -n "$DEBUG" ] && echo 'unknown' | ||
echo "unknown" > $LOCATION_FILE | ||
fi |