I thought this would be straightforward. Amphetamine uses ‘session is active’ to check if a session is, well, active. I want to use that and then do stuff based on whether it returns true/false. Here’s what I have:
tell application "Amphetamine"
set SessionStatus to (session is active)
if SessionStatus is "false" then
log "Amphetamine is not running"
end if
if SessionStatus is "true" then
log "Amphetamine is running"
end if
end tell
And here’s what’s returned - you’ll notice that the logging isn’t happening. Seems like the script checks session activity and then nothing else.
tell application "Amphetamine"
session is active
--> false
end tell
My first thought is that you may be looking at Script Editor’s “Result” pane. If you select “Show Log” in the “View” menu and then select any of the tabs in the lower pane other than “Result”, you should be able to see the log results. Alternatively, you could try “Log History” in the “Window” menu.
Ah! I’ve just noticed that your script has “true” and “false” in quotes. Try removing the quotes. The (session is active) result’s a boolean, not text.
tell application "Amphetamine"
set SessionStatus to (session is active)
if SessionStatus is false then
log "Amphetamine is not running"
end if
if SessionStatus is true then
log "Amphetamine is running"
end if
end tell
Or:
tell application "Amphetamine"
set SessionStatus to (session is active)
if (SessionStatus) then
log "Amphetamine is running"
else
log "Amphetamine is not running"
end if
end tell