Skip to content

Instantly share code, notes, and snippets.

@execjosh
Last active January 12, 2016 23:33
Show Gist options
  • Save execjosh/9682490 to your computer and use it in GitHub Desktop.
Save execjosh/9682490 to your computer and use it in GitHub Desktop.
Confirm Quit for Atom v0.75.0
--- a/Atom.app/Contents/Resources/app/src/workspace-view.js
+++ b/Atom.app/Contents/Resources/app/src/workspace-view.js
@@ -153,7 +153,37 @@
this.command('application:show-settings', function() {
return ipc.sendChannel('command', 'application:show-settings');
});
+ var quitDoubleTapTimeout = null
+ function showConfirmQuitMsg() {
+ $('<div>')
+ .attr({
+ 'class': 'overlay from-top'
+ , id: 'confirm-quit-msg'
+ })
+ .html('<h1>Press &#8984; again to Quit</h1>')
+ .appendTo('body')
+ }
+ function hideConfirmQuitMsg() {
+ $('#confirm-quit-msg').fadeOut(function() {
+ $(this).remove()
+ })
+ }
this.command('application:quit', function() {
+ if (atom.config.get('core.hacks.confirm-quit')) {
+ if (null == quitDoubleTapTimeout) {
+ showConfirmQuitMsg()
+ console.debug('waiting for second quit request...')
+ quitDoubleTapTimeout = setTimeout(function() {
+ console.debug('no second quit request!')
+ quitDoubleTapTimeout = null
+ hideConfirmQuitMsg()
+ }, 1000)
+ return
+ }
+ clearTimeout(quitDoubleTapTimeout)
+ quitDoubleTapTimeout = null
+ hideConfirmQuitMsg()
+ }
return ipc.sendChannel('command', 'application:quit');
});
this.command('application:hide', function() {
@chrishough
Copy link

Has this been deployed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment