Wish File.DirData should return ~/.config/ or ~/.local/share/ instead of File.DirApp on Linux

max123

Well-Known Member
Licensed User
Longtime User
Gemini explained me this. File.DirData should return ~/.config/ or ~/.local/share/ instead of File.DirApp on Linux machines.
File.DirTemp should return ~/.cache/ I think.

The primary Linux counterpart to Windows AppData/Roaming is
~/.config (XDG_CONFIG_HOME) for configuration files and
~/.local/share (XDG_DATA_HOME) for application data files.
Both are located within the user's home directory ($HOME), making them always readable and writable by that user.

Here is the breakdown of the Linux equivalents for application data.

1. The Standard Counterparts (XDG Specification)

Modern Linux applications follow the XDG Base Directory Specification, which splits the functionality of Windows AppData into specialized folders to reduce clutter in the home directory:
  • ~/.config/ (default for $XDG_CONFIG_HOME): Equivalent to AppData\Roaming for user-specific settings, configuration files, and keybindings.
  • ~/.local/share/ (default for $XDG_DATA_HOME): Equivalent to AppData\Local or Roaming for application-specific data files that should persist but are not user-modifiable settings (e.g., game saves, application databases).
  • ~/.cache/ (default for $XDG_CACHE_HOME): For temporary data that can be deleted without losing important application state
2. Traditional/Alternative Approach
  • ~/.appname: Many older or simpler applications place a single hidden directory directly in the user's home directory (e.g., ~/.mozilla, ~/.ssh).
Unlike Windows, Linux does not inherently distinguish between "roaming" (networked) and "local" (machine-specific) app data by default. Everything in ~/.config or ~/.local/share is generally considered part of the user's profile and will move with them if their home directory is on a network share.

Windows FolderLinux CounterpartPurpose
%APPDATA%~/.config/User settings, config files.
%LOCALAPPDATA%~/.local/share/App data, database files, saves.
(Various)~/.cache/Cache, temporary data.

If you are developing or running apps on Linux, ~/.config/ is the recommended location for persistent user settings.

B4X:
    ' Set here the path where THREEJS distribution was unzipped.
    ' More concurrent projects can run at same time, just use different port for each if you need this.
'    gl.Initialize(Me, "WebGL", "WebGL_Demo1", "GMT+1", File.DirData("B4XWebGL"), Port) ' WINDOWS SPECIFIC
'    gl.Initialize(Me, "WebGL", "WebGL__Demo1", "GMT+1", "/home/massimo/.config/B4XWebGL/", Port) ' LINUX SPECIFIC
     gl.Initialize(Me, "WebGL", "WebGL__Demo1", "GMT+1", File.Combine(GetSystemProperty("user.home", ""), ".config/B4XWebGL/"), Port) ' LINUX SPECIFIC

Using this last uncommented command with my WebGL library on a Linux Debian 13 virtual machine works well inside /.config/ folder, because it is in home, is perfectly readable and writable.

I'm interested to know.... what you think about this ?

Here a small test:
 
Last edited:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…