macOS Big Sur: Poor Screen Quality When Connecting to Old Monitor via HDMI

PROBLEM

You have a shiny Mac laptop running macOS Big Sur. This laptop is connected to an old external monitor via HDMI. The screen quality looks pixelated and fuzzy.

Running font smoothing (as below) doesn’t fix the problem:

defaults -currentHost write -g AppleFontSmoothing -int 3

You are poor enough to buy a new 4K monitor.

SOLUTION

The usage of HDMI seems to fool macOS Big Sur, thinking your old monitor is a glorious new TV. This causes macOS to use YPbPr instead of RGB mode.

The fix is to perform Extended Display Identification Data (EDID) override to force macOS to use RGB mode.

Some instructions on the web are inaccurate. There’s no need to reboot into Recovery Mode to disable System Integrity Protection (SIP) via csrutil first.

Instead, run the following command:

sudo mkdir -p /Library/Displays/Contents/Resources/Overrides
cd /Library/Displays/Contents/Resources/Overrides
sudo curl -O https://gist.githubusercontent.com/ejdyksen/8302862/raw/patch-edid.rb
sudo ruby patch-edid.rb

Reboot the laptop.

macOS + Eclipse: The ‘X’ Executable Launcher was Unable to Locate its Companion Shared Library

PROBLEM

When attempting to launch Eclipse-based app (ex: MyApp.app) on Mac, the following error is thrown:-

The 'MyApp' executable launcher was unable to locate 
its companion shared library.

SOLUTION

This problem seems to occur on macOS Sierra and later.

When unzipping the app, the lingering extended attributes prevent the app from launching.

To fix this, run the following command to remove these extended attributes:-

xattr -c MyApp.app

Then, double click MyApp.app to launch it.

Synology NAS: Running CrashPlan in Docker Container

BACKGROUND

The reason to run CrashPlan in Docker container is to prevent any future Synology’s DSM updates from breaking the CrashPlan app.

Let’s assume the Synology NAS IP address is 1.2.3.4.

STEPS

Diskstation Manager

Log into Diskstation Manager: http://1.2.3.4:5000

Install Docker.

Package Center -> Utilities -> Third Party -> Docker

Mac

SSH into Synology NAS.

ssh admin@1.2.3.4

Install CrashPlan Docker container.

sudo docker pull jrcs/crashplan

Run CrashPlan Docker container. In this example, we want to backup photo and video directories.

sudo docker run -d --name CrashPlan \
 -p 4242:4242 -p 4243:4243 \
 -v /volume1/photo:/volume1/photo -v /volume1/video:/volume1/video \
 jrcs/crashplan:latest

Back to Diskstation Manager

Get authentication token from the running CrashPlan.

Docker -> Container -> CrashPlan -> Details -> 
Terminal -> Create -> bash

Run command:-

cat /var/lib/crashplan/.ui_info

The following text are printed:-

4243,########-####-####-####-############,0.0.0.0

Copy ########-####-####-####-############ to somewhere first.

By default, CrashPlan allocates 1GB of memory. The recommendation is to allocate 1GB of memory per 1TB of storage to prevent CrashPlan from running out of memory. In this example, we are going to increase it to 3GB.

Edit /var/crashplan/conf/my.service.xml.

vi /var/crashplan/conf/my.service.xml

Change the following line:-

<config ...>
	...
	<javaMemoryHeapMax>3072m</javaMemoryHeapMax>
	...
</config>

Edit /var/crashplan/app/bin/run.conf.

vi /var/crashplan/app/bin/run.conf

Change the following line:-

SRV_JAVA_OPTS="... -Xmx3072m ..."                                                         
GUI_JAVA_OPTS="..."

Stop CrashPlan Docker container.

Docker -> Container -> CrashPlan -> Action -> Stop

Enable auto-restart on CrashPlan Docker container.

Docker -> Container -> CrashPlan -> Edit -> General Settings -> 
Enable auto-restart -> OK

Start CrashPlan Docker container.

Docker -> Container -> CrashPlan -> Action -> Start

Back to Mac

Download and install CrashPlan software.

Disable CrashPlan service since the UI acts as a client.

sudo launchctl unload -w /Library/LaunchDaemons/com.crashplan.engine.plist

Edit /Applications/CrashPlan.app/Contents/Resources/Java/conf/ui.properties.

sudo nano /Applications/CrashPlan.app/Contents/Resources/Java/conf/ui.properties

Uncomment serviceHost and update Synology NAS IP address.

#Fri Dec 09 09:50:22 CST 2005
serviceHost=1.2.3.4
#servicePort=4243
#pollerPeriod=1000  # 1 second
#connectRetryDelay=10000  # 10 seconds
#connectRetryAttempts=3
#showWelcome=true

#font.small=
#font.default=
#font.title=
#font.message.header=
#font.message.body=
#font.tab=                                  

Edit /Library/Application Support/CrashPlan/.ui_info.

sudo nano "/Library/Application Support/CrashPlan/.ui_info"

Replace the authentication token with the value from above step. Replace IP address with Synology NAS IP address.

4243,########-####-####-####-############,1.2.3.4

Finally, run CrashPlan app to view the backup process.

OS X + Sed: “extra characters at the end of l command” Error

PROBLEM

When executing the following command on OS X…

sed -i 's/megatron/pony/g' /path/to/file.txt

… the following error occurs:-

sed: 1: "/path/to/file.txt": extra characters at the end of l command

SOLUTION

Unlike Ubuntu, OS X requires the extension to be explicitly specified. The workaround is to set an empty string:-

sed -i '' 's/megatron/pony/g' /path/to/file.txt

… and now, Megatron has transformed into a pony.

Mac OS X: Setting Default Java Version

Let’s assume we have installed JDK 7 or JDK 8, and we want to set the default Java version. There are several ways to set default Java version. This is by far the easiest way without the need to look for the installed path or mess around with symlinks.

First, let’s make sure we are not on crack and we indeed installed the version we want:-

➜  ~  /usr/libexec/java_home -verbose
Matching Java Virtual Machines (3):
    1.7.0_25, x86_64:	"Java SE 7"	/Library/Java/JavaVirtualMachines/jdk1.7.0_25.jdk/Contents/Home
    1.6.0_51-b11-457, x86_64:	"Java SE 6"	/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
    1.6.0_51-b11-457, i386:	"Java SE 6"	/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home

In this example, we are going to use JDK 1.7 as our default Java version. Open up the startup file (.bashrc, .zshrc, etc…) and enter this line:-

export JAVA_HOME="`/usr/libexec/java_home -v '1.7*'`"

Restart Terminal and verify the Java version:-

➜  ~  java -version
java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)
➜  ~  javac -version
javac 1.7.0_25