Mac OS X lid open/close event log - macos

Simple request really, I would like to record whenever the lid of my MacBook Pro has been opened or closed. Preferably a free app, but a minimally priced one would be fine too. A nice to have would be if I could choose more events like system startup or shutdown to log, but the important events to me are lid open and close.

Check SleepWatcher 2.2 from http://www.bernhard-baehr.de
It has sources.

Related

Can my program or script ask Windows 10 about keyboard or mouse activity?

I want to write a program or script that looks at how long the user has been idle. How long since the last keyboard or mouse activity. What features of Windows 10 can I use for that?
Yes, you can use the Windows API function GetLastInputInfo, which returns the time of the last input event in milliseconds.
It's not system-wide across all running sessions, but provides information for the current session only. It's supported from Windows 2000 up.

How to run an Applescript when a mouse is connected?

I have an Applescript that changes my mouse tracking speed that I want to run whenever I connect a mouse to my laptop. How do I do something like this? I was thinking of making it into an application and just clicking it whenever I need it, but I feel like there's a better way to do it.
This answer mentions launchd's ability to detect and launch an app when usb devices are connected. Sounds like what you are after.
Execute an application on Mac OS X when a particular type of USB device is connected?
You can get your specific product is, to use in the plist file, from System Profile->USB
Hope that helps.

Forgotten where I left an automatic shutdown script on Mac OSX

I let me Parallels Desktop running Windows XP to start automatically during mac log-in. And to start Windows upon launch to let my dad use his WinXP by just pressing the power button, bypassing the Mac login window and desktop completely. When he shuts down Windows, Parallels closes.
I seem to remember I have a trigger to shut down mac as soon as Parallels closes. But I don't remember where... I have an AppleScript that tells Finder to shut down. I understand that. But now the problem is Mac shuts down AS SOON AS it boots up every time! I can't figure out what's triggering the shutdown... And I've run out of places to look.
It seems like a normal shut down rather than a fatal error. Seems like someone has chosen the 'Shut Down' command as soon as Mac starts up. So could mac gurus suggest places I should look -- what might have triggered this -- I'm pretty sure it's Parallels-related. Maybe there is something in the Package Contents linked to the shutdown script??
You added the Applescript (that shut down the mac) to login items

Strange behavior in user idle detection in Adobe Air on Mac

I've got an Adobe AIR application written in pure AS3 that has some functionality that happens when the user is idle and then returns to the normal state when the user returns. I'm detecting this activity with the following code:
NativeApplication.nativeApplication.idleThreshold = 180;
NativeApplication.nativeApplication.addEventListener(Event.USER_IDLE, onUserIdle);
NativeApplication.nativeApplication.addEventListener(Event.USER_PRESENT, onUserPresent);
The onUserIdle method is called after 3 minutes as it should be, but then the onUserPresent event is fired almost immediately afterwards. I'm talking milliseconds later. This happens without any user input whatsoever. The bizarre thing is that this does not occur on Windows - only on OSX. And it happens on all flavors of OSX going back to 10.6.3.
Adobe's documentation is incredibly vague on how those events are determined, so I'm not sure if there is something I can do at the system level to fix the problem. Does anyone have any experience with this issue, and if not, any other suggestions on how I can detect user idleness even when the app does not have focus?
Just to preempt the suggestion, I cannot use mouse/keyboard listeners to simulate the same behavior because they do not work if the application loses focus, whereas the NativeApplication events still fire. I've also used NativeProcess to get the output of ioreg to get the hardware idle time as reported by the system, but it does not appear to be affected by the mouse.
I really appreciate any assistance.
Edit: I just discovered that this does not occur when the application is run in an Administrator account on OSX. It only happens in a User account, which only serves to confuse me more.
I figured out what the issue is. When the USER_IDLE event is fired in a user account, we did several things - one of which was forcibly kill the Dock in order to make sure it was hidden from the screen. For whatever reason, this resets the internally available idleThreshold count. This was not only happening in AIR - it was also happening when monitored through Terminal and it appears there is absolutely nothing that can be done to stop it. The solution was to stop killing the dock. Everything magically worked after that.

How do I use stackshot to debug my application?

I've recently been told about a useful debugging tool on Mac OS X called stackshot, however I don't know how to invoke it. My understanding from the documentation is that it runs as a daemon, but the man page also reads as if it can be invoked from the command line. How would I go about leveraging stackshot for my currently-running application?
sudo /usr/libexec/stackshot -i
Stackshot is intended for debugging system-wide issues (deadlocks etc), not single applications; as such it creates a stack dump of the entire system, not a single application.
With the default configuration, this will create a stack shot in /Library/Logs/stackshot.log
Apple has asked me to produce a Stackshot on my iOS device. To do so, when the issue occurs, simultaneously hold down and release the Home and a volume button.
Then, synch your device with iTunes.
After synching, your stackshot log file will be stored on the computer. I don't know where it is in Windows, but on a Mac it is in:
~/Library/Logs/CrashReporter/MobileDevice//stacks-yyyy-mm-dd-xxxxxx.log
stackshot no longer appears to be included with OS X, at least not in 10.11. However you can still take a sample of your app using the /usr/bin/sample tool.
This is also accessible using Activity monitor:
Open Activity Monitor
Double click your app
Click the Sample button in the bottom left corner
That will allow you to see what is currently happening in your app so that you can debug CPU usage issues without running the app from Xcode.

Resources