diff --git a/main.js b/main.js
index 26dc2cc..67e78cd 100644
--- a/main.js
+++ b/main.js
@@ -122,7 +122,9 @@ const addQuickNote = (plugin) => {
},
createTrayIcon = (plugin) => {
log(LOG_TRAY_ICON);
- const obsidianIcon = nativeImage.createFromDataURL(OBSIDIAN_BASE64_ICON),
+ const obsidianIcon = nativeImage.createFromDataURL(
+ plugin.settings.trayIconImage ?? OBSIDIAN_BASE64_ICON
+ ),
contextMenu = Menu.buildFromTemplate([
{
type: "normal",
@@ -236,6 +238,16 @@ const OPTIONS = [
type: "toggle",
default: true,
},
+ {
+ key: "trayIconImage",
+ desc: `
+ Set the image used by the tray/menubar icon. Recommended size: 16x16
+
Preview:
+
${REQUIRES_RESTART}
+ `,
+ type: "image",
+ default: OBSIDIAN_BASE64_ICON,
+ },
{
key: "toggleWindowFocusHotkey",
desc: ACCELERATOR_FORMAT,
@@ -311,6 +323,27 @@ class SettingsTab extends obsidian.PluginSettingTab {
.setValue(this.plugin.settings[opt.key] ?? opt.default)
.onChange(onChange);
});
+ } else if (opt.type === "image") {
+ const previewImg = setting.descEl.querySelector("img[data-preview");
+ if (previewImg) {
+ const src = this.plugin.settings[opt.key] ?? opt.default;
+ previewImg.src = src;
+ }
+ const fileUpload = setting.descEl.createEl("input");
+ fileUpload.style.visibility = "hidden";
+ fileUpload.type = "file";
+ fileUpload.onchange = (event) => {
+ const file = event.target.files[0],
+ reader = new FileReader();
+ reader.onloadend = () => {
+ onChange(reader.result);
+ if (previewImg) previewImg.src = reader.result;
+ };
+ reader.readAsDataURL(file);
+ };
+ setting.addButton((button) => {
+ button.setIcon("image").onClick(() => fileUpload.click());
+ });
} else if (opt.type === "moment") {
setting.addMomentFormat((moment) => {
const previewEl = setting.descEl.querySelector("[data-preview]");