mirror of https://github.com/borgbase/vorta
Remove os library (#710)
Co-authored-by: Hofer Julian <30049909+Hofer-Julian@users.noreply.github.com>
This commit is contained in:
parent
97dad34df0
commit
2b1fce0936
|
@ -1,6 +1,4 @@
|
||||||
import sys
|
import sys
|
||||||
import os
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
AUTOSTART_DELAY = """StartupNotify=false
|
AUTOSTART_DELAY = """StartupNotify=false
|
||||||
X-GNOME-Autostart-enabled=true
|
X-GNOME-Autostart-enabled=true
|
||||||
|
@ -33,18 +31,19 @@ def open_app_at_startup(enabled=True):
|
||||||
LSSharedFileListItemRemove(login_items, new_item)
|
LSSharedFileListItemRemove(login_items, new_item)
|
||||||
|
|
||||||
elif sys.platform.startswith('linux'):
|
elif sys.platform.startswith('linux'):
|
||||||
|
from appdirs import user_config_dir
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
is_flatpak = Path('/.flatpak-info').exists()
|
is_flatpak = Path('/.flatpak-info').exists()
|
||||||
|
|
||||||
with open(os.path.join(os.path.dirname(__file__),
|
with open(Path(__file__).parent / "assets/metadata/com.borgbase.Vorta.desktop") as desktop_file:
|
||||||
"assets/metadata/com.borgbase.Vorta.desktop")) as desktop_file:
|
|
||||||
desktop_file_text = desktop_file.read()
|
desktop_file_text = desktop_file.read()
|
||||||
|
|
||||||
# Find XDG_CONFIG_HOME unless when running in flatpak
|
# Find XDG_CONFIG_HOME unless when running in flatpak
|
||||||
if is_flatpak:
|
if is_flatpak:
|
||||||
autostart_path = Path.home() / '.config' / 'autostart'
|
autostart_path = Path.home() / '.config' / 'autostart'
|
||||||
else:
|
else:
|
||||||
autostart_path = Path(os.environ.get(
|
autostart_path = Path(user_config_dir("autostart"))
|
||||||
"XDG_CONFIG_HOME", os.path.expanduser("~") + '/.config') + "/autostart")
|
|
||||||
|
|
||||||
if not autostart_path.exists():
|
if not autostart_path.exists():
|
||||||
autostart_path.mkdir()
|
autostart_path.mkdir()
|
||||||
|
@ -52,7 +51,7 @@ def open_app_at_startup(enabled=True):
|
||||||
autostart_file_path = autostart_path / 'vorta.desktop'
|
autostart_file_path = autostart_path / 'vorta.desktop'
|
||||||
|
|
||||||
if enabled:
|
if enabled:
|
||||||
# Replace to for flatpak if appropriate and start in background
|
# Replace command for flatpak if appropriate and start in background
|
||||||
desktop_file_text = desktop_file_text.replace(
|
desktop_file_text = desktop_file_text.replace(
|
||||||
"Exec=vorta", "Exec=flatpak run com.borgbase.Vorta --daemonize" if is_flatpak
|
"Exec=vorta", "Exec=flatpak run com.borgbase.Vorta --daemonize" if is_flatpak
|
||||||
else "Exec=vorta --daemonize")
|
else "Exec=vorta --daemonize")
|
||||||
|
@ -60,6 +59,5 @@ def open_app_at_startup(enabled=True):
|
||||||
desktop_file_text += (AUTOSTART_DELAY)
|
desktop_file_text += (AUTOSTART_DELAY)
|
||||||
|
|
||||||
autostart_file_path.write_text(desktop_file_text)
|
autostart_file_path.write_text(desktop_file_text)
|
||||||
else:
|
elif autostart_file_path.exists():
|
||||||
if autostart_file_path.exists():
|
|
||||||
autostart_file_path.unlink()
|
autostart_file_path.unlink()
|
||||||
|
|
Loading…
Reference in New Issue