Permalink
Browse files

Cleaner version of location awareness and adium updater

  • Loading branch information...
JosephPecoraro committed Apr 1, 2009
1 parent 8959ab4 commit b19cc6226b1fa29564f9848cdcf63fd9e59f3355
Showing with 84 additions and 0 deletions.
  1. +46 −0 crontasks/auto_status.cron
  2. +38 −0 crontasks/update_location.cron
View
@@ -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
@@ -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

0 comments on commit b19cc62

Please sign in to comment.