Confirm to Quit - Similar to Chrome

Use case or problem

I find myself hitting Cmd + Q often instead of other shortcuts. This immediately closed the Obsidian app on the mac. This completely throws you off.

Proposed solution

It would be great if we could do what google chrome does and confirm before actually quitting the app.

Current workaround (optional)

The only solution that i can find would be to remap the Cmd+Q shortcut to something else so it doesnt work but then you need to start using the mouse in other cases where i use the shortcut.

3 Likes

+1 to this.

Why would you want to close Obsidian at all?

Just forget the quit command completely and press instead minimize cmd+m to clean up your screen.
By the way, Mac has a feature called app nap this reduces application resources if apps are not visible on screen and running idle.

Basically mac covers you needs in this case, users often just don’t know all features of their systems and software and look for capricious, individual solutions and plugins when there isn’t any need for it.

We DON’T want to quit the app. But sometimes we press cmd+Q ACCIDENTALLY, for example, when trying to press cmd+W to close the current tab. The purpose of feature request is to avoid this kind of accident.

1 Like

Whoops, yes true. This may happen sometimes.

My habit is to close windows individually clicking the x button - in Obsidian and other apps too. So i didn’t notice this issue anymore.

I noticed usually browser apps come with a double quit dialog

1 Like

+1 for this

I just accidentally closed obsidian by clicking ‘x’ button while moving my mouse to another monitor :smiling_face_with_tear:

Please add this feature :pray:

@ush could you simply map Cmd+Q to be minimize? Then you’ll never quit by accident.

When you want to manually quit, you can use the “Close window” command from the command palette.

That’s what I’ve done at my end. I also remove the close button via CSS so that i can’t accidentally close by clicking it. @afterobs FYI you can remove that X close button.

(If you wanted to get really advanced, you could make a Quick Actions script to add the “Do you really want to quit?” prompt, and then assign that to Cmd+Q.)

1 Like

Oh I never knew these 3 buttons could be hidden with CSS, thank you for telling me, it’s a good workaround!

Currently I use the following CSS, it works fine:

(source: Any way to remove the minimize, maximize and close buttons? : ObsidianMD (reddit.com))

div[aria-label="Close window"]{
    display: none !important;
}

div[aria-label="Minimize"]{
    display: none !important;
}

div[aria-label="Restore down"]{
    display: none !important;
}

.is-hidden-frameless:not(.is-fullscreen) .workspace-tabs.mod-top-right-space .workspace-tab-header-container{
    padding-right: 0px;
}

.is-hidden-frameless:not(.is-fullscreen) .workspace-tabs.mod-top-right-space .workspace-tab-header-container:after{
    display: none;
}

Ok i finally found a solution to do this using Hammersppon. You have to install hammerspoon and use the following config and it works like a charm! This also works across the mac so that is a great solution too!

-- Variables to keep track of the quit timer and the application
local quitTimer = nil
local quitApp = nil

-- Bind the Command+Q hotkey
hs.hotkey.bind({"cmd"}, "q", function()
  -- Get the currently active application
  local currentApp = hs.application.frontmostApplication()
  
  -- Check if there's an existing timer and if it's for the same app
  if quitTimer and quitApp == currentApp then
    -- If it's the second press within the time window, quit the app
    currentApp:kill()
    -- Stop and clear the timer
    quitTimer:stop()
    quitTimer = nil
    quitApp = nil
    
    -- Show an alert that the app has been quit
   -- hs.alert.show(currentApp:name() .. " has been closed.", 1)
  else
    -- If there's an existing timer for a different app, stop it
    if quitTimer then
      quitTimer:stop()
    end
    
    -- Store the current app and start a new timer
    quitApp = currentApp
    quitTimer = hs.timer.doAfter(0.5, function()
      -- This function runs if the timer expires (0.5 seconds pass)
      -- Reset the timer and app variables
      quitTimer = nil
      quitApp = nil
    end)
    
    -- Show an alert to press again to quit
    hs.alert.show("Press Command+Q again to quit " .. currentApp:name(), 0.5)
  end
end)

1 Like