Live data from Hacker News

Dotfile madness (2019)

0x46.net

171–180 of 185 posts

Re: Dotfile madness (2019)

#171

Earlier quoted context omitted.

Hidden files on MacOS were used sparingly—the main instance of a hidden file is the file which stores an icon for a folder, if the folder has a custom icon. Hidden files are only hidden from the UI, they appear normally in the command line. The standard Unix folders (usr, var, etc) are also hidden—to be honest, this is a compromise because the Unix filesystem hierarchy sucks, but we are saddled with it for backwards…

For people out there on macOS, you can press Cmd-Shift-dot in Finder to toggle displaying any hidden files (including the standard UNIX hierarchy at /). By the way, I'm pondering setting my XDG_*_HOME vars on Linux/BSD to use the macOS paths like ~/Library, just to see if the standard is actually being followed.

I did a similar thing. I set XDG_CONFIG_DIR=~/ (normally ~/.config/). It works surprisingly well, though I encountered some edge cases that eventually made me give up. Also some programs don't know about XDG_CONFIG_DIR and just hardcode ~/.config/, but you can symlink ~/.config/ -> ~/.

Re: Dotfile madness (2019)

#172
post #94

Earlier quoted context omitted.

>What's the point of hiding some of the files in a directory from user? It only makes things more confusing. If a user doesn't know what .ssh/ or .bash_history are, and it can hurt them to accidentally delete or modify them, why show them by default? It's like training wheels on a bike. >For example the folder might look empty but in fact it could contain thousands of hidden files. You want to delete it as it is empt…

> If a user doesn't know what .ssh/ or .bash_history are, and it can hurt them to accidentally delete or modify them, why show them by default? It's like training wheels on a bike. This is really the problem with the home directory. It’s supposed to be the place where the user puts their files, but it’s also a place where applications put their files, usually without asking the user. The battle is lost - the home dir…

Yes! I did that long ago, putting my stuff in /home/kept/. I'm surprised at everyone who still puts their files in ~. What a mess.

Re: Dotfile madness (2019)

#173

Earlier quoted context omitted.

