Theming or using Dark Mode

Everything related to our flagship word processor.
Post Reply
Vanceone
Posts: 132
Joined: 2013-05-03 07:06:31

Theming or using Dark Mode

Post by Vanceone » 2018-12-27 13:24:25

So I see all the appearance options in the Preferences, but I was curious: is there a way to save a "theme" or a set of colors, and apply them all at once? More specifically, I am trying out Dark Mode on Mojave, and was hoping to skin Nisus Writer Pro to match it better. But making each change one at a time is tedious, and what happens if I switch back to light mode?

Being able to load and save a particular color scheme would be useful as well; sometimes I write late at night and prefer a less bright writing environment, for instance. Loading in a "late night" color scheme would be fantastic.

Am I missing something and this can be done, or is this a feature request? Even an XML or plist to change would be great! I don't think the macro language can do this, but maybe I'm wrong.

Thanks in advance.

User avatar
martin
Official Nisus Person
Posts: 4422
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: Theming or using Dark Mode

Post by martin » 2019-01-04 13:25:28

There's no easy way to accomplish what you'd like, so your request breaks down into two feature requests:

1. Add official support for Mojave's Dark Mode.
2. Add a new feature to save and load interface themes.

Your request definitely makes clear a desire for #1, to support Dark Mode. However, if Nisus Writer adds that would you still want request #2, for saving and loading custom themes?

If you really want to pursue this you could manually swap some preferences on disk to accomplish your goal. If you establish a "synchronized setting location" in your Nisus Writer preferences then nearly all of your app settings will be stored in that folder. That includes any customized colors, which are saved in the file "preferences.plist" on disk. The steps to set this up would look something like this:

1. Configure your Nisus Writer color preferences a certain way. Let's call it "day mode".
2. Quit Nisus Writer.
3. Find the "preferences.plist" file on disk and make a copy. Let's say you name it "day mode.plist".
4. Relaunch Nisus Writer.
5. Configure your Nisus Writer color preferences another way. Maybe it's called "moon mode".
6. Quit Nisus Writer and copy the external preferences plist file again.

Now that you have both plists handy, you can swap between them. The workflow would be:

1. Quit Nisus Writer.
2. Replace the plist on disk.
3. Relaunch Nisus Writer and see your colors change to match.

Obviously this has many drawbacks: quitting the app is intrusive, your other non-color preferences won't stay updated unless you change them in both plist files, it doesn't really match Dark Mode, and it's not automatic.

Vanceone
Posts: 132
Joined: 2013-05-03 07:06:31

Re: Theming or using Dark Mode

Post by Vanceone » 2019-01-04 22:33:15

Yes, official support for "Dark Mode" would be nice.

That being said, a way to load a theme would also be nice. For instance, right now I am writing this at 11:30 at night, and frankly, I'd like things to be a bit darker; maybe even black background and white text. Of course, I might want to change it in the morning. Also, while I don't use the fullscreen mode I suspect that some people would love to adjust the UI while in that mode to better suit their needs, but use a less intrusive color scheme while in regular page view or whatever. While it is nice to know the preferences plist can be used to manually do this, a better theme solution would be nice.

Probably fairly low on the priority list, to be honest, though Dark Mode seems like it would be a good idea to implement soon.

adryan
Posts: 222
Joined: 2014-02-08 12:57:03
Location: Australia

Re: Theming or using Dark Mode

Post by adryan » 2019-01-05 02:43:33

G'day, Vanceone et al

I thought I'd write a short AppleScript script to do the job of swapping the plist files for different color preferences. (You need to go outside Nisus Writer because you need to quit NWP as part of the process.) But I'm afraid it didn't work. So I tried Martin's method manually, just to check, but that didn't work either.

I take it that the plist file in question is not that in the higher-level Preferences folder people might normally see but rather that buried more deeply in the Containers folder:–

~/Library/Containers/com.nisus.NisusWriter/Data/Library/Preferences/com.nisus.NisusWriter.plist

