Application Issues!?!
So I made the following application to make my girlfriends life easire with streaming movies since shes fairly illiterate with computers. Bulit it, Tested it, and it worked on my laptop, but when it is on hers, the server update, caffeine, and brightness won't work at all. Any one have any idea what could be going on? I have 10.8.2 she has 10.7.x
Here is the AppDelegate.applescript:
--
-- AppDelegate.applescript
-- Plex Simple Server
--
-- Created by Riley Lloyd on 2/2/13.
-- Copyright (c) 2013 Riley Lloyd. All rights reserved.
--
script AppDelegate
propertyparent : class"NSObject"
property mainWindow : missing value -- outlet connected to the main window
property thePID : missing value
on applicationWillFinishLaunching_(aNotification)
-- Insert code here to initialize your application before any files are opened
set myBundle to current application's NSBundle's mainBundle()
set backgroundImage to current application's NSImage's alloc's initWithContentsOfFile_(myBundle's pathForResource_ofType_("BG", "jpg"))
backgroundImage's setSize_({480, 360}) -- match window size
mainWindow's setBackgroundColor_(current application's NSColor's colorWithPatternImage_(backgroundImage))
end applicationWillFinishLaunching_
on startServer_(applescript)
set PowerSource to (do shell script "pmset -g ps")
do shell script "sudo ifconfig en1 up" with administrator privileges
repeat until PowerSource does not contain "Battery Power"
set PowerSource to (do shell script "pmset -g ps")
if PowerSource does not contain "AC Power" then
display alert "Please plug your computer in to a power source, then click continue." buttons {"Cancel", "Continue"}
set theAnswer to button returned of the result
if theAnswer is "Continue" then
set PowerSource to (do shell script "pmset -g ps")
if PowerSource does not contain "Battery Power" then
exit repeat
else
delay 1
end if
end if
if theAnswer is "Cancel" then
return
end if
end if
end repeat
ifapplication"Plex Media Server"isnot running then
tellapplication"Plex Media Server"toactivate
end if
end startServer_
on stopServer_(applescript)
tellapplication"System Events"
set isOpen to exists process "Plex Media Server"
end tell
if isOpen then
tellapplication"Plex Media Server"toquit
else
display alert "Server was not running to begin with."
end if
end stopServer_
on updateServerLibrary_(applescript)
tellapplication"System Events"
set is_running to exists process "Plex Media Server"
end tell
if is_running then
do shell script"'/Applications/Plex Media Server.app/Contents/MacOS/Plex Media Scanner' -s -r"
return
else
display alert "Please start the server first."
end if
end updateServerLibrary_
on disableSleep_(sender)
set thePID to (do shell script"caffeinate &> /dev/null & echo $!")
end disableSleep_
on enableSleep_(sender)
if thePID is missing value then return -- no process
do shell script "kill $(pgrep caffeinate) " & thePID
set thePID to missing value -- reset for next time
end enableSleep_
on brightnessUp_(applescript)
set theVariable to 0
repeat until theVariable = 16
tellapplication"System Events"
key code 113
end tell
set theVariable to theVariable + 1
end repeat
end brightnessUp_
on brightnessMed_(applescript)
set theVariable to 0
repeat until theVariable = 16
tellapplication"System Events"
key code 107
end tell
set theVariable to theVariable + 1
end repeat
set nextVariable to 0
repeat until nextVariable = 9
tellapplication"System Events"
key code 113
end tell
set nextVariable to nextVariable + 1
end repeat
end brightnessMed_
on brightnessDown_(applescript)
set theVariable to 0
repeat until theVariable = 16
tellapplication"System Events"
key code 107
end tell
set theVariable to theVariable + 1
end repeat
tellapplication"System Events"
key code 113
end tell
end brightnessDown_
on applicationShouldTerminateAfterLastWindowClosed_(sender)
returntrue
end applicationShouldTerminateAfterLastWindowClosed_
on applicationShouldTerminate_(sender)
if thePID is missing value then return -- no process
do shell script "kill $(pgrep caffeinate) " & thePID
set thePID to missing value
return current application's NSTerminateNow
end applicationShouldTerminate_
endscript
MacBook Pro, OS X Mountain Lion (10.8.2), 2.3 GHz i5, 4GB RAM, OCZ 120GB SSD