diff --git a/.gitignore b/.gitignore index 67c8fa2..d001441 100644 --- a/.gitignore +++ b/.gitignore @@ -104,3 +104,6 @@ dist # TernJS port file .tern-port + +#JetBrains .idea folder +.idea/ diff --git a/cleaner.py b/cleaner.py index 8580586..5214649 100644 --- a/cleaner.py +++ b/cleaner.py @@ -1,4 +1,3 @@ - # notion-enhancer # (c) 2020 dragonwocky # (c) 2020 TarasokUA @@ -25,12 +24,12 @@ try: filepath = '' if 'microsoft' in platform.uname()[3].lower() and sys.platform == 'linux': filepath = '/mnt/c/' + \ - subprocess.run( - ['cmd.exe', '/c', 'echo', '%localappdata%'], stdout=subprocess.PIPE).stdout \ - .rstrip().decode('utf-8')[3:].replace('\\', '/') + '/Programs/Notion/resources' + subprocess.run( + ['cmd.exe', '/c', 'echo', '%localappdata%'], stdout=subprocess.PIPE).stdout \ + .rstrip().decode('utf-8')[3:].replace('\\', '/') + '/Programs/Notion/resources' elif sys.platform == 'win32': filepath = subprocess.run(['echo', '%localappdata%'], shell=True, capture_output=True).stdout \ - .rstrip().decode('utf-8') + '\\Programs\\Notion\\resources' + .rstrip().decode('utf-8') + '\\Programs\\Notion\\resources' elif sys.platform == 'linux': filepath = '/opt/notion-app' if os.path.exists( '/opt/notion-app') else '/opt/notion' @@ -57,23 +56,15 @@ try: f' * {os.path.join(filepath, "app.asar.bak")} was not found: step skipped.') if sys.platform == 'linux' and 'microsoft' not in platform.uname()[3].lower(): - path = '' - if os.path.exists('/opt/notion-app/notion-app'): - path = '/opt/notion-app/notion-app' - elif os.path.exists('/usr/bin/notion-app'): - path = '/usr/bin/notion-app' - elif os.path.exists('/usr/bin/notion'): - path = '/usr/bin/notion' - else: - raise ValueError("Couldn't find the app launcher") - with open(path, 'r', encoding='UTF-8') as launcher: - contents = launcher.read() - if 'app.asar' not in contents: - print( - f' ...patching app launcher') - subprocess.call( - ['sed', '-i', r's/electron6\ app/electron6\ app\.asar/', - path]) + pathlist = ['/usr/bin/notion-app', '/usr/bin/notion', '/opt/notion-app/notion-app'] + # get all the possible paths where the launcher may be located + for path in pathlist: + if os.path.exists(path): + with open(path, 'r', encoding='UTF-8') as launcher: + contents = launcher.read() + if 'app.asar' not in contents: + print(f' ...patching app launcher in {path}') + subprocess.call(['sed', '-i', r's/electron6\ app/electron6\ app\.asar/', path]) print(f'\n{bold}>>> SUCCESSFULLY CLEANED <<<{normal}') diff --git a/customiser.py b/customiser.py index af15c00..7002487 100755 --- a/customiser.py +++ b/customiser.py @@ -224,19 +224,15 @@ try: f' * {os.path.join(filepath, "app", "main", "main.js")} was not found: step skipped.') if sys.platform == 'linux' and 'microsoft' not in platform.uname()[3].lower(): - print( - f' ...patching app launcher') - s = '' - if os.path.exists('/opt/notion-app/notion-app'): - s = '/opt/notion-app/notion-app' - elif os.path.exists('/usr/bin/notion-app'): - s = '/usr/bin/notion-app' - elif os.path.exists('/usr/bin/notion'): - s = '/usr/bin/notion' - else: - raise ValueError("Couldn't find the app launcher") - subprocess.call( - ['sed', '-i', r's/electron6\ app\.asar/electron6\ app/', s]) + def patch(dest): + print(f' ...patching app launcher in {path}') + subprocess.call(['sed', '-i', r's/electron6\ app\.asar/electron6\ app/', dest]) + + pathlist = ['/usr/bin/notion-app', '/usr/bin/notion', '/opt/notion-app/notion-app'] + # check all the paths where the launcher may be located + for path in pathlist: + if os.path.exists(path): + patch(path) print('\n>>> SUCCESSFULLY CUSTOMISED <<<')