Swapping this file in and out does not work. A quick perusal of its contents (in BBEdit) did not reveal to me anything relevant to page color (which was what I altered for testing purposes — via NWP > Preferences > Appearance > Colors > Document Views > Page color).

I'd say I was groping in the dark, but I don't have Mojave. :D

Cheers,
Adrian
MacBook Pro (mid-2014)
macOS Sierra 10.12.6
Nisus Writer user since 1996

ToddO
Posts: 20
Joined: 2015-10-18 14:25:32

Re: Theming or using Dark Mode

Post by ToddO » 2019-01-05 05:08:39

A theme capability would be great. It would probably allow more flexibility than only complying with light/dark mode.

In the meantime, I have a sort of work around for this that I use that may help. I theme the "Full Screen" to be a very dark gray with very light gray text. I leave the page view white (actually, I use the slightest gray here also to save my eyes.)

With this setup, I can use page layout view for those times I want a light background. When my eyes need a darker background, I switch from page view to Draft, then Full screen, and have the dark background.

User avatar
martin
Official Nisus Person
Posts: 4422
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: Theming or using Dark Mode

Post by martin » 2019-01-07 11:16:03

That's right, Nisus Writer already allows the user to choose separate custom colors for Full Screen mode.
adryan wrote:
2019-01-05 02:43:33
I thought I'd write a short AppleScript script to do the job of swapping the plist files for different color preferences ... But I'm afraid it didn't work
The path you quoted is not correct. That old-style preferences file is no longer stores most of Nisus Writer's settings.

Did you choose a "synchronized settings location" in your Nisus Writer preferences? If so then that's the location you should consult, where the plist file swap should occur. That's the best location to use. For example:

Code: Select all

~/Dropbox/Nisus Writer Settings/preferences.plist
If you don't have a customized settings location, then you'll need to use the plist file inside Nisus Writer's sandbox. Here's the path:

Code: Select all

~/Library/Containers/com.nisus.NisusWriter/Data/Library/Application Support/Nisus Writer Pro/Settings/preferences.plist

adryan
Posts: 222
Joined: 2014-02-08 12:57:03
Location: Australia

Re: Theming or using Dark Mode

Post by adryan » 2019-01-07 22:31:23

G’day, Vanceone al

OK. I followed the White Rabbit (aka Martin) down the rabbit hole and deep in the Warren of Wonderland I came across the Mad Hacker waving a piece of paper in his hand. Mirabile dictu, it was a script!

Code: Select all

— Script name: Toggle Day and Night

— This script toggles the Preferences file in Nisus Writer Pro between Day and Night modes.

(* NOTE: Before using the script for the first time:–

	(1) Replace "XXXX" in the "set user_directory" line in the script with the name of your own User directory.
	
	(2) In the Finder, navigate to the Settings folder [see filepath below], create a new folder inside this Settings folder, and name the new folder "Circadian".
	
	(3) Move a COPY of the preferences.plist file from the Settings folder to the Circadian folder, and rename the copy in the Circadian folder to "original_preferences.plist". This latter file is not needed by the script: it's just there in case you want to revert everything at some stage.
	
	(4) Open Nisus Writer Pro, alter your settings in Nisus Writer Pro > Preferences > Appearance to reflect your daytime preferences, then quit Nisus Writer Pro.
	
	(5) In the Finder, go to preferences.plist file in the Settings folder, open its Get Info window, and insert "day" [without the quotes] in the Comments field.
	
	(6) Move a COPY of the preferences.plist file from the Settings folder to the Circadian folder, and rename the copy in the Circadian folder to "day_preferences.plist".
	
	(7) Move another COPY of the preferences.plist file from the Settings folder to the Circadian folder, and rename this copy in the Circadian folder to "previous_preferences.plist". This latter file is not really used by the script: it's just there in case you want to revert to the immediately preceding situation at some stage. The file does need to be created because the script refers to it.
	
	(8) Open Nisus Writer Pro, alter your settings in Nisus Writer Pro > Preferences > Appearance to reflect your nighttime preferences, then quit Nisus Writer Pro.
	
	(9) In the Finder, go to preferences.plist file in the Settings folder, open its Get Info window, and replace "day" with "night" [without the quotes] in the Comments field.
	
	(10) Move a COPY of the preferences.plist file from the Settings folder to the Circadian folder, and rename the copy in the Circadian folder to "night_preferences.plist". *)