It's just a different variable: USERPROFILE. https://stackoverflow.com/a/42700844/512904 > being Linux but mangling it so it technically works on other platforms Sounds like the easiest way to solve this problem. I don't blame or shame developers for choosing it. This is simple and works everywhere: char * home = getenv("USERPROFILE"); if (home) { // Use home directory } The answer demonstrating the Windows API way h…

The former does not in fact work everywhere, it only works on Windows. Once you have your #ifdef, there is absolutely no point in having the wrong Windows-specific code instead of the right Windows-specific code. Also, look at what you're describing as weird bullshit: a function call with an enum, instead of a function call with a string. The only difference is that you haven't bothered to familiarize yourself with t…

> The former does not in fact work everywhere, it only works on Windows.

It's just some example code. Real code will probably try a number of variables.

> Calling getenv("APPDATA") is a perfectly fine way of fetching FOLDERID_RoamingAppData

Okay then. Top level post said you needed a Win32 function for this. If you can do that without those functions, I suppose it's easy enough to support.

> calling getpwuid if $HOME was undefined

$HOME is set by login and ssh to whatever is in the passwd database. Can it ever be undefined? Seems like something is seriously wrong if it is.

Re: Dotfile madness (2019)

#174

> a Desktop directory. That last one has been created by Steam, which is quite unfortunate as I simply do not have a desktop or a desktop environment on my machine. Chrome and a number of other software insists on creating some of these directories (e.g. Downloads) too. However you can fix that by setting XDG_DESKTOP_DIR and XDG_DOWNLOAD_DIR in ${XDG_CONFIG_HOME}/user-dirs.dir to something else (e.g. your home direct…

I have tried everything under the sun, including user-dirs.dir: % cat ~/.config/user-dirs.dirs XDG_DESKTOP_DIR="$HOME" XDG_DOWNLOAD_DIR="$HOME" Yet still: % ls -ld ~/Desktop drwxr-xr-x 2 mt mt 4096 Oct 22 18:04 /home/mt/Desktop/ Sometimes there's a ~/Downloads directory too. But not today. I have no idea what keeps creating these. It's pretty annoying as I have a lot of intentionally short-named things in my ~ for ea…

try

    systemctl enable --now xdg-user-dirs-update.service
and just to be safe I have a snippet that parses that file and exports the variables in my login shell like .profile

(fish in this example but would be similar for other shells)

    sed -nE 's/^([^=#]+)=(.*)/set -gx \1 \2/gp' 

Re: Dotfile madness (2019)

#175
The Windows equivalent madness is all the virtual folders for Documents, Downloads etc. that show in explorer without the full path (so no copy/pasting that path for you sir!), and may be mapped to some other place and suchlike. OneDrive takes over in a way that I always uninstall it and forgo the 1Tb of storage they give me for free with O365!

As well as some stuff dumped in the home directory too. The defense on both Windows and Linux is to just keep your own documents elsewhere, or at least in a subfolder of the home directory.

Re: Dotfile madness (2019)

#176

Earlier quoted context omitted.

strongly disagree - as of 2022, more apps follow the XDG Base Directory Specification than not - in fact, by a wide margin. So by "doing dirty" in your users home directory, you're going against the grain of the ecosystem. It doesn't seem like you understand much about the specification? I'd recommend reading it, or at least a short summary I've made available here: https://xdgbasedirectoryspecification.com/

"Everybody else does it" is not an argument.

If you read the parent comment, then you would know that I'm correcting the claim that not using XDG Base Dir Spec is the de-facto standard. It's not, so I'm simply stating that

Re: Dotfile madness (2019)

#177
post #162
post #5

> You will most likely want to create a default configuration file with sane and sensible default values the first time your program is executed. Please don't. Include the example configuration in your docs (/usr/share/PROG..) and mention it in the manual. Statistically user will have hundreds of apps installed but will only ever customize a small fraction them. So creating config unconditionally on first run is one…

I don't see much of a problem with them being initialized in $XDG_CONFIG_HOME/

You upgrade the software and it no longer works right. No one else reports the same issue. Turns out the version you tun for the very first time wrote a config in a location you never looked, and that config is incompatible with latest version.

Re: Dotfile madness (2019)

#178
post #48

Earlier quoted context omitted.

strongly disagree - as of 2022, more apps follow the XDG Base Directory Specification than not - in fact, by a wide margin. So by "doing dirty" in your users home directory, you're going against the grain of the ecosystem. It doesn't seem like you understand much about the specification? I'd recommend reading it, or at least a short summary I've made available here: https://xdgbasedirectoryspecification.com/

My home directory has dotfiles for aspell, bash, bzr, cargo, Clojure, CPAN, CVS, Darcs, D-BUS, Dillo, DOSBox, DOSEmu, Emacs, Eclipse, Emacs, ESD, FLTK, fontconfig, FontForge, GForth, GHC, the GIMP, Git, GnuPG, Gnuplot, Guix, IceWM, Idle, Java, John the Ripper, Jython, Links2, MilkyTracker, Mozilla (Firefox), MPlayer, Nethack, Octave, Racket, R, Skeinforge, Slic3r, SSH, SQLite, Subversion, Units, Vim, W3M, WINE, X-Win…

Yeah I sympathize with you - my goal is for the Linux community to use a system - that is, a well-defined one, not one born arbitrarily out of the (`if (name[0] == ".") file_hidden = true;` code that has since metastasized into an ungodly manifestation of chaos itself. And that good system is the XDG Base Directory Specification. I'm sure as you know, Unix systems in general have a bad history of ad-hoc protocols and conventions, and in the process of correcting for those, somethings going to be disrupted. I've done my part to ensure that a config location that exists will continue to be looked at, but as you mention, it's confusing and increases complexity. I'm sorry, but that is what I'm willing to risk to fix this particular underlying issue.

Re: Dotfile madness (2019)

#179

Earlier quoted context omitted.

> Nobody should go out of their way to integrate with Windows APIs int writeConfigFile(ConfigFile file) { #if defined(_WIN32) // Windows-specific function #elif defined(__linux__) // Linux-specific function #elif defined(__APPLE__) // macOS-specific function With modern C++, there's probably a way to do this in a nicer manner, and achieve runtime polymorphism with virtual functions or a lambda (function pointer) tabl…

No need for runtime polymorphism for this. The same binary won't be used in different operating systems. This is a classic example of misuse of C++ features just because they exist and a reason why I personally prefer programming in C. What I would do in a case like this is to have three source files each implementing the function for UNIX/Windows/Mac and the build system should take care of compiling the right one i…

This is a much better idea, actually. You're right that what I mentioned is a bad misuse of C++ features.

I initially did think of simply letting the build system handle it (CMake can do this excellently, as can Meson, probably) by simply choosing different source files for different target OSs, but when typing out the parent comment, I forgot about it in my train of thought.

Come to think of it, this is far more elegant.

Re: Dotfile madness (2019)

#180

> a Desktop directory. That last one has been created by Steam, which is quite unfortunate as I simply do not have a desktop or a desktop environment on my machine. Chrome and a number of other software insists on creating some of these directories (e.g. Downloads) too. However you can fix that by setting XDG_DESKTOP_DIR and XDG_DOWNLOAD_DIR in ${XDG_CONFIG_HOME}/user-dirs.dir to something else (e.g. your home direct…

I have tried everything under the sun, including user-dirs.dir: % cat ~/.config/user-dirs.dirs XDG_DESKTOP_DIR="$HOME" XDG_DOWNLOAD_DIR="$HOME" Yet still: % ls -ld ~/Desktop drwxr-xr-x 2 mt mt 4096 Oct 22 18:04 /home/mt/Desktop/ Sometimes there's a ~/Downloads directory too. But not today. I have no idea what keeps creating these. It's pretty annoying as I have a lot of intentionally short-named things in my ~ for ea…

Try to set enabled=False in ~/.config/user-dirs.conf

https://www.unix.com/man-page/centos/5/user-dirs.conf/

Post reply on HN