macos

Why is my MacBook warm when the lid is closed (in sleep mode)?

When I woke up last night it was a little windy outside, so I decided to unplug my MacBook Pro because the power tends to flicker here. When I picked up the MacBook I noticed that it was very warm, even though the lid was closed and it was in sleep mode. This morning I decided to dig into the “Why is my MacBook hot even though the lid is closed and it’s in sleep mode” question.

Notes on looking at MacOS application/process memory usage

Very briefly, I spent a little time today trying to understand how much memory/RAM a Java/Swing application was really using, and these are my notes from that excursion. Note that the app is bundled as a MacOS/Java app I named AlPad, but from some system perspectives it is only seen by the name JavaAppLauncher. Here are my notes, which will hopefully be useful to me in the future:

How to use the Linux ‘scp’ command without a password to make remote backups

Summary: How to create a public and private key pair to use ssh and scp without using a password, which lets you automate a remote server backup process.

Over the last two years I've ended up creating a large collection of websites and web applications on a variety of Linux servers that are hosted with different companies like GoDaddy and A2 Hosting. I recently embarked on a mission to automate the backup processes for all these sites, and as a result of this effort, I thought I'd share what I've learned here.

How to fire MacOS notifications with AppleScript and Scala alvin July 15, 2019 - 7:44am
Table of Contents1 - A “Hello, world” MacOS AppleScript notification2 - AppleScript: Mac notification with a sound3 - How to add a title and subtitle to your notification4 - Running from Scala (or Java)5 - See also6 - Summary

Summary: This tutorial demonstrates how to fire MacOS system notifications with AppleScript and Scala (or Java).

In this article it helps if you already know a little bit about AppleScript, though that’s not completely necessary. Near the end of the tutorial I show how to invoke the AppleScript code using Scala, so feel free to skip down to there if you just want to see that — you can always read the stuff at the top for reference later.

Scala error: Shell scripts hang indefinitely on MacOS 10.13 and 10.14 (won’t run)

If you run into a problem where a Scala shell script won’t run on MacOS — it hangs indefinitely without doing anything — hopefully this bug report will help. The solution is to change this line at the beginning of the Scala shell script:

exec scala -savecompiled "$0" "$@"

to this:

exec scala -nocompdaemon -savecompiled "$0" "$@"

I just had this problem with Scala 2.12.x and Java 8 running on MacOS 10.14.4, and I can confirm that adding -nocompdaemon solved the problem for me.

Did you know: You can use JavaScript for macOS scripting alvin June 22, 2019 - 5:35pm

I learned today that you can use JavaScript for “scripting” on macOS. These docs say that has been the case since Mac OS X 10.10.

Linux/Unix: How to copy a directory and save the date/time file information

If you need to copy a directory on Unix/Linux and want to preserve the date/time information while copying the directory and files, use the -p option to save the date/time information, and the -r option to copy the directory properly. For instance, I just used this cp command to copy a directory named OldDir to a new directory named NewDir, while retaining all of the date/time file information:

A shell script to change between MacOS dark mode and light mode alvin April 16, 2019 - 5:31pm

If you want to create a shell script so you can change between MacOS dark mode and light mode from the Terminal (Unix) command line, put this source code in a file and name it something like dark:

osascript -e \
'tell application "System Events" to tell appearance preferences to set dark mode to not dark mode'

Then make that file executable, and make sure it’s on your PATH. Now you can type dark to toggle back and forth between dark mode and the regular light mode:

Jeyes, a Java version of Xeyes

Jeyes, a Java version of Xeyes

In my spare time back in 2011 I created a Java version of the old Unix/X-Windows “Xeyes” application. If you ever used Xeyes, you know it as a set of eyes that are displayed on-screen, and follow the mouse cursor as you move it around.

Now in 2019 I just brought it back to life, and here’s a 56-second video that shows how it works: