Skip to content

Commit acfb9db

Browse files
authored
Merge pull request #13 from Bergbok/scoop-support
Add support for scoop installations
2 parents eec317f + a455d7e commit acfb9db

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

funcs.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ def start_discord(discord_parent_path: str):
88
script_working_dir = os.getcwd()
99

1010
os.chdir('c:/')
11-
subprocess.Popen(f'{os.path.join(discord_parent_path, "Update.exe")} --processStart Discord.exe')
11+
if 'scoop\\apps' in discord_parent_path:
12+
latest_installed_discord_version = get_latest_installed_discord_folder_name(discord_parent_path)
13+
subprocess.Popen(f'{os.path.join(discord_parent_path, latest_installed_discord_version, "Discord.exe")}', stdout=subprocess.DEVNULL)
14+
else:
15+
subprocess.Popen(f'{os.path.join(discord_parent_path, "Update.exe")} --processStart Discord.exe')
1216
os.chdir(script_working_dir)
1317

1418

main.py

+11-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import sys
22
import time
33
import json
4+
import shutil
45
import logging
56
import requests
67
from funcs import *
@@ -29,6 +30,7 @@ def dump_settings():
2930
logger = logging.getLogger(__name__)
3031
logging.basicConfig(level=logging.INFO, format='(%(asctime)s) %(message)s')
3132
appdata = os.getenv('appdata')
33+
home = os.getenv('userprofile')
3234
localappdata = os.getenv('localappdata')
3335

3436
SETTINGS_PATH = 'settings.json'
@@ -39,10 +41,16 @@ def dump_settings():
3941

4042
# default settings
4143
CURRENT_SETTINGS_VERSION = 3
42-
DISCORD_PARENT_PATH = f'{localappdata}/Discord'
44+
DISCORD_PARENT_PATH = f'{localappdata}\\Discord'
4345
LAST_INSTALLED_DISCORD_VERSION = None
4446
DISABLE_VERSION_CHECKING = False
4547

48+
if shutil.which('scoop') is not None:
49+
scoop_info = subprocess.run(['scoop', 'list', 'discord'], capture_output=True, text=True, shell=True).stdout.splitlines()
50+
discord_line = next((line for line in scoop_info if line.startswith('discord ')), None)
51+
if discord_line:
52+
DISCORD_PARENT_PATH = f'{home}\\scoop\\apps\\discord\\current\\app'
53+
4654
# try to load settings
4755
if os.path.exists(SETTINGS_PATH):
4856
try:
@@ -60,8 +68,8 @@ def dump_settings():
6068

6169
# get discord location from user if it is invalid
6270
while True:
63-
if not os.path.exists(os.path.join(DISCORD_PARENT_PATH, 'update.exe')):
64-
logger.info(f'Discord was not found at "{DISCORD_PARENT_PATH}". Enter the path to folder with "Update.exe":')
71+
if not os.path.exists(os.path.join(DISCORD_PARENT_PATH, 'Update.exe')) and not os.path.exists(os.path.join(discord_path, 'Discord.exe')):
72+
logger.info(f'Discord was not found at "{DISCORD_PARENT_PATH}".\nEnter the path to folder with "Update.exe" for normal installations or full path of ~\\scoop\\apps\\discord\\current\\app for scoop installations:')
6573
DISCORD_PARENT_PATH = input('\n=> ')
6674
dump_settings()
6775
else:

0 commit comments

Comments
 (0)