Elevate Your JOSM Experience on MacOS with Dark Mode
Posted by darkonus on 28 August 2023 in English.Hello! Today, I want to share a handy script that can enhance your experience with JOSM on MacOS by enabling a dark mode theme. Dark mode not only looks sleek but can also reduce eye strain, especially during late-night mapping sessions.
Note: This script is specifically for MacOS users.
Step 1: Download JOSM
If you haven’t already, download the latest version of josm-tested.jar here. Save it to a location on your Mac.
Step 2: Install the FlatLaf Plugin
FlatLaf is a fantastic plugin that allows you to apply dark themes to Java applications. After installing the plugin and restarting, go to the menu and select the dark theme: JOSM → Settings → Display → Look and Feel → FlatLaf Darcula
Step 3: Create and Run the Script
Now, let’s create a script that will launch JOSM with a dark theme. Open your favorite text editor and paste the following code:
shell
#!/bin/zsh
java -Dapple.awt.application.appearance=NSAppearanceNameDarkAqua -Xmx7168m -jar /Users/YourUsername/Documents/josm-tested.jar
Make sure to replace YourUsername
with your actual MacOS username. This script does the following:
#!/bin/zsh
: Informs your system to use the Zsh shell to execute the script.java -Dapple.awt.application.appearance=NSAppearanceNameDarkAqua -Xmx7168m -jar /Users/YourUsername/Documents/josm-tested.jar
: Launches the Java runtime with dark mode enabled, allocates 7168MB (or 7GB) of RAM to JOSM (you can adjust this value), and specifies the path to your JOSM JAR file.
Step 4: Save and Make the Script Executable
Save this script with a .command
extension, for example, josm-dark-mode.command
. To make it executable, open your terminal, navigate to the directory where you saved the script, and run the following command:
shell
chmod +x josm-dark-mode.command
Step 5: Execute the Script
Now, you can simply double-click josm-dark-mode.command, and JOSM will launch with a beautiful dark theme, thanks to the FlatLaf plugin and the MacOS appearance setting.
Enjoy your enhanced JOSM mapping experience with the dark mode theme. Happy mapping, and may your edits be as precise as ever!
Discussion
Comment from vorpalblade on 29 August 2023 at 14:44
A couple of notes:
-Dapple.awt.application.appearance=NSAppearanceNameDarkAqua
is necessary to make the title bar dark. If you don’t care about that, you can skip the JVM argument and use the standard methods for starting JOSM. Alternatively, if you installed JOSM from the macOS package, you can edit/Applications/JOSM.app/Contents/app/JOSM.cfg
(note: if installed per-user, prefix/Applications
with${HOME}
) and addjava-options=-Dapple.awt.application.appearance=NSAppearanceNameDarkAqua
to the[JavaOptions]
section. You will have to do that on every update, I believe.java -Dapple.awt.application.appearance=NSAppearanceNameDarkAqua -Xmx7168m -jar /Users/YourUsername/Documents/josm-tested.jar
is reallyjava -Dapple.awt.application.appearance=NSAppearanceNameDarkAqua -Xmx7168m -jar $PATH_TO_JOSM_JAR
. You can replace/Users/YourUsername
with${HOME}
.Beyond that, I would check and see if it would be possible to automatically add that system property at startup from either the flatlaf plugin or in JOSM core, if there is an easy way to determine that a theme is “dark” without hardcoding class names.
Comment from darkonus on 29 August 2023 at 16:00
vorpalblade, thank you! All of your notes are valuable. I just didn’t want to focus on the details.
As for me, it would be great to have a universal dmg with both x86 and Apple Silicon support. But as far as I understand, this is not possible yet.
So far, I’m using the azul JDK and the following script to run JOSM.
Comment from MxxCon on 29 August 2023 at 22:19
Why mess around with command line parameters if you can just change it in josm’s display menu?
Comment from vorpalblade on 29 August 2023 at 22:47
@MxxCon: The command line parameter sets the window title bar to a dark color. It could also be
-Dapple.awt.application.appearance=system
which should follow the system dark/light setting.Comment from darkonus on 30 August 2023 at 05:11
Unfortunately, the FlatLaf theme does not switch from white to dark automatically. Even worse, after changing the theme to another one, you have to restart JOSM.
My guide for those who just want a consistent dark theme in JOSM on MacOS.