You are viewing a single thread.
View all comments
132 points
*

but please donโ€™t hard-code ~/.config or $HOME/.config. Use the XDG_CONFIG_HOME environment variable, with $HOME/.config as a fallback if itโ€™s not set.

Many programming languages have a cross-platform implementation of this built in to their standard library. C# has Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) which uses XDG_CONFIG_HOME on Linux, local AppData on Windows, and whatever is the correct thing on MacOS (not very familiar with how things work on MacOS)

permalink
report
reply
10 points

On macOS, the correct thing to use is usually NSUserDefaults API, or - [NSFileManager URLsForDirectory:inDomains:] with NSApplicationSupportDirectory (gives a list of paths to find your config file in, like XDG_CONFIG_DIRS)

permalink
report
parent
reply
7 points

Never new about this! Thatโ€™s very handy

permalink
report
parent
reply
1 point

In Python the equivalent library is platformdirs

permalink
report
parent
reply

linuxmemes

!linuxmemes@lemmy.world

Create post

Hint: :q!


Sister communities:

Community rules (click to expand)

1. Follow the site-wide rules
2. Be civil
  • Understand the difference between a joke and an insult.
  • Do not harrass or attack users for any reason. This includes using blanket terms, like โ€œevery user of thingโ€.
  • Donโ€™t get baited into back-and-forth insults. We are not animals.
  • Leave remarks of โ€œpeasantryโ€ to the PCMR community. If you dislike an OS/service/application, attack the thing you dislike, not the individuals who use it. Some people may not have a choice.
  • Bigotry will not be tolerated.
  • These rules are somewhat loosened when the subject is a public figure. Still, do not attack their person or incite harrassment.
3. Post Linux-related content
  • Including Unix and BSD.
  • Non-Linux content is acceptable as long as it makes a reference to Linux. For example, the poorly made mockery of sudo in Windows.
  • No porn. Even if you watch it on a Linux machine.
4. No recent reposts
  • Everybody uses Arch btw, canโ€™t quit Vim, <loves/tolerates/hates> systemd, and wants to interject for a moment. You can stop now.
5. ๐Ÿ‡ฌ๐Ÿ‡ง Language/ัะทั‹ะบ/Sprache
  • This is primarily an English-speaking community. ๐Ÿ‡ฌ๐Ÿ‡ง๐Ÿ‡ฆ๐Ÿ‡บ๐Ÿ‡บ๐Ÿ‡ธ
  • Comments written in other languages are allowed.
  • The substance of a post should be comprehensible for people who only speak English.
  • Titles and post bodies written in other languages will be allowed, but only as long as the above rule is observed.

ย 

Please report posts and comments that break these rules!


Important: never execute code or follow advice that you donโ€™t understand or canโ€™t verify, especially here. The word of the day is credibility. This is a meme community โ€“ even the most helpful comments might just be shitposts that can damage your system. Be aware, be smart, donโ€™t remove France.

Community stats

  • 7.2K

    Monthly active users

  • 1.4K

    Posts

  • 77K

    Comments