Stefan, thank-you noting that your explanations seems to confirm my understanding.
Joel
Stefan, thank-you noting that your explanations seems to confirm my understanding.
Joel
I am having trouble with the “if then portion” of the following small section of code which is contained within an On Idle block:
set timeControl to time of (current date)
if ((timeControl is equal to or greater than 82800) or (timeControl is equal to or less than than 28800)) then -- No ping to test for iPhone absence/presence between 11:00 PM and 8:00 AM
if (timeControl is equal to or greater than 82800) then set returnTime to ((86339 - timeControl) + 28800) as integer
if (timeControl is equal to or less than 28800) then set returnTime to (28800 - timeControl) as integer
else
if iPhoneDetected is equal to false then set returnTime to 60 as integer -- Ping for absence/presence of iPhone every 1 minute when iPhone is absent, "travel time" will be 3+ minutes
if iPhoneDetected is equal to true then set returnTime to 300 as integer -- Ping for absence/presence if iPhone every 5 minutes when iPhone is present, "travel time" will be 7+ minutes
end if
The idea is simple enough… the first time the On Idle block is “loop through” on or after 11:00 PM set the idle time to essentially 9 hours so that the script starts polling for the iPhone again at 8:00 AM the following day.
The problem that I am running into is that the above code DOES NOT result in the script starting to pole for the iPhone at 8:00 AM but rather DOES result in the script starting to pole for the iPhone at 9:00 AM the following day.
While it is possible that there is an error in my code[which i can’t see] I am beginning to think that the problem / result is caused by switching to the next day…that is, I am beginning to think that when the return time is set to 9 hours what is happening is that the “time counter” gets reset at midnight so that the 9 hour delay is measured from midnight rather than 11:00 PM.
Would appreciate any feedback / thoughts on this.
Thanks,
Joel
PS. Although I await the input of others, I do note that I did test my hypothesis last night by changing the returnTime to 8 hours and now the scripts works as wanted [i.e. the scripts starts pinging for the iPhone at 8:00 AM]. While this is good news, I would like to understand why this happens.
One follow up / outstanding item here… I am trying to change the icons that i) appear in the Dock and ii) the icons that appear in the dialog box.
I found the following icons https://www.dropbox.com/s/jm2mfcp1lj3ad . .icns?dl=0.
I tried changing them by i) replacing the package’s applet.ins file with the above file and renaming it to applet.ins [which does change the icons in the dialog boxes] and ii) copying and pasting the above icons over the app’s icons in FInder’ Get Info dialog box…none of these change the icons on the Dock…woud appreciate some guidance as to how best to do this?
Thanks in advance,
Joel
Hi! Don’t know if this would help but I think an application needs to be relaunched in order to see the icon updated in the Dock. Sorry if I’ve missed sth.
Hello.
If I remember correctly CMYS is correct, with regards to changing icons on the fly. What you can do, is to update a badge on your icon to signify different things. You’ll have to use AppleScriptObjC in order to do that.
This script is written by Shane Stanley, and you’ll have to read up on ASOC libraries in the Unscripted section on this site in order to use it.
use framework "Foundation"
use framework "AppKit"
on showDockBadge:theText
set theDockTile to current application's NSApp's dockTile()
theDockTile's setBadgeLabel:theText
theDockTile's display()
end showDockBadge:
Assuming you have a suitable .icns file, put it in the applet’s /Contents/Resources/ folder. Then open its /Contents/Info.plist file in a text editor. It’s an XML file, and you’ll see something like this:
<key>CFBundleIconFile</key>
<string>applet</string>
Change “applet” to the name of your new icon file.
@CMYS and McUsrII, appreciate the response and note that I not only restarted the app but also restarted my MBA and still the icon did not change in the dock [i.e. it did change in the display dialog messages but not in the dock]…with respect to the related code thanks, it has been added to my list of readings!
Shane, thanks, will give that a go and let you know…
Shane, tried and, unfortunately, failed…specifically, the icons in the display dialog messages have been successfully changes but the dock icons has not been changed…any other ideas?
Thanks again,
Joel
It can take time to filter through. Remove it from the Dock, put the original in the Applications folder, then add it to the Dock from there.
Shane, apologies but I am confused…move what from the dock and put what in the applications folder…for example, do you want me to:
Close the application which will remove it from the dock [i.e. I don’t yet have the application pinned to the dock].
Move the applet to the applications folder [i.e. currently the applet is in a folder other than the applications folder]
Restart the application and – assuming the icon change is successful – then pin it to the dock.
Sorry for the confusion but I just want to be clear as to what you are suggesting.
Thanks,
Joel
That’s a good start. Icons are associated with application bundle IDs, and the OS usually scans for them in the Applications folders and subfolders. Once the database is updated, you can move them.
But sometimes the database isn’t in a great state. You may have to try duplicating the app, or restarting the Mac.
Shane, appreciate that, will give it a go and come back to you later in the day as I need to leave for work now.
Have a good evening,
Joel
Shane:
What can I say other than I have my priorities right in that I decided to stay home an extra 5 minutes and try your suggestion which worked…worth noting is that moving / putting the applet it in the Applications folder was the missing link because the applet icon changed as soon as I put it there then, as you suggested, I was able to move it back!
With much thanks,
Joel