mirror of https://github.com/borgbase/vorta
Fix autostart for Linux (#213)
This commit is contained in:
parent
7487c40ec6
commit
4b197f20d8
|
@ -1,15 +1,12 @@
|
||||||
import sys
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from PyQt5 import QtCore
|
from PyQt5 import QtCore
|
||||||
from setuptools import Distribution
|
|
||||||
from setuptools.command.install import install
|
|
||||||
|
|
||||||
|
|
||||||
LINUX_STARTUP_FILE = """\
|
LINUX_STARTUP_FILE = """\
|
||||||
[Desktop Entry]
|
[Desktop Entry]
|
||||||
Name=Vorta
|
Name=Vorta
|
||||||
GenericName=Backup Software
|
GenericName=Backup Software
|
||||||
Exec={}/vorta
|
Exec=vorta
|
||||||
Terminal=false
|
Terminal=false
|
||||||
Icon=vorta
|
Icon=vorta
|
||||||
Categories=Utility
|
Categories=Utility
|
||||||
|
@ -42,31 +39,12 @@ def open_app_at_startup(enabled=True):
|
||||||
None, None, url, props, None)
|
None, None, url, props, None)
|
||||||
if not enabled:
|
if not enabled:
|
||||||
LSSharedFileListItemRemove(login_items, new_item)
|
LSSharedFileListItemRemove(login_items, new_item)
|
||||||
|
|
||||||
elif sys.platform.startswith('linux'):
|
elif sys.platform.startswith('linux'):
|
||||||
config_path = QtCore.QStandardPaths.writableLocation(QtCore.QStandardPaths.ConfigLocation)
|
config_path = QtCore.QStandardPaths.writableLocation(QtCore.QStandardPaths.ConfigLocation)
|
||||||
autostart_file_path = Path(config_path) / 'autostart' / 'vorta.desktop'
|
autostart_file_path = Path(config_path) / 'autostart' / 'vorta.desktop'
|
||||||
if enabled:
|
if enabled:
|
||||||
dir_entry_point = get_setuptools_script_dir()
|
autostart_file_path.write_text(LINUX_STARTUP_FILE)
|
||||||
autostart_file_path.write_text(LINUX_STARTUP_FILE.format(dir_entry_point))
|
|
||||||
else:
|
else:
|
||||||
if autostart_file_path.exists():
|
if autostart_file_path.exists():
|
||||||
autostart_file_path.unlink()
|
autostart_file_path.unlink()
|
||||||
|
|
||||||
|
|
||||||
# Get entry point of vorta
|
|
||||||
# From https://stackoverflow.com/questions/
|
|
||||||
# 25066084/get-entry-point-script-file-location-in-setuputils-package
|
|
||||||
class OnlyGetScriptPath(install):
|
|
||||||
def run(self):
|
|
||||||
# does not call install.run() by design
|
|
||||||
self.distribution.install_scripts = self.install_scripts
|
|
||||||
|
|
||||||
|
|
||||||
def get_setuptools_script_dir():
|
|
||||||
dist = Distribution({'cmdclass': {'install': OnlyGetScriptPath}})
|
|
||||||
dist.dry_run = True # not sure if necessary, but to be safe
|
|
||||||
dist.parse_config_files()
|
|
||||||
command = dist.get_command_obj('install')
|
|
||||||
command.ensure_finalized()
|
|
||||||
command.run()
|
|
||||||
return dist.install_scripts
|
|
||||||
|
|
Loading…
Reference in New Issue