SnapDock

Building from Source

CurrentPublication 1By @ZFordDev

Building SnapDock from Source

SnapDock is open source, so you're welcome to download the code, make changes and build your own version.

Maybe you want a different theme, a custom name, or a version that doesn't check for updates. Maybe you just want to see how everything works.

Whatever the reason, this guide will help you get started.

SnapDock V3 uses Electron, JavaScript, HTML and CSS. You don't need a complicated development environment or a frontend framework to work on it.

1. Before You Start

You'll need:

  • Git to download the repository.
  • Node.js 24 (recommended, matching the project's build environment).
  • npm, included with Node.js.
  • A Windows or Linux computer.

A code editor is useful too, but you're free to use whichever one you prefer.

SnapDock's official V3 builds target Windows and Linux. macOS is discussed further down because I'd love some help testing it.

Download the source

Open a terminal and clone the repository:

bash
git clone --branch main --single-branch https://github.com/ZFordDev/SnapDock.git
cd SnapDock

The main branch contains SnapDock V3.

The Phoenix branch is used for V4 development, so make sure you're working with the version you actually want.

Install dependencies

Run:

bash
npm install

This downloads the packages needed to build and run SnapDock.

Build and launch

First, bundle the renderer's JavaScript:

bash
node scripts/bundle.js

Then start SnapDock:

bash
npm start

You should now have SnapDock running directly from your source checkout.

Note: npm start doesn't automatically rebuild the renderer. If you change JavaScript modules, you'll need to run the bundling command again before restarting the application.

There isn't a built-in hot-reload workflow in V3.

2. Building an Application Package

Running from source is useful for development, but you can also create a standalone application.

Windows

On Windows, run:

bash
npm run build:win

This builds a Windows NSIS installer.

Linux

On Linux, run:

bash
npm run build:linux

This creates AppImage and Debian (.deb) packages.

Unpacked development build

If you want a packaged application without creating a normal installer, run:

bash
npm run build:dev

This creates an unpacked application for your current platform.

Build output is placed under the dist/ directory.

The Windows and Linux packaging commands also generate the required renderer bundle and build metadata, so you don't need to run those steps separately.

For the most predictable results, build Windows packages on Windows and Linux packages on Linux.

Cross-platform packaging hasn't been fully verified.

3. Making Your Own Theme

This is probably the easiest and most enjoyable way to customise SnapDock.

Themes are written in CSS, and you can change just about every part of the interface, including backgrounds, tabs, editor colours, Markdown styling and syntax highlighting.

SnapDock currently includes Light, Dark, Solarized, Arctic Dark and Forest.

If none of those suit you, make another!

Step 1 — Copy an existing theme

Open:

src/styles/themes/

You'll find the existing theme stylesheets.

For this example, we'll create a Lavender theme using Light as our starting point.

Copy:

src/styles/themes/light.css

And name the copy:

src/styles/themes/lavender.css

Inside the new file, change the theme selector from:

css
body.light-theme

To:

css
body.lavender-theme

SnapDock falls back to the Light theme when a theme variable is missing. This means you don't necessarily need to define every variable, but anything you leave out will use the Light theme's styling.

Step 2 — Choose your colours

You can now modify the variables to create your own appearance.

For example, these values can be added to the new stylesheet after copying and renaming the complete Light theme:

css
/* Lavender theme variables and styles */
body.lavender-theme {
  /* Core layout */
  --workspace-bg: #efedf7;
  --toolbar-bg:   #e7e2f2;
  --sidebar-bg:   #f5f2fa;
  --footer-bg:    #e7e2f2;

  /* Editor */
  --editor-bg:    #fffaff;
  --editor-text:  #30283d;
  --editor-text-secondary: #574c68;

  /* Borders */
  --border-color: #cfc4de;

  /* Markdown preview: code blocks */
  --code-bg:        #f0eaf7;
  --code-text:      #392d4c;
  --inline-code-bg: #eae2f3;

  /* Markdown preview: notes, warnings, tips */
  --note-bg:        #e9e2f9;
  --note-accent:    #7652a3;

  --warning-bg:     #fff1df;
  --warning-accent: #b97527;

  --tip-bg:         #e5f3ec;
  --tip-accent:     #34856a;

  /* Tables */
  --table-header-bg: #e9e1f2;
  --table-row-bg:    #fffaff;

  /* Global */
  background: var(--workspace-bg);
  color: var(--editor-text);

  /* Syntax highlighting */
  --hljs-bg:            #f0eaf7;
  --hljs-text:          #392d4c;
  --hljs-comment:       #81738f;
  --hljs-keyword:       #9450a6;
  --hljs-number:        #326b9b;
  --hljs-string:        #477450;
  --hljs-title:         #6a48aa;
  --hljs-variable:      #a15c40;
  --hljs-addition-bg:   #e5f3ec;
  --hljs-addition-text: #287454;
  --hljs-deletion-bg:   #fce6ed;
  --hljs-deletion-text: #aa4566;

  /* Tab styles */
  --tab-bar-bg:    #e7e2f2;
  --tab-idle-bg:   #ddd4eb;
  --tab-active-bg: #fffaff;
  --tab-text:      var(--editor-text-secondary);
  --tab-accent:    var(--note-accent);
  --tab-border:    var(--border-color);

  --footer-bg-glass: rgba(231, 226, 242, 0.75);
}

The existing themes are useful references for the available variables and how different interface elements are styled.

Step 3 — Import your theme

Open:

src/styles/index.css

Add:

css
@import "./themes/lavender.css";

This includes your new stylesheet in the application.

Step 4 — Register your theme

Open:

src/modules/ui/theme.js

Find the THEMES collection and add:

js
"lavender"

This allows SnapDock to recognise your theme when switching between styles.

Step 5 — Add it to the menu

Open:

index.html

Find the existing theme options and add:

html
<button class="theme-option" data-theme="lavender">Lavender</button>

SnapDock already handles theme selection through these buttons, so you don't need to write another event handler.

Step 6 — Test your theme

Rebuild and launch:

bash
node scripts/bundle.js
npm start

Open Tools → Themes and select Lavender.

Check the editor, preview, tabs, menus and syntax highlighting. It's worth trying both full preview and split view.

A theme that looks great in an empty editor can look very different once you fill it with tables, code blocks and headings.

Making your theme the default

If you'd like your theme to be the default for new users, open:

src/modules/ui/theme.js

Find the fallback inside initTheme() and change it to:

js
const saved = localStorage.getItem(THEME_KEY) || "lavender";

You'll also need to change the initial body class in index.html to lavender-theme.

Existing users who have already selected a theme will keep their saved preference.

One limitation: PDF export uses separate styles, so adding an application theme won't automatically change exported PDFs.

Share your theme!

Made something you think others would like?

Send a pull request!

I'm always happy to add more themes to SnapDock. If you've put together a good stylesheet, there's a good chance other people will enjoy using it too.

A theme contribution should include the stylesheet, import, registration and menu entry. Screenshots are also helpful so we can see what it looks like before trying it.

You don't need to change SnapDock's default theme to contribute a new one.

4. Disabling the Updater

If you're making your own version of SnapDock, you might not want it checking the official repository for updates.

That's particularly useful if you've made changes that would be lost by installing an ordinary SnapDock release.

The updater is managed through:

src/modules/updater/index.js

The main process initialises it through setupUpdater().

Replace the updater service

One approach is to replace the updater implementation with a disabled service while keeping the existing IPC responses available.

In src/modules/updater/index.js, replace its implementation with:

js
const { ipcMain } = require("electron");
const { getInstallSource } = require("./detectSource");

module.exports = function setupUpdater() {
  ipcMain.handle("update:source", () => getInstallSource());

  ipcMain.handle("update:pending", () => null);

  ipcMain.handle("update:check", () => ({
    disabled: true,
    updateAvailable: false,
    reason: "custom-build"
  }));

  ipcMain.handle("update:download", () => ({
    error: "Updates disabled in this build."
  }));

  ipcMain.handle("update:install", () => ({
    error: "Updates disabled in this build."
  }));

  return {
    hasPendingUpdate: () => false
  };
};

This keeps the expected updater interface available to the rest of SnapDock without loading the normal update and download implementation.

Remove the update controls

To prevent the renderer from making its normal startup update request, open:

src/modules/ui/dropdownMenus.js

Inside initToolsDropdown(), remove the block that calls:

js
initUpdateButton(updateBtn);

You can also remove the update button and status indicator from index.html if you don't want them appearing in your custom build.

After making these changes, rebuild and test the application.

In particular, check that SnapDock starts normally, closes correctly and no longer contacts the update feed.

This customisation is based on the V3 implementation and should be tested before distributing your modified build.

5. Changing the Application Name

Want to give your copy of SnapDock a different name?

There are two ways to approach this, depending on how much you want to change.

Change the name at the top

If you only want to change the visible name in the application's title bar, open:

index.html

Find:

html
<div id="appTitle" class="app-title">SnapDock</div>

Change the text:

html
<div id="appTitle" class="app-title">My Editor</div>

That's it.

For this HTML-only change, you can restart the source application without rebundling the JavaScript.

This doesn't rename the installed application, executable or installer.

Fully rebrand your build

If you're creating a separate application based on SnapDock, there are several other places to review.

File or location What it controls
index.html Window title, title-bar text and welcome text
package.json Application name, product name, executable name and package identity
src/modules/ui/app.js Footer branding
main.js Some native dialog messages
scripts/inject-metadata.js Generated desktop metadata
snapdock.desktop Linux desktop integration
snapcraft.yaml Snap package identity and desktop integration
assets/ Application icons and other artwork
assets/resources/docs/user_guide.md Bundled help documentation
src/modules/pdf/pdf.js Temporary PDF filename prefix

For an independently distributed application, you should also review the application ID, release destinations and updater configuration.

Changing a visible name is easy. Changing an application's identity across different operating systems requires a little more care.

6. Want to Try SnapDock on macOS?

I've tried to keep SnapDock compatible with macOS where possible, but there's one small problem: I don't have a Mac to test it on.

Some macOS support is already present in the source, including build configuration, window handling and keyboard shortcut support.

However, macOS isn't officially supported, and the existing npm run build:mac command is currently a placeholder.

Try an experimental build

If you have a Mac, you can try building SnapDock using:

bash
node scripts/inject-metadata.js --stage=dev --channel=dev
node scripts/bundle.js
npx electron-builder --mac dmg zip --publish never

You'll need to install the dependencies first using the instructions at the beginning of this guide.

These commands attempt to create DMG and ZIP packages using the existing Electron build configuration.

I haven't been able to verify that these packages build successfully or that the application runs correctly on macOS.

You may also encounter macOS signing or Gatekeeper restrictions with an unsigned development build.

GitHub Actions

Another option is to experiment with a GitHub Actions workflow using a macOS runner.

The project already uses GitHub Actions for Windows and Linux builds, so extending the workflow to attempt macOS packaging is possible.

That could make building easier, although it won't tell us whether the application actually works on a Mac.

Let me know how it goes!

If you manage to build or run SnapDock on macOS, I'd love to hear about it.

Even getting the application to launch would be a useful starting point.

If you can, try opening and saving documents, using the preview, switching themes, exporting PDFs and working with folders.

Please share which Mac and macOS version you tested, what worked and what didn't.

I'd love to formally support macOS, but I need some real testing before I can confidently say it works.

7. Running Tests

SnapDock includes automated checks for parts of the application.

Run the main test suite using:

bash
npm test

For Markdown-specific checks:

bash
npm run md:test

You can also run the editor font tests separately:

bash
node --test src/modules/ui/editorFont.test.mjs

These checks cover selected application logic, but they don't replace testing the actual desktop application.

Some existing tests contain platform-specific assumptions. In particular, the V3 link-navigation tests have known path-assertion failures on Windows.

If you're modifying the application, test the features you've changed directly as well.

For themes, that means checking the actual interface. For filesystem changes, try opening, editing and saving real documents.

8. Contributing to SnapDock

You're welcome to experiment with the source and share improvements.

If you'd like to contribute something back:

  1. Fork the SnapDock repository.
  2. Create a branch for your changes.
  3. Make and test your changes.
  4. Open a pull request explaining what you've changed.

Please read the Contributing Guide for the project's contribution guidelines.

Themes are particularly welcome, including for V3.

For larger feature changes, it's worth opening an issue or discussion first. Some features may be better suited to the next generation of SnapDock rather than adding complexity to V3.

And if you're simply building your own version, that's fine too. SnapDock is MIT licensed, so you're free to modify and redistribute it under the terms of that licence.

9. Where to Go Next

If you're interested in how the application works internally, see Technical Overview.

You can also explore the repository directly:

SnapDock Source Code

Whether you're making a new theme, experimenting with the editor or trying to get SnapDock running on another operating system, have fun with it.

And if you build something useful, feel free to share it!

DocsHub · Capybara

Documentation

SSnapDock@ZFordDev