Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- Nothing

### Fixed:
- Nothing
- Fix Windows start with system setting and quotes usage (#156 by @oneshoekid & @Willy-JL)

### Removed:
- Nothing
Expand Down
6 changes: 3 additions & 3 deletions modules/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1220,16 +1220,16 @@ def cancel_callback():
"Start-Sleep -Seconds 3",
'Write-Host "Deleting old version files..."',
" | ".join((
f"Get-ChildItem -Force -Recurse -Path {shlex.quote(str(dst))}",
f'Get-ChildItem -Force -Recurse -Path "{dst}"',
"Select-Object -ExpandProperty FullName",
"Sort-Object -Property Length -Descending",
"Remove-Item -Force -Recurse",
)),
'Write-Host "Moving new version files..."',
" | ".join((
f"Get-ChildItem -Force -Path {shlex.quote(str(src))}",
f'Get-ChildItem -Force -Path "{src}"',
"Select-Object -ExpandProperty FullName",
f"Move-Item -Force -Destination {shlex.quote(str(dst))}",
f'Move-Item -Force -Destination "{dst}"',
)),
'Write-Host "Sleeping 3 seconds..."',
"Start-Sleep -Seconds 3",
Expand Down
6 changes: 4 additions & 2 deletions modules/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ def update_start_with_system(toggle: bool):
if globals.os is Os.Windows:
import winreg
current_user = winreg.ConnectRegistry(None, winreg.HKEY_CURRENT_USER)
winreg.SetValue(current_user, globals.autostart, winreg.REG_SZ, globals.start_cmd)
key = winreg.OpenKeyEx(current_user, str(globals.autostart.parent), 0, winreg.KEY_WRITE)
winreg.SetValueEx(key, globals.autostart.name, 0, winreg.REG_SZ, globals.start_cmd)
elif globals.os is Os.Linux:
config = configparser.RawConfigParser()
config.optionxform = lambda option: option
Expand All @@ -69,7 +70,8 @@ def update_start_with_system(toggle: bool):
if globals.os is Os.Windows:
import winreg
current_user = winreg.ConnectRegistry(None, winreg.HKEY_CURRENT_USER)
winreg.SetValue(current_user, globals.autostart, winreg.REG_SZ, "")
key = winreg.OpenKeyEx(current_user, str(globals.autostart.parent), 0, winreg.KEY_WRITE)
winreg.DeleteValue(key, globals.autostart.name)
elif globals.os is Os.Linux or globals.os is Os.MacOS:
globals.autostart.unlink()
globals.start_with_system = toggle
Expand Down
12 changes: 8 additions & 4 deletions modules/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,22 +174,25 @@ def _():
def _():
global start_cmd, autostart, start_with_system
if frozen:
start_cmd = shlex.join([sys.executable])
start_cmd = [sys.executable]
else:
from main import __file__ as main_path
start_cmd = shlex.join([sys.executable, main_path])
start_cmd = [sys.executable, main_path]

if os is Os.Windows:
import winreg
autostart = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run\\F95Checker"
start_cmd = " ".join(f'"{split}"' for split in start_cmd)
autostart = pathlib.Path("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run\\F95Checker")
try:
current_user = winreg.ConnectRegistry(None, winreg.HKEY_CURRENT_USER)
value = winreg.QueryValue(current_user, autostart)
key = winreg.OpenKeyEx(current_user, str(autostart.parent))
value = winreg.QueryValueEx(key, autostart.name)[0]
start_with_system = value == start_cmd
except Exception:
start_with_system = False
elif os is Os.Linux:
import configparser
start_cmd = shlex.join(start_cmd)
autostart_dir = pathlib.Path.home() / ".config/autostart"
autostart_dir.mkdir(parents=True, exist_ok=True)
autostart = autostart_dir / "F95Checker.desktop"
Expand All @@ -203,6 +206,7 @@ def _():
start_with_system = False
elif os is Os.MacOS:
import plistlib
start_cmd = shlex.join(start_cmd)
autostart_dir = pathlib.Path.home() / "Library/LaunchAgents"
autostart_dir.mkdir(parents=True, exist_ok=True)
autostart = autostart_dir / "io.github.willy-jl.f95checker.plist"
Expand Down