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.
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:
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.
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.
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:
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.
Table of Contents
- macOS: crontab, launchd, and launchctl
- Running a simple command every minute with Mac launchd
- 1) Move to the $HOME/Library/LaunchAgents directory
- 2) Create a Mac plist file to describe your job
- 3) Tell MacOS about your Mac plist launchd file
- 4) How Mac launchd works with system reboots
- An important note about root and sudo access
- MacOS launchd, launchctl, and plist resources
- 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.”
This is a decent article about how to start the Mac/MacOS screensaver using a keyboard shortcut (keystroke).
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.