[api] refactoring: adding AUTOSTART_DIR constant to 'paths' module

This commit is contained in:
Vinicius Moreira
2021-11-24 14:14:04 -03:00
parent 0c11c4c166
commit 530a5019e2
4 changed files with 6 additions and 4 deletions

View File

@@ -26,7 +26,7 @@ from bauh.api.abstract.model import SoftwarePackage, CustomSoftwareAction, Packa
SuggestionPriority, PackageStatus
from bauh.api.abstract.view import MessageType, MultipleSelectComponent, InputOption, SingleSelectComponent, \
SelectViewType, TextInputComponent, FormComponent, FileChooserComponent, ViewComponent, PanelComponent
from bauh.api.paths import DESKTOP_ENTRIES_DIR
from bauh.api.paths import DESKTOP_ENTRIES_DIR, AUTOSTART_DIR
from bauh.commons import resource
from bauh.commons.boot import CreateConfigFile
from bauh.commons.html import bold
@@ -763,8 +763,7 @@ class WebApplicationManager(SoftwareManager):
pkg.desktop_entry = desktop_entry_path
if '--tray=start-in-tray' in install_options:
autostart_dir = '{}/.config/autostart'.format(Path.home())
Path(autostart_dir).mkdir(parents=True, exist_ok=True)
Path(AUTOSTART_DIR).mkdir(parents=True, exist_ok=True)
with open(pkg.get_autostart_path(), 'w+') as f:
f.write(entry_content)

View File

@@ -6,6 +6,7 @@ from typing import List
from bauh import __app_name__
from bauh.api import user
from bauh.api.abstract.model import SoftwarePackage
from bauh.api.paths import AUTOSTART_DIR
from bauh.commons import resource
from bauh.gems.web import ROOT_DIR
@@ -125,7 +126,7 @@ class WebApplication(SoftwarePackage):
def get_autostart_path(self) -> str:
if self.desktop_entry:
return f"{Path.home()}/.config/autostart/{self.desktop_entry.split('/')[-1]}"
return f"{AUTOSTART_DIR}/{self.desktop_entry.split('/')[-1]}"
def set_custom_icon(self, custom_icon: str):
self.custom_icon = custom_icon