mac-os-x

recent posts related to the mac os x operating system

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.

How to fire MacOS notifications with AppleScript and Scala

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.

A shell script to change between MacOS dark mode and light mode

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:

How to batch-convert Mac BMP, JPG, PNG image files, free

Mac batch image conversion FAQ: How can I “batch convert” images from one image format to another on a Mac, such as BMP to JPG, or PNG to JPG?

As I mentioned in my earlier Mac batch image resizing tutorial, the Mac OS X Automator application is my new best friend. Besides letting you easily batch resize images very easily, the Automator also lets you easily batch create thumbnails for images, and also lets you convert images from one image format to another (BMP to JPG, PNG to JPG, etc.).

Here’s a quick look at how to use the Mac Automator to “batch convert” images from one file format to another, including image file formats like BMP, GIF, JPEG, and PNG.

TextMate TODO tag syntax highlighting alvin January 12, 2019 - 5:17pm

As a brief note to self, I like the way the TODO tag is highlighted when using TextMate, so I dug around to see how it worked so I can make other words be highlighted the same way it is. The short answer is that in TextMate, click the Bundles menu, select Edit Bundles, then scroll down to select TODO near the bottom of the list, then Language Grammars and TODO. The last few steps are shown in the image.

How to convert HTML to AsciiDoc with Pandoc

If you ever need to convert HTML to AsciiDoc, I just used this Pandoc command and it seems to work well:

pandoc --wrap=none -f html -t asciidoc myfile.html > myfile.adoc

The wrapping part of that command isn’t 100% necessary, but if you don’t use it, Pandoc will wrap the plain paragraph text, which I don’t like because I’ll be editing the resulting AsciiDoc text.

Here’s some of the AsciiDoc text that this command generated:

How to convert Asciidoc to HTML

As a brief note to self, if you need to convert an Asciidoc file named test1.adoc to HTML format, this command works:

asciidoc -o test1.html test1.adoc

Of course a key here is that you need the asciidoc command installed. I installed it on my Mac with Homebrew, something like brew install asciidoc. I don’t like the HTML that this approach generates, so I’ll keep looking for something better.

Mac crontab: Creating MacOS startup jobs with crontab, er, launchd

Table of Contents1 - macOS: crontab, launchd, and launchctl2 - Running a simple command every minute with Mac launchd3 - 1) Move to the $HOME/Library/LaunchAgents directory4 - 2) Create a Mac plist file to describe your job5 - 3) Tell MacOS about your Mac plist launchd file6 - 4) How Mac launchd works with system reboots7 - An important note about root and sudo access8 - MacOS launchd, launchctl, and plist resources9 - MacOS startup jobs: cron and crontab, launchd and launchctl

MacOS crontab FAQ: How do I run a Unix job (or shell script) through the MacOS crontab facility? I keep trying to edit my Mac crontab file, but my Mac won't save my crontab changes, or run my program.

Back to top

macOS: crontab, launchd, and launchctl

Way back when (~2012-2014), I found that the Mac crontab command was deprecated on MacOS, and the Apple documentation encouraged you to use their launchd facility. Here’s a blurb from Apple's crontab man page:

“Darwin note: Although cron(8) and crontab(5) are officially supported under Darwin, their functionality has been absorbed into launchd(8), which provides a more flexible way of automatically executing commands. See launchctl(1) for more information.”