Skip to content

XDG directories for config #258

@rangelovkiril

Description

@rangelovkiril

Is your feature request related to a problem? Please describe.
Currently, instagram-cli stores all user data, config, cache, and downloads inside ~/.instagram-cli. While this works, it does not follow the XDG Base Directory specification, which is the standard on Linux and other Unix-like systems for separating configuration, cache, and user data. Users who follow XDG conventions have cluttered home directories, and this prevents integration with system-wide standards for managing user directories.

Describe the solution you'd like
Optional support for XDG user directories:

Purpose Current path Example XDG path
Config ~/.instagram-cli/config.ts.yaml $XDG_CONFIG_HOME/instagram-cli/config.ts.yaml
User data ~/.instagram-cli/users $XDG_DATA_HOME/instagram-cli/users
Cache ~/.instagram-cli/cache $XDG_CACHE_HOME/instagram-cli
Media / downloads ~/.instagram-cli/media $XDG_DATA_HOME/instagram-cli/media
Generated files ~/.instagram-cli/generated $XDG_DATA_HOME/instagram-cli/generated
Logs ~/.instagram-cli/logs $XDG_STATE_HOME/instagram-cli/logs

This could be implemented as an opt-in feature, where paths starting with xdg: (e.g., xdg:DOWNLOAD) are expanded to the appropriate XDG user dir. Default behavior remains unchanged for existing users.

Describe alternatives you've considered

  • Leaving the current ~/.instagram-cli layout as-is (status quo).
  • Using symlinks to map XDG directories manually. Works but is user-side and not integrated into the CLI.
  • Hardcoding XDG paths in the CLI, but this could break existing setups and is less flexible.

Additional context
A possible implementation could include:

if (filePath.startsWith('xdg:')) {
    const key = filePath.slice(4).toUpperCase();
    const dir = getXdgUserDir(key); // calls `xdg-user-dir` or parses ~/.config/user-dirs.dirs
    if (!dir) throw new Error(`Unknown XDG user dir: ${key}`);
    return dir;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions