Skip to content

feat(linux): update font path to XDG spec and refresh cache#41

Merged
tinsever merged 2 commits intomasterfrom
feat/linux-font-folder
Jan 1, 2026
Merged

feat(linux): update font path to XDG spec and refresh cache#41
tinsever merged 2 commits intomasterfrom
feat/linux-font-folder

Conversation

@tinsever
Copy link
Owner

@tinsever tinsever commented Jan 1, 2026

  • Use ~/.local/share/fonts (or /fonts) for Linux installs.
  • Execute fc-cache -f post-install to update the system font list.

Greptile Summary

This PR modernizes Linux font installation by adopting the XDG Base Directory specification and adding automatic font cache refresh functionality.

Key Changes:

  • Migrated Linux font installation path from ~/.fonts/ to XDG-compliant ~/.local/share/fonts (respects $XDG_DATA_HOME environment variable)
  • Added fc-cache -f execution after font installation to automatically refresh the system font cache
  • Error handling for fc-cache is graceful - if the command fails or isn't available, the font is still successfully saved

Documentation Gaps:

  • README.md still references the old ~/.fonts path in multiple locations (lines 56, 187, 364)
  • CI workflow still creates the old ~/.fonts directory instead of the new XDG path

The implementation itself is solid with proper error handling, but supporting documentation and CI configuration need updates to maintain consistency.

Confidence Score: 4/5

  • This PR is safe to merge with minor documentation inconsistencies
  • The code changes are well-implemented with proper XDG spec compliance and graceful error handling for fc-cache. However, documentation (README.md) and CI configuration reference outdated paths, creating inconsistency between code and docs. The functional changes are sound and backward-compatible since XDG_DATA_HOME can be customized.
  • No files require special attention - the implementation is solid

Important Files Changed

Filename Overview
lib/system-font.js Updates Linux font installation to use XDG spec path and adds fc-cache refresh; implementation is solid but README needs updating

Sequence Diagram

sequenceDiagram
    participant User
    participant SystemFont
    participant FileSystem
    participant OS
    participant fcCache as fc-cache

    User->>SystemFont: install(remoteFile, fileName)
    
    alt Platform: Linux
        SystemFont->>OS: Get XDG_DATA_HOME env
        alt XDG_DATA_HOME exists
            OS-->>SystemFont: $XDG_DATA_HOME value
        else XDG_DATA_HOME not set
            SystemFont->>OS: os.homedir()
            OS-->>SystemFont: ~/.local/share (default)
        end
        
        SystemFont->>SystemFont: linuxDestFolder = xdgDataHome/fonts
        SystemFont->>SystemFont: saveAt(remoteFile, linuxDestFolder, fileName)
        SystemFont->>FileSystem: Download and save font
        FileSystem-->>SystemFont: Font saved successfully
        
        SystemFont->>fcCache: exec('fc-cache -f')
        alt fc-cache succeeds
            fcCache-->>SystemFont: Cache refreshed
        else fc-cache fails
            fcCache-->>SystemFont: Error (silently caught)
            Note over SystemFont: Font already saved, continue
        end
        
        SystemFont-->>User: Font path
    else Platform: Darwin/Windows
        Note over SystemFont: Use platform-specific paths
    end
Loading

- Use ~/.local/share/fonts (or /fonts) for Linux installs.
- Execute fc-cache -f post-install to update the system font list.
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional Comments (1)

  1. lib/system-font.js, line 36 (link)

    style: CI workflow .github/workflows/ci.yml:36 creates ~/.fonts but should create ~/.local/share/fonts to match new XDG path

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

1 file reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Comment on lines +166 to +167
const xdgDataHome = process.env.XDG_DATA_HOME || path.join(os.homedir(), '.local', 'share');
const linuxDestFolder = path.join(xdgDataHome, 'fonts');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: README.md still references old ~/.fonts path (lines 56, 187, 364). Update docs to reflect new XDG path ~/.local/share/fonts

Prompt To Fix With AI
This is a comment left during a code review.
Path: lib/system-font.js
Line: 166:167

Comment:
**style:** README.md still references old `~/.fonts` path (lines 56, 187, 364). Update docs to reflect new XDG path `~/.local/share/fonts`

How can I resolve this? If you propose a fix, please make it concise.

@tinsever tinsever merged commit de354b4 into master Jan 1, 2026
2 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant