From e01fbcfa3e778b4d8c3d5e18727258b5bfee5d14 Mon Sep 17 00:00:00 2001 From: Julien Reichardt Date: Sun, 6 Aug 2023 17:06:47 +0200 Subject: [PATCH] Create shortcuts in subdirectory Fixes #2264 by creating and giving the rights to create shortcuts into a specific applications directory. --- bottles/backend/globals.py | 3 ++- bottles/backend/managers/manager.py | 2 +- bottles/backend/utils/manager.py | 6 ++++-- com.usebottles.bottles.yml | 1 + 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/bottles/backend/globals.py b/bottles/backend/globals.py index 152afd4194..9dd81d3f28 100644 --- a/bottles/backend/globals.py +++ b/bottles/backend/globals.py @@ -33,7 +33,8 @@ class Paths: base = f"{xdg_data_home}/bottles" # User applications path - applications = f"{xdg_data_home}/applications/" + applications = f"{xdg_data_home}/applications" + applications_bottles = f"{applications}/bottles/" temp = f"{base}/temp" runtimes = f"{base}/runtimes" diff --git a/bottles/backend/managers/manager.py b/bottles/backend/managers/manager.py index 9be2ed31af..53dcfc963f 100644 --- a/bottles/backend/managers/manager.py +++ b/bottles/backend/managers/manager.py @@ -1461,7 +1461,7 @@ def delete_bottle(self, config: BottleConfig) -> bool: return False logging.info(f"Removing applications installed with the bottle…") - for inst in glob(f"{Paths.applications}/{config.Name}--*"): + for inst in glob(f"{Paths.applications}/{config.Name}--*") + glob(f"{Paths.applications_bottles}/{config.Name}--*"): os.remove(inst) logging.info(f"Removing library entries associated with this bottle…") diff --git a/bottles/backend/utils/manager.py b/bottles/backend/utils/manager.py index c102a6aab9..75a131fa7d 100644 --- a/bottles/backend/utils/manager.py +++ b/bottles/backend/utils/manager.py @@ -206,6 +206,8 @@ def create_desktop_entry(config, program: dict, skip_icon: bool = False, custom_ use_xdp: bool = False) -> bool: if not os.path.exists(Paths.applications) and not use_xdp: return False + else: + os.makedirs(Paths.applications_bottles, exist_ok=True) cmd_legacy = "bottles" cmd_cli = "bottles-cli" @@ -223,13 +225,13 @@ def create_desktop_entry(config, program: dict, skip_icon: bool = False, custom_ if not use_xdp: file_name_template = "%s/%s--%s--%s.desktop" existing_files = glob(file_name_template % ( - Paths.applications, + Paths.applications_bottles, config.Name, program.get("name"), "*" )) desktop_file = file_name_template % ( - Paths.applications, + Paths.applications_bottles, config.Name, program.get("name"), datetime.now().timestamp() diff --git a/com.usebottles.bottles.yml b/com.usebottles.bottles.yml index 976ad74964..1d05dfce78 100644 --- a/com.usebottles.bottles.yml +++ b/com.usebottles.bottles.yml @@ -17,6 +17,7 @@ finish-args: - --socket=pulseaudio - --device=all - --filesystem=xdg-download + - --filesystem=xdg-data/applications/bottles:create - --system-talk-name=org.freedesktop.UDisks2 - --env=LD_LIBRARY_PATH=/app/lib:/app/lib32 - --env=PATH=/app/bin:/app/utils/bin:/usr/bin:/usr/lib/extensions/vulkan/MangoHud/bin/:/usr/bin:/usr/lib/extensions/vulkan/OBSVkCapture/bin/