Made the scripts check all known linux applicaion starters instead of just one

This commit is contained in:
Nek-12 2020-07-16 20:36:47 +03:00
parent 6e1d9e9516
commit 829335a739
3 changed files with 25 additions and 35 deletions

3
.gitignore vendored
View File

@ -104,3 +104,6 @@ dist
# TernJS port file # TernJS port file
.tern-port .tern-port
#JetBrains .idea folder
.idea/

View File

@ -1,4 +1,3 @@
# notion-enhancer # notion-enhancer
# (c) 2020 dragonwocky <thedragonring.bod@gmail.com> # (c) 2020 dragonwocky <thedragonring.bod@gmail.com>
# (c) 2020 TarasokUA # (c) 2020 TarasokUA
@ -25,12 +24,12 @@ try:
filepath = '' filepath = ''
if 'microsoft' in platform.uname()[3].lower() and sys.platform == 'linux': if 'microsoft' in platform.uname()[3].lower() and sys.platform == 'linux':
filepath = '/mnt/c/' + \ filepath = '/mnt/c/' + \
subprocess.run( subprocess.run(
['cmd.exe', '/c', 'echo', '%localappdata%'], stdout=subprocess.PIPE).stdout \ ['cmd.exe', '/c', 'echo', '%localappdata%'], stdout=subprocess.PIPE).stdout \
.rstrip().decode('utf-8')[3:].replace('\\', '/') + '/Programs/Notion/resources' .rstrip().decode('utf-8')[3:].replace('\\', '/') + '/Programs/Notion/resources'
elif sys.platform == 'win32': elif sys.platform == 'win32':
filepath = subprocess.run(['echo', '%localappdata%'], shell=True, capture_output=True).stdout \ 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': elif sys.platform == 'linux':
filepath = '/opt/notion-app' if os.path.exists( filepath = '/opt/notion-app' if os.path.exists(
'/opt/notion-app') else '/opt/notion' '/opt/notion-app') else '/opt/notion'
@ -57,23 +56,15 @@ try:
f' * {os.path.join(filepath, "app.asar.bak")} was not found: step skipped.') 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(): if sys.platform == 'linux' and 'microsoft' not in platform.uname()[3].lower():
path = '' pathlist = ['/usr/bin/notion-app', '/usr/bin/notion', '/opt/notion-app/notion-app']
if os.path.exists('/opt/notion-app/notion-app'): # get all the possible paths where the launcher may be located
path = '/opt/notion-app/notion-app' for path in pathlist:
elif os.path.exists('/usr/bin/notion-app'): if os.path.exists(path):
path = '/usr/bin/notion-app' with open(path, 'r', encoding='UTF-8') as launcher:
elif os.path.exists('/usr/bin/notion'): contents = launcher.read()
path = '/usr/bin/notion' if 'app.asar' not in contents:
else: print(f' ...patching app launcher in {path}')
raise ValueError("Couldn't find the app launcher") subprocess.call(['sed', '-i', r's/electron6\ app/electron6\ app\.asar/', path])
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])
print(f'\n{bold}>>> SUCCESSFULLY CLEANED <<<{normal}') print(f'\n{bold}>>> SUCCESSFULLY CLEANED <<<{normal}')

View File

@ -224,19 +224,15 @@ try:
f' * {os.path.join(filepath, "app", "main", "main.js")} was not found: step skipped.') 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(): if sys.platform == 'linux' and 'microsoft' not in platform.uname()[3].lower():
print( def patch(dest):
f' ...patching app launcher') print(f' ...patching app launcher in {path}')
s = '' subprocess.call(['sed', '-i', r's/electron6\ app\.asar/electron6\ app/', dest])
if os.path.exists('/opt/notion-app/notion-app'):
s = '/opt/notion-app/notion-app' pathlist = ['/usr/bin/notion-app', '/usr/bin/notion', '/opt/notion-app/notion-app']
elif os.path.exists('/usr/bin/notion-app'): # check all the paths where the launcher may be located
s = '/usr/bin/notion-app' for path in pathlist:
elif os.path.exists('/usr/bin/notion'): if os.path.exists(path):
s = '/usr/bin/notion' patch(path)
else:
raise ValueError("Couldn't find the app launcher")
subprocess.call(
['sed', '-i', r's/electron6\ app\.asar/electron6\ app/', s])
print('\n>>> SUCCESSFULLY CUSTOMISED <<<') print('\n>>> SUCCESSFULLY CUSTOMISED <<<')