Skip to content

Commit 4c0c3da

Browse files
committed
theoretically fix #27: call app.dock.hide() on mac
+ restore hidden taskbar icons on plugin cleanup/disable
1 parent b832652 commit 4c0c3da

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

main.js

+15-7
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,16 @@ const onWindowClose = (event) => event.preventDefault(),
100100
window.removeEventListener("beforeunload", onWindowUnload, true);
101101
};
102102

103-
const setHideTaskbarIcon = () => {
104-
getWindows().forEach((win) => {
105-
win.setSkipTaskbar(plugin.settings.hideTaskbarIcon);
106-
});
103+
const hideTaskbarIcons = () => {
104+
getWindows().forEach((win) => win.setSkipTaskbar(true));
105+
if (process.platform === "darwin") app.dock.hide();
107106
},
108-
setLaunchOnStartup = () => {
107+
showTaskbarIcons = () => {
108+
getWindows().forEach((win) => win.setSkipTaskbar(false));
109+
if (process.platform === "darwin") app.dock.show();
110+
};
111+
112+
const setLaunchOnStartup = () => {
109113
const { launchOnStartup, runInBackground, hideOnLaunch } = plugin.settings;
110114
app.setLoginItemSettings({
111115
openAtLogin: launchOnStartup,
@@ -248,7 +252,10 @@ const OPTIONS = [
248252
`,
249253
type: "toggle",
250254
default: false,
251-
onChange: setHideTaskbarIcon,
255+
onChange() {
256+
if (plugin.settings.hideTaskbarIcon) hideTaskbarIcons();
257+
else showTaskbarIcons();
258+
},
252259
},
253260
{
254261
key: "createTrayIcon",
@@ -410,10 +417,10 @@ class TrayPlugin extends obsidian.Plugin {
410417
plugin = this;
411418
createTrayIcon();
412419
registerHotkeys();
413-
setHideTaskbarIcon();
414420
setLaunchOnStartup();
415421
observeWindows();
416422
if (settings.runInBackground) interceptWindowClose();
423+
if (settings.hideTaskbarIcon) hideTaskbarIcons();
417424
if (settings.hideOnLaunch) {
418425
this.registerEvent(this.app.workspace.onLayoutReady(hideWindows));
419426
}
@@ -435,6 +442,7 @@ class TrayPlugin extends obsidian.Plugin {
435442
log(LOG_CLEANUP);
436443
unregisterHotkeys();
437444
allowWindowClose();
445+
showTaskbarIcons();
438446
destroyTray();
439447
}
440448

0 commit comments

Comments
 (0)