mirror of https://github.com/borgbase/vorta
Avoid autostart warning when autostart disabled (#1549)
This commit is contained in:
parent
66340bc2a8
commit
ef297bbf4b
|
@ -24,10 +24,7 @@ jobs:
|
|||
pip install .
|
||||
pip install -r requirements.d/dev.txt
|
||||
- name: Test formatting with Flake8, isort and Black
|
||||
run: |
|
||||
flake8
|
||||
isort --check-only .
|
||||
black --check .
|
||||
run: make lint
|
||||
# - name: Run PyLint (info only)
|
||||
# run: pylint --rcfile=setup.cfg src --exit-zero
|
||||
|
||||
|
@ -85,11 +82,10 @@ jobs:
|
|||
if: runner.os == 'Linux'
|
||||
run: |
|
||||
xvfb-run --server-args="-screen 0 1024x768x24+32" \
|
||||
-a dbus-run-session -- pytest --cov=vorta
|
||||
-a dbus-run-session -- make test
|
||||
- name: Test with pytest (macOS)
|
||||
if: runner.os == 'macOS'
|
||||
run: |
|
||||
pytest --cov=vorta
|
||||
run: make test
|
||||
|
||||
- name: Upload coverage to Codecov
|
||||
uses: codecov/codecov-action@v1
|
||||
|
|
8
Makefile
8
Makefile
|
@ -56,5 +56,13 @@ flatpak-install: translations-to-qm
|
|||
install -D package/icon-symbolic.svg ${FLATPAK_DEST}/share/icons/hicolor/symbolic/apps/com.borgbase.Vorta-symbolic.svg
|
||||
install -D src/vorta/assets/metadata/com.borgbase.Vorta.desktop ${FLATPAK_DEST}/share/applications/com.borgbase.Vorta.desktop
|
||||
|
||||
lint:
|
||||
flake8
|
||||
isort --check-only .
|
||||
black --check .
|
||||
|
||||
test:
|
||||
pytest --cov=vorta
|
||||
|
||||
help:
|
||||
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
|
||||
|
|
|
@ -46,9 +46,9 @@ install_requires =
|
|||
psutil
|
||||
setuptools
|
||||
secretstorage; sys_platform != 'darwin'
|
||||
pyobjc-core<9.0; sys_platform == 'darwin'
|
||||
pyobjc-framework-Cocoa<9.0; sys_platform == 'darwin'
|
||||
pyobjc-framework-LaunchServices<9.0; sys_platform == 'darwin'
|
||||
pyobjc-core; sys_platform == 'darwin'
|
||||
pyobjc-framework-Cocoa; sys_platform == 'darwin'
|
||||
pyobjc-framework-LaunchServices; sys_platform == 'darwin'
|
||||
tests_require =
|
||||
pytest
|
||||
pytest-qt
|
||||
|
|
|
@ -17,11 +17,14 @@ def open_app_at_startup(enabled=True):
|
|||
|
||||
# CF = CDLL(find_library('CoreFoundation'))
|
||||
from LaunchServices import (
|
||||
LSSharedFileListCopySnapshot,
|
||||
LSSharedFileListCreate,
|
||||
LSSharedFileListInsertItemURL,
|
||||
LSSharedFileListItemRemove,
|
||||
LSSharedFileListItemResolve,
|
||||
kLSSharedFileListItemHidden,
|
||||
kLSSharedFileListItemLast,
|
||||
kLSSharedFileListNoUserInteraction,
|
||||
kLSSharedFileListSessionLoginItems,
|
||||
)
|
||||
|
||||
|
@ -30,9 +33,17 @@ def open_app_at_startup(enabled=True):
|
|||
login_items = LSSharedFileListCreate(kCFAllocatorDefault, kLSSharedFileListSessionLoginItems, None)
|
||||
props = NSDictionary.dictionaryWithObject_forKey_(True, kLSSharedFileListItemHidden)
|
||||
|
||||
new_item = LSSharedFileListInsertItemURL(login_items, kLSSharedFileListItemLast, None, None, url, props, None)
|
||||
if not enabled:
|
||||
LSSharedFileListItemRemove(login_items, new_item)
|
||||
if enabled:
|
||||
LSSharedFileListInsertItemURL(login_items, kLSSharedFileListItemLast, None, None, url, props, None)
|
||||
else:
|
||||
# From https://github.com/pudquick/pyLoginItems/blob/master/pyLoginItems.py
|
||||
list_ref = LSSharedFileListCreate(None, kLSSharedFileListSessionLoginItems, None)
|
||||
login_items, _ = LSSharedFileListCopySnapshot(list_ref, None)
|
||||
flags = kLSSharedFileListNoUserInteraction + kLSSharedFileListNoUserInteraction
|
||||
for i in login_items:
|
||||
err, a_CFURL, a_FSRef = LSSharedFileListItemResolve(i, flags, None, None)
|
||||
if 'Vorta.app' in str(a_CFURL):
|
||||
LSSharedFileListItemRemove(list_ref, i)
|
||||
|
||||
elif sys.platform.startswith('linux'):
|
||||
from pathlib import Path
|
||||
|
|
Loading…
Reference in New Issue