mirror of
https://github.com/notion-enhancer/notion-enhancer.git
synced 2025-04-05 05:09:03 +00:00
bugfix hotkey, version checker
This commit is contained in:
parent
4a01fe9761
commit
0f066316cc
@ -19,7 +19,7 @@ or a built-in feature like [userChrome.css](https://www.userchrome.org/).)
|
||||
5. [download this enhancer](https://github.com/dragonwocky/notion-enhancer/archive/master.zip) & extract to a location it can safely remain (this must be in the windows filesystem,
|
||||
even if you are running the script from the wsl).
|
||||
6. ensure notion is closed.
|
||||
7. optional: to remove previous versions of notion enhancer, run `cleaner.py`
|
||||
7. optional: to remove previous applications of the notion enhancer, run `cleaner.py`
|
||||
8. optional: modify the `resources/user.css` file to your liking (see [styling](#styling)).
|
||||
9. run `customiser.py` to build changes.
|
||||
|
||||
@ -32,10 +32,6 @@ done: run notion and enjoy.
|
||||
3. reboot.
|
||||
4. follow instructions above (ensuring notion _isn't_ running! again, check task manager).
|
||||
|
||||
**i'm updating from an old version of the enhancer?**
|
||||
|
||||
you must first run `cleaner.py` before running `customiser.py`.
|
||||
|
||||
**i tried opening the python file but it just closed instantly and nothing happened?**
|
||||
|
||||
python scripts must be run from the wsl terminal or windows command prompt via e.g. `python customiser.py`.
|
||||
@ -80,7 +76,7 @@ _image: after default enhancement_
|
||||
you can now reload a window with `F5`.
|
||||
- **toggle all notion windows to/from the tray**: `CmdOrCtrl+Shift+A` by default.
|
||||
|
||||
to set your own toggle hotkey, open `customiser.py` and change line 16 (`hotkey = 'CmdOrCtrl+Shift+A'`)
|
||||
to set your own toggle hotkey, open `customiser.py` and change line 19 (`hotkey = 'CmdOrCtrl+Shift+A'`)
|
||||
to your preference. you will need to run or re-run `customiser.py` afterwards.
|
||||
|
||||
### tray
|
||||
|
@ -9,22 +9,22 @@ import os
|
||||
import sys
|
||||
import platform
|
||||
import subprocess
|
||||
from shutil import copyfile
|
||||
from shutil import copyfile, rmtree
|
||||
from time import sleep
|
||||
|
||||
# to smooth the update process
|
||||
enhancer_version = '0.6.0~beta2'
|
||||
|
||||
# for toggling notion visibility
|
||||
hotkey = 'CmdOrCtrl+Shift+A'
|
||||
|
||||
# f'{bold}=== title ==={normal}' = headers
|
||||
# '=== title ===' = headers
|
||||
# '*' = information
|
||||
# '...' = actions
|
||||
# '##' = warnings
|
||||
# '>' = exit
|
||||
|
||||
bold = '\033[1m'
|
||||
normal = '\033[0m'
|
||||
|
||||
print(f'{bold}=== NOTION ENHANCER CUSTOMISATION LOG ==={normal}\n')
|
||||
print('=== NOTION ENHANCER CUSTOMISATION LOG ===\n')
|
||||
|
||||
try:
|
||||
filepath = ''
|
||||
@ -44,20 +44,50 @@ try:
|
||||
print(' > script not compatible with your os!\n (report this to dragonwocky#8449 on discord)')
|
||||
exit()
|
||||
|
||||
if os.path.isfile(filepath + '/app.asar'):
|
||||
unpacking_asar = True
|
||||
if not os.path.isfile(filepath + '/app.asar'):
|
||||
print(f' ## file {filepath}/app.asar not found!')
|
||||
print(' * attempting to locate')
|
||||
if os.path.exists(filepath + '/app'):
|
||||
unpacking_asar = False
|
||||
print(' * app.asar was already unpacked: checking version.')
|
||||
cleaning_asar = True
|
||||
if os.path.isfile(filepath + '/ENHANCER_VERSION.txt'):
|
||||
with open(filepath + '/ENHANCER_VERSION.txt', 'r', encoding='UTF-8') as content:
|
||||
if content.read() == enhancer_version:
|
||||
cleaning_asar = False
|
||||
if cleaning_asar:
|
||||
unpacking_asar = True
|
||||
print(' * version does not match: cleaning.')
|
||||
if os.path.exists(filepath + '/app'):
|
||||
print(
|
||||
f' ...removing folder {filepath}/app/')
|
||||
rmtree(filepath + '/app')
|
||||
else:
|
||||
print(
|
||||
f' * {filepath}/app/ was not found: step skipped.')
|
||||
if os.path.isfile(filepath + '/app.asar.bak'):
|
||||
print(' ...renaming asar.app.bak to asar.app')
|
||||
os.rename(filepath + '/app.asar.bak',
|
||||
filepath + '/app.asar')
|
||||
else:
|
||||
print(
|
||||
f' * {filepath}/app.asar.bak was not found: exiting. notion install is corrupted.')
|
||||
exit()
|
||||
else:
|
||||
print(' * version matches: continuing.')
|
||||
else:
|
||||
print(
|
||||
' > nothing found: exiting. notion install is either corrupted or non-existent.')
|
||||
exit()
|
||||
if unpacking_asar:
|
||||
print(' ...unpacking app.asar')
|
||||
subprocess.run(['asar', 'extract', filepath +
|
||||
'/app.asar', filepath + '/app'], shell=(True if sys.platform == 'win32' else False))
|
||||
print(' ...renaming asar.app to asar.app.bak')
|
||||
os.rename(filepath + '/app.asar', filepath + '/app.asar.bak')
|
||||
else:
|
||||
print(f' ## file {filepath}/app.asar not found!')
|
||||
print(' * attempting to locate')
|
||||
if os.path.exists(filepath + '/app'):
|
||||
print(' * app.asar was already unpacked: step skipped.')
|
||||
else:
|
||||
print(' > nothing found: exiting.')
|
||||
exit()
|
||||
with open(filepath + '/ENHANCER_VERSION.txt', 'w', encoding='UTF-8') as write:
|
||||
write.write(enhancer_version)
|
||||
|
||||
if os.path.isfile(filepath + '/app/renderer/preload.js'):
|
||||
print(f' ...adding preload.js to {filepath}/app/renderer/preload.js')
|
||||
@ -167,9 +197,9 @@ try:
|
||||
print(
|
||||
f' * {filepath}/app/main/main.js was not found: step skipped.')
|
||||
|
||||
print(f'\n{bold}>>> SUCCESSFULLY CUSTOMISED <<<{normal}')
|
||||
print('\n>>> SUCCESSFULLY CUSTOMISED <<<')
|
||||
|
||||
except Exception as e:
|
||||
print(f'\n{bold}### ERROR ###{normal}\n{str(e)}')
|
||||
print(f'\n### ERROR ###\n{str(e)}')
|
||||
|
||||
print(f'\n{bold}=== END OF LOG ==={normal}')
|
||||
print('\n=== END OF LOG ===')
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
// adds: custom styles, nicer window control buttons
|
||||
|
||||
// DO NOT REMOVE THE INJECTION MARKER ABOVE
|
||||
// DO NOT REMOVE THE MARKERS ABOVE.
|
||||
|
||||
require('electron').remote.getGlobal('setTimeout')(() => {
|
||||
const fs = require('fs'),
|
||||
@ -33,7 +33,6 @@ require('electron').remote.getGlobal('setTimeout')(() => {
|
||||
const head = document.getElementsByTagName('head')[0],
|
||||
css = ['user'];
|
||||
if (store.theme) css.push('theme');
|
||||
console.table(store);
|
||||
css.forEach((file) => {
|
||||
file = fs.readFileSync(`☃☃☃assets☃☃☃/${file}.css`); // will be set by python script
|
||||
let style = document.createElement('style');
|
||||
@ -52,44 +51,43 @@ require('electron').remote.getGlobal('setTimeout')(() => {
|
||||
node = document.querySelector('#window-buttons-area');
|
||||
|
||||
// always-on-top
|
||||
element = document.createElement('button');
|
||||
element.classList.add('window-buttons');
|
||||
element.innerHTML = '🠛';
|
||||
element.onclick = function () {
|
||||
const alwaysontopEl = document.createElement('button');
|
||||
alwaysontopEl.classList.add('window-buttons', 'btn-alwaysontop');
|
||||
alwaysontopEl.innerHTML = '🠛';
|
||||
alwaysontopEl.onclick = function () {
|
||||
const state = appwindow.isAlwaysOnTop();
|
||||
appwindow.setAlwaysOnTop(!state);
|
||||
this.innerHTML = state ? '🠛' : '🠙';
|
||||
};
|
||||
node.appendChild(element);
|
||||
node.appendChild(alwaysontopEl);
|
||||
|
||||
// minimise
|
||||
element = document.createElement('button');
|
||||
element.classList.add('window-buttons');
|
||||
element.innerHTML = '⚊';
|
||||
element.onclick = () => appwindow.minimize();
|
||||
node.appendChild(element);
|
||||
const minimizeEl = document.createElement('button');
|
||||
minimizeEl.classList.add('window-buttons', 'btn-minimize');
|
||||
minimizeEl.innerHTML = '⚊';
|
||||
minimizeEl.onclick = () => appwindow.minimize();
|
||||
node.appendChild(minimizeEl);
|
||||
|
||||
// maximise
|
||||
element = document.createElement('button');
|
||||
element.classList.add('window-buttons');
|
||||
element.innerHTML = appwindow.isMaximized() ? '🗗' : '🗖';
|
||||
element.onclick = function () {
|
||||
if (appwindow.isMaximized()) {
|
||||
appwindow.unmaximize();
|
||||
this.innerHTML = '🗖';
|
||||
} else {
|
||||
appwindow.maximize();
|
||||
this.innerHTML = '🗗';
|
||||
}
|
||||
const maximiseEl = document.createElement('button'),
|
||||
maximiseIcon = () => (appwindow.isMaximized() ? '🗗' : '🗖');
|
||||
maximiseEl.classList.add('window-buttons', 'btn-maximize');
|
||||
maximiseEl.innerHTML = maximiseIcon();
|
||||
maximiseEl.onclick = function () {
|
||||
if (appwindow.isMaximized()) appwindow.unmaximize();
|
||||
else appwindow.maximize();
|
||||
this.innerHTML = maximiseIcon();
|
||||
};
|
||||
node.appendChild(element);
|
||||
node.appendChild(maximiseEl);
|
||||
require('electron').remote.app.on('browser-window-focus', (event, win) => {
|
||||
if (win.id == appwindow.id) maximiseEl.innerHTML = maximiseIcon();
|
||||
});
|
||||
|
||||
// close
|
||||
const path = require('path');
|
||||
element = document.createElement('button');
|
||||
element.classList.add('window-buttons');
|
||||
element.innerHTML = '⨉';
|
||||
element.onclick = () => {
|
||||
const closeEl = document.createElement('button');
|
||||
closeEl.classList.add('window-buttons');
|
||||
closeEl.innerHTML = '⨉';
|
||||
closeEl.onclick = () => {
|
||||
if (
|
||||
store.tray &&
|
||||
require('electron').remote.BrowserWindow.getAllWindows().length === 1
|
||||
@ -97,7 +95,7 @@ require('electron').remote.getGlobal('setTimeout')(() => {
|
||||
appwindow.hide();
|
||||
} else appwindow.close();
|
||||
};
|
||||
node.appendChild(element);
|
||||
node.appendChild(closeEl);
|
||||
|
||||
/* reload window */
|
||||
document.defaultView.addEventListener(
|
||||
|
@ -5,7 +5,8 @@
|
||||
* (https://dragonwocky.me/) under the MIT license
|
||||
*/
|
||||
|
||||
// a wrapper for accessing data stored in a JSON file
|
||||
// a wrapper for accessing data stored in a JSON file.
|
||||
// editing this WILL break things if you don't know what you're doing.
|
||||
|
||||
const path = require('path'),
|
||||
fs = require('fs');
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
// adds: tray support (inc. context menu with settings), window toggle hotkey
|
||||
|
||||
// DO NOT REMOVE THE INJECTION MARKER ABOVE.
|
||||
// DO NOT REMOVE THE MARKERS ABOVE.
|
||||
// DO NOT CHANGE THE NAME OF THE 'enhancements()' FUNCTION.
|
||||
|
||||
let tray;
|
||||
@ -90,20 +90,22 @@ function enhancements() {
|
||||
]);
|
||||
tray.setContextMenu(contextMenu);
|
||||
|
||||
function showWindows(windows) {
|
||||
if (store.maximised)
|
||||
windows.forEach((win) => [win.maximize(), win.focus()]);
|
||||
else windows.forEach((win) => win.show());
|
||||
}
|
||||
tray.on('click', () => {
|
||||
const windows = electron_1.BrowserWindow.getAllWindows();
|
||||
if (windows.some((win) => win.isVisible()))
|
||||
windows.forEach((win) => win.hide());
|
||||
else if (store.maximised) windows.forEach((win) => win.maximize());
|
||||
else windows.forEach((win) => win.show());
|
||||
else showWindows(windows);
|
||||
});
|
||||
const hotkey = '☃☃☃hotkey☃☃☃'; // will be set by python script;
|
||||
electron_1.globalShortcut.register(hotkey, () => {
|
||||
const windows = electron_1.BrowserWindow.getAllWindows(),
|
||||
focused = electron_1.BrowserWindow.getFocusedWindow();
|
||||
if (windows.some((win) => win.isVisible() && focused))
|
||||
windows.forEach((win) => win.hide());
|
||||
else if (store.maximised) windows.forEach((win) => win.maximize());
|
||||
else windows.forEach((win) => win.show());
|
||||
// hotkey will be set by python script
|
||||
electron_1.globalShortcut.register('☃☃☃hotkey☃☃☃', () => {
|
||||
const windows = electron_1.BrowserWindow.getAllWindows();
|
||||
if (windows.some((win) => win.isFocused() && win.isVisible()))
|
||||
windows.forEach((win) => [win.blur(), win.hide()]);
|
||||
else showWindows(windows);
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user