From 3edca6462996a58fde45a6a4516110bcf82f1a56 Mon Sep 17 00:00:00 2001 From: Azalea Date: Thu, 15 Jun 2023 07:07:23 -0700 Subject: [PATCH] [O] Write to cache dir instead of config Closes #136 --- hyfetch/constants.py | 1 + hyfetch/main.py | 10 ++++++---- hyfetch/models.py | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/hyfetch/constants.py b/hyfetch/constants.py index 94afc99c..81536d40 100644 --- a/hyfetch/constants.py +++ b/hyfetch/constants.py @@ -6,6 +6,7 @@ from dataclasses import dataclass from pathlib import Path from .types import LightDark +from .__version__ import VERSION CONFIG_PATH = Path.home() / '.config/hyfetch.json' diff --git a/hyfetch/main.py b/hyfetch/main.py index f0a30234..14f71aed 100755 --- a/hyfetch/main.py +++ b/hyfetch/main.py @@ -376,7 +376,8 @@ def run(): # Check if it's June (pride month) now = datetime.datetime.now() - if now.month == 6 and now.year not in config.pride_month_shown and os.isatty(sys.stdout.fileno()): + june_path = CACHE_PATH / f'animation-displayed-{now.year}' + if now.month == 6 and now.year not in config.pride_month_shown and not june_path.is_file() and os.isatty(sys.stdout.fileno()): args.june = True if args.june and not config.pride_month_disable: @@ -385,9 +386,10 @@ def run(): print("Happy pride month!") print("(You can always view the animation again with `hyfetch --june`)") print() - if now.year not in config.pride_month_shown: - config.pride_month_shown.append(now.year) - config.save() + + if not june_path.is_file(): + june_path.parent.mkdir(parents=True, exist_ok=True) + june_path.touch() # Use a custom distro GLOBAL_CFG.override_distro = args.distro or config.distro diff --git a/hyfetch/models.py b/hyfetch/models.py index 6974ccae..7050e3b0 100644 --- a/hyfetch/models.py +++ b/hyfetch/models.py @@ -17,7 +17,7 @@ class Config: color_align: ColorAlignment = field(default_factory=lambda: ColorAlignment('horizontal')) backend: BackendLiteral = "neofetch" distro: str | None = None - pride_month_shown: list[int] = field(default_factory=list) + pride_month_shown: list[int] = field(default_factory=list) # This is deprecated, see issue #136 pride_month_disable: bool = False @classmethod