Close obsidian window with cmd w on mac. Leave app running for faster launch

I was about to make the same feature request. Lacking this just feels like a UX bug.

1 Like

I came here to make this same request. Pressing Cmd+W should close panes, until there are no panes, at which point it should close the window.

Particularly with Sync being a thing, there are good reasons to leave the app running with the windows closed, and I’d just as soon be able to do that without using a mouse. Thanks!

2 Likes

Is anyone able to close an Obsidian window without touching mouse on Mac?

Example:
I have 2 Obsidian windows open. I can toggle between them using cmd - ~. However, I cannot close one window without having to CLICK the red x button using mouse/trackpad. i.e. I cannot do a simple cmd - w. cmd - w only closes tabs… This is a real bottleneck for my productivity, I’m wondering how everyone else is dealing with this problem. Is there a hack?

This seems like an Electron app issue. Could the devs take a look at this @Licat :

It would be awesome if you could add a Command - W option in the Menu to close the window. Or, to be independent from the current Command - W which closes tabs, could use Command + Shift - W instead?

3 Likes

You can almost get the intended behaviour by using ⌘-H (Hide) instead of ⌘-W (Close) when you’re looking at the “No file is open” screen. But it’s a bit of a nuisance to remember to use that shortcut for just this single app, so i agree that it would be nice if Obsidian would act the same as other macOS apps. E.g. Franz is also an Electron app and there ⌘-W works as expected.

+1 on closing the window w/ cmd+w.

cmd+Q is too permanent - takes time for the restart etc (mentioned above).
I personally don’t use cmd+h because of the worry that it might hoard memory (?)

PS. Not entirely sure why browsers are (nearly) all caught up with the confirmation-to-quit thingy (double pressing cmd+q). Sure, mistakes/accidents can happen, but that’s what the re-open all page/tab function is for, I think. :confused:

Now that you mention it, I realized that Visual Studio Code works as expected as well.

I don’t think there’s any difference between ⌘-W and ⌘-H memory wise. In both cases the app is still running but not showing any windows. To make sure the app is not consuming any memory you need to fully quit it.

Activity Monitor shows Obsidian takes (about) 80–100MB with no windows, and each window spawns a new “Obsidian (Renderer)” instance, itself about 80MB. ⌘-H doesn’t affect this (the window is hidden) but the red cross does (the window is closed, and takes a moment to re-open). A working ⌘-(shift-)W key would definitely help there.

In terms of this suggestion, however, I’m more bothered by how unwieldy it is to manage having multiple vaults open. There’s not even an option in the menu bar to close a window, so a sysprefs shortcut can’t even help. It kinda hampers the native-app experience when this basic hotkey is nowhere to be found :confused:

1 Like

There is a menu item under the File menu that closes the window.
If you use a macro or automation tool on your mac you can create a neat work around. For example I use Keyboard Maestro, and when I now press cmd W it will hit that menu item. You can do the same from the keyboard settings in your mac.
Just make sure you update the hotkey inside obsidian for closing a pane to something like cmd shift W

1 Like

+1

On Mac the obsidian behavior for cmd+w feels broken. Every other application I can think of behaves exactly like that: cmd+w closes the window, if there is nothing sensible to close inside the window

2 Likes

Throwing another voice of support on here for this - this is a big part of how I manage tabs and windows in all other applications and it would be really nice for it to work with Obsidian

@dabai @evanjohnson @yunruse It’s completely possible to map “Close Window” to a hotkey in MacOS, Cmd-W included. This is true of any menu command in any app in MacOS. Instructions are here:

screenshot.2022-08-08T041741Z

This command will close the window of a single vault, and not close the entire app.

1 Like

BetterTouchTool can also do this. The problem with mapping Cmd + W to closing the window is that you lose the functionality of being able to close individual tabs.

1 Like

Use case or problem

  1. Press Ctrl/Cmd + W when only one tab is open
  2. Notice it goes to a completely useless “I’m a window with no tabs open” mode
  3. This is not the correct behaviour for any Mac app.

Proposed solution

The correct behaviour for any Mac app is for the window itself to close (without the app quitting). It should essentially do what the “Close window” menu option or clicking the red “close” button does: closes the window, but brings it back up again (with the same tab open) if bring up Obsidian.

2 Likes

Relevant discussion for a workaround: Command + W shortcut - #7 by John039481957

By default, Cmd-W is mapped to “Close current tab”. You can remap this yourself. And the reason (I assume) it doesn’t act in a typical Mac way is because it is a cross-platform app, and needs to be consistent across all the operating systems. (I’m not trying to discourage your feature request. But that’s why I bet it isn’t going to happen.)

In the meantime, as a workaround, if you want to close the vault window, you can map Cmd-W (or anything you like) to “Close Window” in app specific keyboard shortcuts.

This may be how you work. I have all sorts of useful side panes still open and ready to keep working.

I like it this way. Personally, I never want my vault closed just because I closed a tab. When I’ve closed all the notes I’m working on, I open a new one and keep writing. If the app is open, I want my vault open. But if I need it closed for some reason, the menu command (or the red X) is there. Or I just quit the app.

Looking at other Electron apps with tabs, the window is closeable with Cmd+w. I think the way VS Code does it is pretty nice. On closing the final tab it goes back to a general state of a window with no tabs open. Doing Cmd+w again closes the window.

I think the current way is very much an anti-pattern and this should be implemented for improved accessibility.

Please please implement this. I now have to rethink how I manage windows because of this.

3 Likes

Hey folks, I arrived at this for much the same reason other people have. We’re used to OSX applications conventions where an application closes it’s window on CMD+W when it’s got nothing displaying. This is not the same as CMD+Q, its a cheap CMD+H.

As noted by other people in this thread, other Electron apps like VSCode follow this idiom too.

I’m happy to workaround this myself using some automation as well - is there an API I can use to introspect current state in Obsidian? E.g. JSX/AppleScript/whatever? I’d like to query the app to know how many tabs/which tabs it has open

2 Likes

As mentionned by others, the missing/desired feature would be to simultaneously be able :

  • to close Obsidian window (especially when pressing ⌘+W as there is no open tab)
  • not to close Vault (for faster re-launch)

Current behaviour

  • Press ⌘+W mutiple times to close all tabs.
    Problem: Obsidian window stays open with an empty tab (as opposed to all macOS apps)

  • Press ⌘+⇧+W or click on the red “traffic light” button to close the window.
    Problem: Obsidian closes the vault, and reopening it takes (annoyingly long) loading time.

Desired behaviour

  • When no tabs are open, close window when pressing ⌘+W.
    (i.e. close window when pressing ⌘+W multiple times)

  • Do not close Vault when closing window, or add an option in settings not to close Vault.
    (i.e. close window but keep Vault open in the background to avoid loading it every time).

Current workaround

  • Press ⌘+H to hide the window (unsatisfactory)
1 Like

I ran into the same problem. Posted a fix in another topic: Obsidian Should Close the Window When The Last Tab is Closed - #10 by joriswvanrijn