tell application "Nisus Writer Pro"
	quit saving ask
end tell

tell application "Finder"
	
	-- Set name of User directory.
	set user_directory to "XXXX"
	
	-- Establish the folders we wish to work with.
	set settings to folder "Settings" of folder "Nisus Writer Pro" of folder "Application Support" of folder "Library" of folder "Data" of folder "com.nisus.NisusWriter" of folder "Containers" of folder "Library" of folder user_directory of folder "Users" of startup disk
	set Circadian to folder "Circadian" of settings
	
	set current_preferences to file "preferences.plist" of settings
	set previous_preferences to file "previous_preferences.plist" of Circadian
	set day_preferences to file "day_preferences.plist" of Circadian
	set night_preferences to file "night_preferences.plist" of Circadian
	
	if comment of current_preferences contains "day" then
		duplicate night_preferences to settings
		move current_preferences to Circadian
		delete previous_preferences
		set name of file "preferences.plist" of Circadian to "previous_preferences.plist"
		set name of file "night_preferences.plist" of settings to "preferences.plist"
	else if comment of current_preferences contains "night" then
		duplicate day_preferences to settings
		move current_preferences to Circadian
		delete previous_preferences
		set name of file "preferences.plist" of Circadian to "previous_preferences.plist"
		set name of file "day_preferences.plist" of settings to "preferences.plist"
	end if
	
end tell

tell application "Nisus Writer Pro"
	activate
end tell
The script is an AppleScript script, but the forum would not permit attachment of a file with the .scpt extension, so the above text would need to be copied and pasted into a Script Editor document which is then named (for example) “Toggle Day and Night”.

The script toggles the preferences.plist file (in the location indicated by Martin — thanks for that) between Day and Night modes, as defined by the user. The technique it employs could easily be adapted for other situations. It relies on the trick of using the Comments field of the relevant Get Info windows to keep track of where we are up to in the toggling process (since we don’t want to rename the main preferences.plist file lest it become inaccessible to the application).

In the script is a preamble listing some (easy) tasks to perform before running the script for the first time.

Since the script calls for the quitting of Nisus Writer, it can’t be called from a NWP macro. The next best thing is to place it here:–

Code: Select all

~Library/Scripts/Applications/Nisus Writer Pro/Toggle Day and Night.scpt
Thus situated, it is readily callable from the bottom of the Scripts menu (under the scroll icon in the top Menu Bar) whenever Nisus Writer Pro is the active application.

There are a few caveats. While you are asked whether you want to save any open NWP files, there is no error-trapping. (But following the steps in the preamble creates a backup file in case you need it.) I am not sure whether the Circadian folder would survive installations of Nisus Writer updates and upgrades in its present location, so it might be prudent to store a copy elsewhere in case it goes missing. That copy would not necessarily be the very latest version, but it could save some work. Altering other Preferences in NWP would have them reflected only in the currently active mode (Day, say). To have them operate also in the other mode (in this case, Night), you would have to switch to the other mode and alter your settings there similarly.

I hope this helps. Gotta get back to that party.

Cheers,
Adrian
MacBook Pro (mid-2014)
macOS Sierra 10.12.6
Nisus Writer user since 1996

User avatar
martin
Official Nisus Person
Posts: 4422
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: Theming or using Dark Mode

Post by martin » 2019-01-08 16:20:03

adryan wrote:
2019-01-07 22:31:23
I followed the White Rabbit (aka Martin) down the rabbit hole
It is quite a deep way down! 🐰🌀 Especially those crazy long sandbox container file paths.

Thanks for sharing your script, and enjoy that party!

Post Reply