[O] Write to cache dir instead of config

Closes #136
This commit is contained in:
Azalea 2023-06-15 07:07:23 -07:00
parent 2edf9c1304
commit 3edca64629
3 changed files with 8 additions and 5 deletions

View file

@ -6,6 +6,7 @@ from dataclasses import dataclass
from pathlib import Path from pathlib import Path
from .types import LightDark from .types import LightDark
from .__version__ import VERSION
CONFIG_PATH = Path.home() / '.config/hyfetch.json' CONFIG_PATH = Path.home() / '.config/hyfetch.json'

View file

@ -376,7 +376,8 @@ def run():
# Check if it's June (pride month) # Check if it's June (pride month)
now = datetime.datetime.now() 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 args.june = True
if args.june and not config.pride_month_disable: if args.june and not config.pride_month_disable:
@ -385,9 +386,10 @@ def run():
print("Happy pride month!") print("Happy pride month!")
print("(You can always view the animation again with `hyfetch --june`)") print("(You can always view the animation again with `hyfetch --june`)")
print() print()
if now.year not in config.pride_month_shown:
config.pride_month_shown.append(now.year) if not june_path.is_file():
config.save() june_path.parent.mkdir(parents=True, exist_ok=True)
june_path.touch()
# Use a custom distro # Use a custom distro
GLOBAL_CFG.override_distro = args.distro or config.distro GLOBAL_CFG.override_distro = args.distro or config.distro

View file

@ -17,7 +17,7 @@ class Config:
color_align: ColorAlignment = field(default_factory=lambda: ColorAlignment('horizontal')) color_align: ColorAlignment = field(default_factory=lambda: ColorAlignment('horizontal'))
backend: BackendLiteral = "neofetch" backend: BackendLiteral = "neofetch"
distro: str | None = None 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 pride_month_disable: bool = False
@classmethod @classmethod