From 61206db05aceac08eb6377b2f4f52ec4e93d43f4 Mon Sep 17 00:00:00 2001 From: dragonwocky Date: Sun, 11 Oct 2020 15:28:56 +1100 Subject: [PATCH] bugfixes: match up some styling better, EACCES dest chmodding, csp re-allow fonts --- CHANGELOG.md | 10 +++- README.md | 30 +++++++++-- mods/core/css/theme.css | 101 +++++++++++++++++++++++++++--------- mods/core/css/variables.css | 21 ++++++++ mods/core/render.js | 2 +- mods/core/tray.js | 35 +++++++++---- package.json | 1 + pkg/apply.js | 9 +++- pkg/remove.js | 9 +++- yarn.lock | 5 ++ 10 files changed, 180 insertions(+), 43 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b19209..703bdcd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ a flexibility update. variables can be modified.) - new: in-page columns disabled/wrapped and wider pages when the window is narrower than 600px for improved responsiveness. +- new: relaunch button in tray menu. - improved: a core mod option to make transitions snappy/0s. - improved: menu will now respect integrated titlebar setting. - bugfix: removed messenger emoji set as the provider no longer supports it. @@ -28,8 +29,15 @@ a flexibility update. - bugfix: bypass preview extension works with the back/forward keyboard shortcuts. - bugfix: (maybe) fix csp issues under proxy. - bugfix: remove focus mode footer from neutral theme. +- bugfix: improvements to the colour theming, particularly to make real- and fake-light/dark + modes (as applied by the night shift extension) look consistent. - tweak: sticky table/list rows. -- extension: "material ocean" = an oceanic colour palette. +- theme: "material ocean" = an oceanic colour palette. +- theme: "dracula" = a theme based on the popular dracula color palette + originally by zeno rocha and friends. +- extension: "tabs" = have multiple notion pages open in a single window. + +a fork of notion-deb-builder that does generate an app.asar has been created and is once again supported. ### v0.9.1 (2020-09-26) diff --git a/README.md b/README.md index 080124b..bd7aa25 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,8 @@ for support, join the [discord server](https://discord.gg/sFWPXtA). - the [official windows/mac releases](https://notion.so/desktop). - the arch linux AUR [notion-app](https://aur.archlinux.org/packages/notion-app/) package. - the linux [notion-app](https://github.com/jaredallard/notion-app) installer. +- [@haydn-jones](https://github.com/haydn-jones/)'s fork of the + linux [notion-deb-builder](https://github.com/haydn-jones/notion-deb-builder). (it can also be run from the wsl to apply enhancements to the windows app.) @@ -31,10 +33,22 @@ a chrome extension may be coming soon for web client support. during installation/removal, make sure no notion processes are running! (check your task manager.) -**win10, macOS** +**win10** -1. [install node.js](https://nodejs.org/en/download/) (_a computer restart may be required here._) -2. execute `npm i -g notion-enhancer` in the terminal/command prompt. +[install node.js](https://nodejs.org/en/download/) (_a computer restart may be required here_), +then execute `npm i -g notion-enhancer` in the command prompt. + +**macOS** + +[install node.js](https://nodejs.org/en/download/) (_a computer restart may be required here_), +then execute the following lines in the terminal: + +``` +sudo chmod -R a+wr /usr/local/lib/node_modules +sudo chmod -R a+wr /usr/local/bin +sudo chmod -R a+wr /Applications/Notion/Contents/Resources +npm i -g notion-enhancer +``` **debian/ubuntu, chromeOS, WSL (to modify the win10 app)** @@ -81,6 +95,14 @@ Options: -v, --version : display version number ``` +### faq + +**the themes aren't working?** + +if you pick a dark theme it will only be applied if notion is in dark mode, +and if you pick a light theme it will only work if notion is in light mode. +do `CMD/CTRL+SHIFT+L` to toggle between them. + **is this against notion's terms of service? can i get in trouble for using it?** definitely not! i contacted their support team to check, and the response was awesome: @@ -92,7 +114,7 @@ team to take to heart for future improvements." ## features once applied, modules can be configured via the graphical menu, which is opened from -the tray/menubar icon or with `ALT+E`. +the tray/menubar icon or with `OPTION/ALT+E`. ![](https://user-images.githubusercontent.com/16874139/93692603-954fd980-fb38-11ea-9d52-82ac53449d33.png) diff --git a/mods/core/css/theme.css b/mods/core/css/theme.css index 7778954..735fad2 100644 --- a/mods/core/css/theme.css +++ b/mods/core/css/theme.css @@ -9,20 +9,25 @@ /** app **/ +.notion-body, +.notion-body.dark [style*='background: rgb(47, 52, 55)'], +.notion-body.dark [style*='background-color: rgb(47, 52, 55)'], +.notion-body:not(.dark) + .notion-light-theme + [style*='background: white']:not(.notion-help-button), +.notion-body:not(.dark) + .notion-dark-theme + [style*='background: white']:not(.notion-help-button):not([style*='box-shadow: rgba(15, 15, 15, 0.05) 0px 0px 0px 1px, rgba(15, 15, 15, 0.1) 0px 3px 6px, rgba(15, 15, 15, 0.2) 0px 9px 24px;']), +.notion-body:not(.dark) [style*='background-color: white'] { + background: var(--theme--main) !important; +} +.notion-sidebar > div, .notion-body.dark [style*='background: rgb(55, 60, 63)'], .notion-body.dark [style*='background: rgb(120, 123, 123)'], .notion-body:not(.dark) [style*='background: rgb(247, 246, 243)'], .notion-body:not(.dark) [style*='background: rgb(223, 223, 222)'] { background: var(--theme--sidebar) !important; } -.notion-body, -.notion-body.dark [style*='background: rgb(47, 52, 55)'], -.notion-body.dark [style*='background-color: rgb(47, 52, 55)'], -.notion-body:not(.dark) - [style*='background: white']:not(.notion-help-button):not([style*='box-shadow: rgba(15, 15, 15, 0.05) 0px 0px 0px 1px, rgba(15, 15, 15, 0.1) 0px 3px 6px, rgba(15, 15, 15, 0.2) 0px 9px 24px;']), -.notion-body:not(.dark) [style*='background-color: white'] { - background: var(--theme--main) !important; -} [style*='background: rgba(15, 15, 15, 0.6)'] { background: var(--theme--overlay) !important; } @@ -195,7 +200,8 @@ > a[style*='background: white'], .notion-body:not(.dark) [style*='background: rgb(247, 246, 243)'], .notion-body:not(.dark) - [style*='box-shadow: rgba(15, 15, 15, 0.05) 0px 0px 0px 1px, rgba(15, 15, 15, 0.1) 0px 3px 6px, rgba(15, 15, 15, 0.2) 0px 9px 24px;'] { + .notion-dark-theme + [style*='background: white'][style*='box-shadow: rgba(15, 15, 15, 0.05) 0px 0px 0px 1px, rgba(15, 15, 15, 0.1) 0px 3px 6px, rgba(15, 15, 15, 0.2) 0px 9px 24px;'] { background: var(--theme--card) !important; } .notion-body.dark @@ -206,19 +212,36 @@ [style*='background: rgba(55, 53, 47, 0.024)'] { background: var(--theme--gallery) !important; } +.notion-body.dark .notion-scroller > [style*='rgb(55, 60, 63)'], +.notion-body:not(.dark) [style*='background: rgba(242, 241, 238, 0.6)'] { + background: var(--theme--select_input) !important; +} .notion-body.dark - [style*='box-shadow: rgba(15, 15, 15, 0.2) 0px 0px 0px 1px, rgba(15, 15, 15, 0.2) 0px 2px 4px'], + [style*='box-shadow: rgba(255, 255, 255, 0.14) 0px -1px inset;'], .notion-body:not(.dark) - .notion-dark-theme - [style*='box-shadow: white -3px 0px 0px'] { - box-shadow: rgba(15, 15, 15, 0.1) 0px 0px 0px 1px, - rgba(15, 15, 15, 0.1) 0px 2px 4px !important; + [style*='box-shadow: rgba(55, 53, 47, 0.16) 0px -1px 0px inset'] { + box-shadow: rgba(55, 53, 47, 0.16) 0px -1px inset !important; +} + +.notion-body.dark [style*='box-shadow: rgba(255, 255, 255, 0.07) 0px 1px 0px'], +.notion-body:not(.dark) + [style*='box-shadow: rgba(55, 53, 47, 0.09) 0px 1px 0px'] { + box-shadow: var(--theme--ui-border) 0px 1px 0px !important; +} +.notion-body.dark + [style*='box-shadow: rgba(255, 255, 255, 0.14) 0px 1px 0px inset'], +.notion-body:not(.dark) + [style*='box-shadow: rgba(55, 53, 47, 0.16) 0px 1px 0px inset'] { + box-shadow: var(--theme--table-border) 0px 1px 0px inset !important; } .notion-body.dark [style*='box-shadow: rgb(47, 52, 55) -3px 0px 0px'] { box-shadow: var(--theme--main) -3px 0px 0px !important; } +.notion-body:not(.dark) [style*='box-shadow: white -3px 0px 0px;'] { + box-shadow: none !important; +} .notion-body.dark [style*='box-shadow: rgb(47, 52, 55) -3px 0px 0px, rgba(255, 255, 255, 0.14) 0px 1px 0px'], .notion-body:not(.dark) @@ -226,7 +249,7 @@ .notion-body:not(.dark) [style*='box-shadow: rgba(255, 255, 255, 0.07) 0px -1px 0px'] { box-shadow: var(--theme--main) -3px 0px 0px, - var(--theme--table-border) 0px 1px 0px !important; + var(--theme--ui-border) 0px 1px 0px !important; } .notion-body.dark [style*='border-top: 1px solid rgba(255, 255, 255,'], @@ -254,7 +277,7 @@ .notion-body.dark [style*='box-shadow: rgba(55, 53, 47, 0.09) 0px -1px 0px'], .notion-body:not(.dark) [style*='box-shadow: rgba(55, 53, 47, 0.09) 0px -1px 0px'] { - box-shadow: var(--theme--table-border) 0px -1px 0px !important; + box-shadow: var(--theme--ui-border) 0px -1px 0px !important; } .notion-body.dark [style*='border-left: 1px solid rgba(255, 255, 255,'], .notion-body.dark @@ -263,12 +286,6 @@ .notion-body:not(.dark) [style*='border-left: 1px solid rgba(55, 53, 47,'] { border-left: 1px solid var(--theme--table-border) !important; } -.notion-body.dark - [style*='box-shadow: rgba(255, 255, 255, 0.14) 0px 1px 0px inset'], -.notion-body:not(.dark) - [style*='box-shadow: rgba(55, 53, 47, 0.16) 0px 1px 0px inset'] { - box-shadow: var(--theme--table-border) 0px 1px 0px inset !important; -} .notion-body.dark [style*='box-shadow: rgba(255, 255, 255, 0.14) 1px 0px 0px inset'], .notion-body:not(.dark) @@ -296,6 +313,7 @@ .notion-body.dark [style*='background: rgb(71, 76, 80)'], .notion-body.dark [style*='background: rgb(80, 85, 88)'], .notion-body.dark [style*='background: rgb(98, 102, 104)'], +.notion-body.dark [style*='height: 1px; background: rgba(255, 255, 255, 0.07)'], .notion-body:not(.dark) [style*='background: rgba(55, 53, 47,'], .notion-body:not(.dark) [style*='background: rgb(239, 239, 238)'], .notion-body:not(.dark) [style*='background: rgba(206, 205, 202, 0.5)'] { @@ -395,6 +413,19 @@ background: var(--theme--primary_indicator) !important; } +.notion-body.dark + [style*='box-shadow: rgba(15, 15, 15, 0.1) 0px 0px 0px 1px, rgba(15, 15, 15, 0.2) 0px 3px 6px, rgba(15, 15, 15, 0.4) 0px 9px 24px'], +.notion-body:not(.dark) + [style*='box-shadow: rgba(15, 15, 15, 0.05) 0px 0px 0px 1px, rgba(15, 15, 15, 0.1) 0px 3px 6px, rgba(15, 15, 15, 0.2) 0px 9px 24px'] { + box-shadow: var(--theme--box-shadow_strong) !important; +} +.notion-body.dark + [style*='box-shadow: rgba(15, 15, 15, 0.2) 0px 0px 0px 1px, rgba(15, 15, 15, 0.2) 0px 2px 4px'], +.notion-body:not(.dark) + [style*='box-shadow: rgba(15, 15, 15, 0.1) 0px 0px 0px 1px, rgba(15, 15, 15, 0.1) 0px 2px 4px'] { + box-shadow: var(--theme--box-shadow) !important; +} + .notion-to_do-block > div [role='button']:hover, .notion-to_do-block > div [role='button']:hover .checkboxSquare, .notion-to_do-block > div [role='button']:hover .check { @@ -444,18 +475,38 @@ .notion-body:not(.dark) [style*='color: rgba(25, 23, 17, 0.6)'] { color: var(--theme--text_ui) !important; } +::placeholder { + opacity: 1 !important; +} +::placeholder, +[style*='-webkit-text-fill-color:'], .notion-body.dark [style*='color: rgba(255, 255, 255, 0.4)'], -.notion-body:not(.dark) [style*='color: rgba(55, 53, 47, 0.4)'] { +.notion-body.dark [style*='color: rgba(255, 255, 255, 0.4)']::before, +.notion-body:not(.dark) [style*='color: rgba(55, 53, 47, 0.4)'], +.notion-body:not(.dark) [style*='color: rgba(55, 53, 47, 0.4)']::before { color: var(--theme--text_ui_info) !important; + -webkit-text-fill-color: var(--theme--text_ui_info) !important; } .notion-body.dark [style*='fill: rgb(202, 204, 206)'] { fill: var(--theme--text) !important; } -.notion-body.dark [style*='fill: rgba(202, 204, 206,'], + +.notion-body.dark [style*='fill: rgba(255, 255, 255, 0.6)'], .notion-body:not(.dark) [style*='fill: rgba(55, 53, 47, 0.8)'], -.notion-body:not(.dark) [style*='fill: rgba(55, 53, 47,'] { +.notion-body:not(.dark) [style*='fill: rgba(55, 53, 47, 0.6)'], +.notion-body:not(.dark) [style*='fill: rgba(25, 23, 17, 0.6)'] { fill: var(--theme--text_ui) !important; } +.notion-body.dark [style*='fill: rgba(202, 204, 206, 0.6)'], +.notion-body.dark [style*='fill: rgba(202, 204, 206, 0.4)'], +.notion-body:not(.dark) [style*='fill: rgba(55, 53, 47, 0.4)'], +.notion-body:not(.dark) [style*='fill: rgba(55, 53, 47, 0.3)'] { + fill: var(--theme--text_ui_info) !important; +} +.notion-body.dark [style*='border-color:rgba(255,255,255,0.4);opacity:0.7'], +.notion-body:not(.dark) [style*='border-color:rgba(55,53,47,0.4);opacity:0.7'] { + border-color: var(--theme--text_ui_info) !important; +} .notion-body.dark [style*='caret-color: rgba(255, 255, 255, 0.9)'], .notion-body:not(.dark) [style*='caret-color: rgb(55, 53, 47)'] { caret-color: var(--theme--text) !important; diff --git a/mods/core/css/variables.css b/mods/core/css/variables.css index 76e4bbd..d394665 100644 --- a/mods/core/css/variables.css +++ b/mods/core/css/variables.css @@ -14,6 +14,10 @@ --theme_dark--sidebar: rgb(55, 60, 63); --theme_dark--overlay: rgba(15, 15, 15, 0.6); --theme_dark--dragarea: #272d2f; + --theme_dark--box-shadow: rgba(15, 15, 15, 0.2) 0px 0px 0px 1px, + rgba(15, 15, 15, 0.2) 0px 2px 4px; + --theme_dark--box-shadow_strong: rgba(15, 15, 15, 0.1) 0px 0px 0px 1px, + rgba(15, 15, 15, 0.2) 0px 3px 6px, rgba(15, 15, 15, 0.4) 0px 9px 24px; --theme_dark--page_normal-width: 900px; --theme_dark--page_full-width: 100%; --theme_dark--page-padding: calc(96px + env(safe-area-inset-left)); @@ -48,7 +52,9 @@ --theme_dark--card: rgb(63, 68, 71); --theme_dark--gallery: rgba(255, 255, 255, 0.05); + --theme_dark--select_input: rgb(55, 60, 63); --theme_dark--table-border: rgba(255, 255, 255, 0.1); + --theme_dark--ui-border: rgba(255, 255, 255, 0.07); --theme_dark--interactive_hover: rgb(71, 76, 80); --theme_dark--interactive_hover-border: transparent; --theme_dark--button_close: #e81123; @@ -189,6 +195,10 @@ --theme_light--sidebar: rgb(247, 246, 243); --theme_light--overlay: rgba(15, 15, 15, 0.6); --theme_light--dragarea: rgba(55, 53, 47, 0.04); + --theme_light--box-shadow: rgba(15, 15, 15, 0.1) 0px 0px 0px 1px, + rgba(15, 15, 15, 0.1) 0px 2px 4px; + --theme_light--box-shadow_strong: rgba(15, 15, 15, 0.05) 0px 0px 0px 1px, + rgba(15, 15, 15, 0.1) 0px 3px 6px, rgba(15, 15, 15, 0.2) 0px 9px 24px; --theme_light--page_normal-width: 900px; --theme_light--page_full-width: 100%; --theme_light--page-padding: calc(96px + env(safe-area-inset-left)); @@ -223,7 +233,9 @@ --theme_light--card: rgb(247, 247, 247); --theme_light--gallery: rgba(55, 53, 47, 0.024); + --theme_light--select_input: rgba(242, 241, 238, 0.6); --theme_light--table-border: rgba(55, 53, 47, 0.16); + --theme_light--ui-border: rgba(55, 53, 47, 0.09); --theme_light--interactive_hover: rgb(239, 239, 239); --theme_light--interactive_hover-border: transparent; --theme_light--button_close: #e81123; @@ -247,6 +259,7 @@ --theme_light--text: rgb(55, 53, 47); --theme_light--text_ui: rgba(55, 53, 47, 0.6); + --theme_light--text_ui: rgba(55, 53, 47, 0.6); --theme_light--text_ui_info: rgba(55, 53, 47, 0.4); --theme_light--text_gray: rgb(155, 154, 151); @@ -364,6 +377,8 @@ --theme--sidebar: var(--theme_dark--sidebar); --theme--overlay: var(--theme_dark--overlay); --theme--dragarea: var(--theme_dark--dragarea); + --theme--box-shadow: var(--theme_dark--box-shadow); + --theme--box-shadow_strong: var(--theme_dark--box-shadow_strong); --theme--page_normal-width: var(--theme_dark--page_normal-width); --theme--page_full-width: var(--theme_dark--page_full-width); --theme--page-padding: var(--theme_dark--page-padding); @@ -389,7 +404,9 @@ --theme--scrollbar_hover: var(--theme_dark--scrollbar_hover); --theme--card: var(--theme_dark--card); --theme--gallery: var(--theme_dark--gallery); + --theme--select_input: var(--theme_dark--select_input); --theme--table-border: var(--theme_dark--table-border); + --theme--ui-border: var(--theme_dark--ui-border); --theme--interactive_hover: var(--theme_dark--interactive_hover); --theme--interactive_hover-border: var( --theme_dark--interactive_hover-border @@ -524,6 +541,8 @@ --theme--sidebar: var(--theme_light--sidebar); --theme--overlay: var(--theme_light--overlay); --theme--dragarea: var(--theme_light--dragarea); + --theme--box-shadow: var(--theme_light--box-shadow); + --theme--box-shadow_strong: var(--theme_light--box-shadow_strong); --theme--page_normal-width: var(--theme_light--page_normal-width); --theme--page_full-width: var(--theme_light--page_full-width); --theme--page-padding: var(--theme_light--page-padding); @@ -549,7 +568,9 @@ --theme--scrollbar_hover: var(--theme_light--scrollbar_hover); --theme--card: var(--theme_light--card); --theme--gallery: var(--theme_light--gallery); + --theme--select_input: var(--theme_light--select_input); --theme--table-border: var(--theme_light--table-border); + --theme--ui-border: var(--theme_light--ui-border); --theme--interactive_hover: var(--theme_light--interactive_hover); --theme--interactive_hover-border: var( --theme_light--interactive_hover-border diff --git a/mods/core/render.js b/mods/core/render.js index 619c91f..0ac5969 100644 --- a/mods/core/render.js +++ b/mods/core/render.js @@ -23,7 +23,7 @@ const url = require('url'), const insertCSP = ` const csp = document.createElement('meta'); csp.httpEquiv = 'Content-Security-Policy'; - csp.content = "script-src 'self' 'unsafe-inline' 'unsafe-eval' enhancement: https://gist.github.com https://apis.google.com https://api.amplitude.com https://widget.intercom.io https://js.intercomcdn.com https://logs-01.loggly.com https://cdn.segment.com https://analytics.pgncs.notion.so https://checkout.stripe.com https://embed.typeform.com https://admin.typeform.com https://platform.twitter.com https://cdn.syndication.twimg.com; connect-src 'self' https://msgstore.www.notion.so wss://msgstore.www.notion.so https://notion-emojis.s3-us-west-2.amazonaws.com https://s3-us-west-2.amazonaws.com https://s3.us-west-2.amazonaws.com https://notion-production-snapshots-2.s3.us-west-2.amazonaws.com https: http: https://api.amplitude.com https://api.embed.ly https://js.intercomcdn.com https://api-iam.intercom.io wss://nexus-websocket-a.intercom.io https://logs-01.loggly.com https://api.segment.io https://api.pgncs.notion.so https://checkout.stripe.com https://cdn.contentful.com https://preview.contentful.com https://images.ctfassets.net https://api.unsplash.com https://boards-api.greenhouse.io; font-src 'self' data: https://cdnjs.cloudflare.com https://js.intercomcdn.com; img-src 'self' data: blob: https: https://platform.twitter.com https://syndication.twitter.com https://pbs.twimg.com https://ton.twimg.com; style-src 'self' 'unsafe-inline' enhancement: https://cdnjs.cloudflare.com https://github.githubassets.com https://platform.twitter.com https://ton.twimg.com; frame-src https: http:; media-src https: http:"; + csp.content = "script-src 'self' 'unsafe-inline' 'unsafe-eval' enhancement: https://gist.github.com https://apis.google.com https://api.amplitude.com https://widget.intercom.io https://js.intercomcdn.com https://logs-01.loggly.com https://cdn.segment.com https://analytics.pgncs.notion.so https://checkout.stripe.com https://embed.typeform.com https://admin.typeform.com https://platform.twitter.com https://cdn.syndication.twimg.com; connect-src 'self' https://msgstore.www.notion.so wss://msgstore.www.notion.so https://notion-emojis.s3-us-west-2.amazonaws.com https://s3-us-west-2.amazonaws.com https://s3.us-west-2.amazonaws.com https://notion-production-snapshots-2.s3.us-west-2.amazonaws.com https: http: https://api.amplitude.com https://api.embed.ly https://js.intercomcdn.com https://api-iam.intercom.io wss://nexus-websocket-a.intercom.io https://logs-01.loggly.com https://api.segment.io https://api.pgncs.notion.so https://checkout.stripe.com https://cdn.contentful.com https://preview.contentful.com https://images.ctfassets.net https://api.unsplash.com https://boards-api.greenhouse.io; font-src 'self' data: enhancement: https: http:; img-src 'self' data: blob: https: https://platform.twitter.com https://syndication.twitter.com https://pbs.twimg.com https://ton.twimg.com; style-src 'self' 'unsafe-inline' enhancement: https: http:; frame-src https: http:; media-src https: http:"; document.head.appendChild(csp); `; diff --git a/mods/core/tray.js b/mods/core/tray.js index 25be7e9..2b50971 100644 --- a/mods/core/tray.js +++ b/mods/core/tray.js @@ -17,6 +17,8 @@ module.exports = (store, __exports) => { helpers = require('../../pkg/helpers.js'); electron.app.on('ready', () => { + // tray + tray = new electron.Tray( is_win ? path.resolve(`${__dirname}/icons/windows.ico`) @@ -28,6 +30,8 @@ module.exports = (store, __exports) => { }) ); + // menu + electron.ipcMain.on('enhancer:set-menu-theme', (event, arg) => { if (!enhancer_menu) return; enhancer_menu.webContents.send('enhancer:set-menu-theme', arg); @@ -111,6 +115,19 @@ module.exports = (store, __exports) => { }); } + electron.globalShortcut.register(store().menu_toggle, () => { + if ( + electron.BrowserWindow.getAllWindows() + .filter((win) => win.getTitle() !== 'notion-enhancer menu') + .some((win) => win.isFocused()) + ) { + openExtensionMenu(); + } else if (enhancer_menu && enhancer_menu.isFocused()) + enhancer_menu.close(); + }); + + // tray + const contextMenu = electron.Menu.buildFromTemplate([ { type: 'normal', @@ -185,6 +202,13 @@ module.exports = (store, __exports) => { { type: 'separator', }, + { + label: 'Relaunch', + click: () => { + electron.app.relaunch(); + electron.app.quit(); + }, + }, { label: 'Quit', role: 'quit', @@ -193,16 +217,7 @@ module.exports = (store, __exports) => { tray.setContextMenu(contextMenu); tray.setToolTip('Notion'); - electron.globalShortcut.register(store().menu_toggle, () => { - if ( - electron.BrowserWindow.getAllWindows() - .filter((win) => win.getTitle() !== 'notion-enhancer menu') - .some((win) => win.isFocused()) - ) { - openExtensionMenu(); - } else if (enhancer_menu && enhancer_menu.isFocused()) - enhancer_menu.close(); - }); + // hotkey function showWindows() { const windows = electron.BrowserWindow.getAllWindows(); diff --git a/package.json b/package.json index aaa8e97..a71d9c9 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ "asar": "^3.0.3", "cac": "^6.5.12", "fs-extra": "^9.0.1", + "keyboardevent-from-electron-accelerator": "^2.0.0", "readdir-enhanced": "^6.0.3" } } diff --git a/pkg/apply.js b/pkg/apply.js index 168193a..586cb7a 100644 --- a/pkg/apply.js +++ b/pkg/apply.js @@ -120,7 +120,14 @@ module.exports = async function ({ overwrite_version, friendly_errors } = {}) { : `try running "sudo chmod a+wr -R ${err.path.replace( 'Notion.app', 'Notion' - )}"` + )}" ${ + err.dest + ? `and "sudo chmod a+wr -R ${err.dest.replace( + 'Notion.app', + 'Notion' + )}"` + : '' + }` }` ); } else if (['EIO', 'EBUSY'].includes(err.code) && friendly_errors) { diff --git a/pkg/remove.js b/pkg/remove.js index a9c3696..cb25f73 100644 --- a/pkg/remove.js +++ b/pkg/remove.js @@ -122,7 +122,14 @@ module.exports = async function ({ : `try running "sudo chmod a+wr -R ${err.path.replace( 'Notion.app', 'Notion' - )}"` + )}" ${ + err.dest + ? `and "sudo chmod a+wr -R ${err.dest.replace( + 'Notion.app', + 'Notion' + )}"` + : '' + }` }` ); } else if (['EIO', 'EBUSY'].includes(err.code) && friendly_errors) { diff --git a/yarn.lock b/yarn.lock index 42d4db4..0b9ca31 100644 --- a/yarn.lock +++ b/yarn.lock @@ -143,6 +143,11 @@ jsonfile@^6.0.1: optionalDependencies: graceful-fs "^4.1.6" +keyboardevent-from-electron-accelerator@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/keyboardevent-from-electron-accelerator/-/keyboardevent-from-electron-accelerator-2.0.0.tgz#ace21b1aa4e47148815d160057f9edb66567c50c" + integrity sha512-iQcmNA0M4ETMNi0kG/q0h/43wZk7rMeKYrXP7sqKIJbHkTU8Koowgzv+ieR/vWJbOwxx5nDC3UnudZ0aLSu4VA== + minimatch@^3.0.4: version "3.0.4" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"