Skip to content

Commit

Permalink
[O] Write to cache dir instead of config
Browse files Browse the repository at this point in the history
Closes #136
  • Loading branch information
hykilpikonna committed Jun 15, 2023
1 parent 2edf9c1 commit 3edca64
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions hyfetch/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from pathlib import Path

from .types import LightDark
from .__version__ import VERSION

CONFIG_PATH = Path.home() / '.config/hyfetch.json'

Expand Down
10 changes: 6 additions & 4 deletions hyfetch/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion hyfetch/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3edca64

Please sign in to comment.