1
0
Fork 0
mirror of https://github.com/borgbase/vorta synced 2024-12-23 00:07:58 +00:00

Make Flatpak Ready

1) Change socket-file path so that Flatpaks has access
2) Change autostart function so that it detects if it is run as Flatpak
This commit is contained in:
Julian Hofer 2019-05-03 20:57:05 +02:00 committed by Hofer-Julian
parent 33c16d925f
commit 8f5953b3b4
3 changed files with 25 additions and 9 deletions

View file

@ -1,8 +1,12 @@
import os
import sys
import qdarkstyle
from PyQt5 import QtCore
import sip
from vorta.borg.version import BorgVersionThread
from vorta.config import STATE_DIR
from .borg.create import BorgCreateThread
from .i18n import init_translations, translate
@ -10,12 +14,10 @@
from .qt_single_application import QtSingleApplication
from .scheduler import VortaScheduler
from .tray_menu import TrayMenu
from .utils import parse_args, set_tray_icon, borg_compat
from .utils import borg_compat, parse_args, set_tray_icon
from .views.main_window import MainWindow
from vorta.borg.version import BorgVersionThread
APP_ID = "vorta"
APP_ID = os.path.join(STATE_DIR, "socket")
class VortaApp(QtSingleApplication):

View file

@ -1,18 +1,18 @@
import sys
from pathlib import Path
from PyQt5 import QtCore
LINUX_STARTUP_FILE = """\
[Desktop Entry]
Name=Vorta
GenericName=Backup Software
Exec=vorta
Exec={}
Terminal=false
Icon=vorta
Categories=Utility
Type=Application
StartupNotify=false
X-GNOME-Autostart-enabled=true
X-GNOME-Autostart-Delay=20
"""
@ -41,10 +41,20 @@ def open_app_at_startup(enabled=True):
LSSharedFileListItemRemove(login_items, new_item)
elif sys.platform.startswith('linux'):
config_path = QtCore.QStandardPaths.writableLocation(QtCore.QStandardPaths.ConfigLocation)
autostart_file_path = Path(config_path) / 'autostart' / 'vorta.desktop'
autostart_path = Path.home() / '.config' / 'autostart'
if not autostart_path.exists():
autostart_path.mkdir()
autostart_file_path = autostart_path / 'vorta.desktop'
if enabled:
autostart_file_path.write_text(LINUX_STARTUP_FILE)
if Path('/.flatpak-info').exists():
# Vorta runs as flatpak
autostart_file_path.write_text(LINUX_STARTUP_FILE.format('flatpak run com.borgbase.vorta'))
else:
autostart_file_path.write_text(LINUX_STARTUP_FILE.format('vorta'))
else:
if autostart_file_path.exists():
autostart_file_path.unlink()

View file

@ -6,9 +6,13 @@
dirs = appdirs.AppDirs(APP_NAME, APP_AUTHOR)
SETTINGS_DIR = dirs.user_data_dir
LOG_DIR = dirs.user_log_dir
STATE_DIR = dirs.user_state_dir
if not os.path.exists(SETTINGS_DIR):
os.makedirs(SETTINGS_DIR)
if not os.path.exists(LOG_DIR):
os.makedirs(LOG_DIR)
if not os.path.exists(STATE_DIR):
os.makedirs(STATE_DIR)