diff --git a/pikaur/config.py b/pikaur/config.py index fd7528f7..f8789bb6 100644 --- a/pikaur/config.py +++ b/pikaur/config.py @@ -144,6 +144,18 @@ def init_value(cls) -> Path: return Path(gettempdir()) +class _CachePathDefault(FixedPathSingleton): + @classmethod + def init_value(cls) -> Path: + return Path( + pre_arg_parser("--xdg-cache-home", "") + or os.environ.get( + "XDG_CACHE_HOME", + ) + or Home()() / ".cache/", + ) + + class _UserCacheRoot(FixedPathSingleton): @classmethod def init_value(cls) -> Path: @@ -190,6 +202,18 @@ def init_value(cls) -> Path: ) +class _DataPathDefault(FixedPathSingleton): + @classmethod + def init_value(cls) -> Path: + return Path( + pre_arg_parser("--xdg-data-home", "") + or os.environ.get( + "XDG_DATA_HOME", + ) + or Home()() / ".local/share/", + ) + + class DataRoot(FixedPathSingleton): @classmethod def init_value(cls) -> Path: @@ -459,11 +483,11 @@ class DiffPagerValues: }, "CachePath": { "data_type": STR, - "default": str(Home()() / ".cache/"), + "default": str(_CachePathDefault()()), }, "DataPath": { "data_type": STR, - "default": str(Home()() / ".local/share/"), + "default": str(_DataPathDefault()()), }, "PacmanPath": { "data_type": STR, diff --git a/pikaur/privilege.py b/pikaur/privilege.py index d1f87025..2eb6d531 100644 --- a/pikaur/privilege.py +++ b/pikaur/privilege.py @@ -119,7 +119,7 @@ def get_args_to_elevate_pikaur(original_args: list[str]) -> list[str]: ("--xdg-data-home", "xdg_data_home", "XDG_DATA_HOME"), ): arg_value = str(getattr(args, arg_key, None) or "") - if value := (arg_value or os.environ.get(env_key)): + if value := (os.environ.get(env_key) or arg_value): extra_args += [ (flag, value), ]