diff options
| author | Jan <sentrycraft123@gmail.com> | 2023-11-11 21:50:23 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-11-11 20:50:23 +0000 |
| commit | 75ad98a7b2ce53bf2916a6bfb760599e7b50fc9d (patch) | |
| tree | 12e7ddd910a1851dc15890ea7cbf6ba9adf39861 | |
| parent | 479a16c6557fc9656e1ff601e6ed7e677846d428 (diff) | |
| download | decky-loader-75ad98a7b2ce53bf2916a6bfb760599e7b50fc9d.tar.gz decky-loader-75ad98a7b2ce53bf2916a6bfb760599e7b50fc9d.zip | |
Check if Linux service is running before trying to start or stop it (#540)
this prevents needless prompts opening up
| -rw-r--r-- | backend/src/localplatformlinux.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/backend/src/localplatformlinux.py b/backend/src/localplatformlinux.py index bde2caac..846fa074 100644 --- a/backend/src/localplatformlinux.py +++ b/backend/src/localplatformlinux.py @@ -125,11 +125,19 @@ async def service_restart(service_name : str) -> bool: return res.returncode == 0 async def service_stop(service_name : str) -> bool: + if not await service_active(service_name): + # Service isn't running. pretend we stopped it + return True + cmd = ["systemctl", "stop", service_name] res = run(cmd, stdout=PIPE, stderr=STDOUT) return res.returncode == 0 async def service_start(service_name : str) -> bool: + if await service_active(service_name): + # Service is running. pretend we started it + return True + cmd = ["systemctl", "start", service_name] res = run(cmd, stdout=PIPE, stderr=STDOUT) return res.returncode == 0 |
