From 42c64c55e88644956d370ac7df067ca1a51a3da2 Mon Sep 17 00:00:00 2001 From: mdwalters Date: Wed, 12 Jul 2023 15:16:55 -0400 Subject: [PATCH] fix: finally solved our caching dilemna --- ml.mdwalters.Lemonade.json | 3 +-- src/main.py | 8 ++++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ml.mdwalters.Lemonade.json b/ml.mdwalters.Lemonade.json index c7df07a..cad90ef 100644 --- a/ml.mdwalters.Lemonade.json +++ b/ml.mdwalters.Lemonade.json @@ -9,8 +9,7 @@ "--share=ipc", "--socket=fallback-x11", "--device=dri", - "--socket=wayland", - "--filesystem=home" + "--socket=wayland" ], "cleanup" : [ "/include", diff --git a/src/main.py b/src/main.py index a5e766f..c9fa783 100644 --- a/src/main.py +++ b/src/main.py @@ -4,6 +4,7 @@ import json import requests import urllib.request import http +import os gi.require_version("Gtk", "4.0") gi.require_version("Adw", "1") @@ -84,12 +85,15 @@ class LemonadeWindow(Gtk.ApplicationWindow): if "icon" in community["community"]: try: + print(f"Downloading icon for {community['community']['title']}") name = community["community"]["icon"].split("/")[-1] - urllib.request.urlretrieve(community["community"]["icon"], f"~/.cache/{name}") - avatar.set_custom_image(Gdk.Texture.new_from_file(Gio.File.new_for_path(f"~/.cache/{name}"))) + urllib.request.urlretrieve(community["community"]["icon"], f"{os.environ['XDG_RUNTIME_DIR']}/app/{os.environ['FLATPAK_ID']}/cache/{name}") + avatar.set_custom_image(Gdk.Texture.new_from_file(Gio.File.new_for_path(f"{os.environ['XDG_RUNTIME_DIR']}/app/{os.environ['FLATPAK_ID']}/cache/{name}"))) except: + print(f"Error getting icon for {community['community']['title']}") pass else: + print(f"No icon found for {community['community']['title']}, skipping") pass if not "description" in community["community"]: