-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
XDG directory spec #864
XDG directory spec #864
Conversation
Search $XDG_CONFIG_HOME and $XDG_CONFIG_DIRS for config files. This also negates the need to have separate user and global variants of mp_find_config_file()
Upon trying this branch,the watch later thing (shift+q) stopped working. There was a memory leak. The code for --config-dir (force_configdir) and "$MPV_HOME" was removed. As you say, it breaks Windows and Mac support. Also, ideally there should be some sort of migration between old and new config dirs. So I guess there's some work to do.
Well, the code is there. There's also osdep/path-win.c and osdep/path-osx.m. One weird thing about Windows is that it supports two config locations, the official Microsoft one, and in the .exe dir. OSX supports both the UNIX convention and the "Bundle" stuff (which I don't quite understand myself). |
Unfortunately, I have no way to test the Windows or Mac fixes, so I'd like to request some help with that. Still need to fix watch_later, memory leaks come last. Anything else I'm forgetting? |
Not sure. By the way, I think the main reasons why "user" and "system" config dirs were separate are:
|
It boils down to implementing a list of config directories. The first directory in the list becomes the user writable directory. Incremental config files (I don't recommend this, it overcomplicates things) just need to be loaded in reverse order that they're found I'm not sure why you'd look up 10000 config files at once, just check it when the video loads instead of when the playlist loads |
Sounds more complicated than separate functions for "user"/"system" config files, but maybe this is the right approach. It could also be helpful for implementing cascading config files and for simplifying config file handling on MS Windows.
This is for resuming playlists, i.e. for finding the first file on the playlist that should be resumed. It's pretty nice when playing all files in a directory with |
I guess you still want cascading config files after all. Anyway, couple of small things I'd like to ask:
|
I'm just saying that's a possible implementation. Or you can switch back to using separate functions for user/system config files.
Users were complaining they can't refer to other config-file-like paths using
Valgrind, or for the talloc functions |
Okay, that should be everything. For backwards compatibility, I kept ~/.mpv as a search directory, and /config (as opposed to /mpv.conf) as a valid config file name, you may or may not want to remove them someday in the future. Also, could someone check if the search dirs on Windows and Mac are correct? It's part of verbose output, so just building and running MPV_VERBOSE=1 /path/to/mpv will do. |
Someone tested it on OSX and reported that it appeared to work (including bundle), but nobody did on win32 yet. So screw Windows and leave fixing it for later (probably even after merge), but first I'll review the patch in its current state. |
|
||
|
||
|
||
static char *mp_append_all(void* talloc_ctx, const char *_dirs, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please no identifiers that start with _
. Although in this case it's still legal, some other uses of leading underscores are not allowed, because the C standard reserves them for the standard library. (See section 7.1.3 in the C11 standard.)
I tried building this on Windows and there are two issues:
Apart from that, it looks good on Windows, though I agree with what @wm4 is saying about the |
@knthzh: looks generally good to me, but apparently the ms windows specific handling still needs improvement. |
You sure about exe_dir/mpv? Well, if you say so. Just checking, should app_dir or exe_dir have priority? |
It would match the old behaviour. The official builds come with a custom fonts.conf in this directory.
I think exe_dir should, since it would let different versions of mpv run on the same machine with different configs. That's how it currently works, I think. |
Just tested 0c6dd72 and it looks good. |
Note that if you have |
Sorry, that huge ifdef (even with a nested ifdef) is a bit ugly. |
|
||
talloc_free(res); | ||
res = NULL; | ||
if (!*dir) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And especially here, !dir[0]
would be more readable.
Done. foo/mpv/config had priority
XDG_CONFIG_DIRS is meant for overriding that. As an example, maybe a developer wants to test a clean config without mpv defaulting to the ones installed with it.
Just keep it, it's not like it's hard to implement. |
What if it's set to something useless by default instead? Did you check what Gnome/KDE/xfce do? |
It's the distro's responsibility to organize downstream configuration changes
All DEs I know of leave it unset by default |
OK then. Reducing the ifdef ugliness would still be nice, though. |
I'm not convinced this looks any better, especially since ifdefs read like regular ifs to me. I almost certainly broke Windows support again, though, so that needs another round of checking. |
Windows build looks good. |
Well then, I'll probably merge it now. |
OK, on testing, I determined it doesn't properly take the union of all config dirs. Let mpv1 be mpv compiled without this patch, and mpv2 compiled with this patch. Then if you do:
So that means as soon as you quit mpv2 with quit_watch_later, all previously suspended files suddenly won't resume anymore. The underlying reason is that quit_watch_later creates The same problem exists with the lua config subdirectory. According to XDG, it should load all lua scripts in all lua subdirectories in all config paths, but in fact it will load only the one with the highest priority. |
Done |
cb250d4
Pushed it. I made a bunch of heavy modifications on top of it. I hope this is not considered offensive; some issues I thought better were doing myself (instead of keeping demanding new changes etc.), and some things I noticed only later. Maybe I'm a bit too pedantic and I didn't want to keep making new demands. In any case, you're a great contributor. Anyway, apart from this, there's still a problem: now it will always write new config files (watch later configs at least) to the directory containing the .exe (instead of the app dir), because that directory always exists and is highest on the priority list. I assume this will annoy windows users? |
Of course not, it's your project, lol.
I'm just following what @rossy2401 said. It doesn't really make sense to dump files all over the place (I know I'd get pissed from having to track multiple locations). Deciding which directory to consolidate all the files to... Well, I'll leave that to you guys. It's just a two line change in osdep/path-win.c |
Yeah, one could for example prefer the app dir over the exe dir. But then the app dir would always be created, and maybe someone doesn't like it. I'm not sure what's the best behavior, so I'll leave it to the windows guys. |
I think the problem is that different Windows users want different things. Some people understandably want config files to be stored in the proper location, which is why #458 was created. These people could be storing mpv.exe in a read-only directory (like C:\Program Files) so it would be a bad idea to create new files in the exe directory in this case. Other people (myself included) like portable apps, which are completely self-contained and can be stored on flash drives or network drives. There is a portable version of SMPlayer and I'm fairly sure Baka MPlayer is portable. For these apps it's the opposite. They should write everything to their directory and leave nothing on the host machine. I'm not sure how to please both groups of users. Perhaps the AppData directory could be preferred for the sake of the first group of users, and the second group could set |
Fix for #109
This is a full implementation that uses $XDG_CONFIG_HOME and $XDG_CONFIG_DIRS.
The rationale is that since CONFIG_HOME corresponds to /etc and DATA_HOME corresponds to /usr/share, everything should go in CONFIG_HOME.
This currently breaks support on Windows and Mac, so I'd like some pointers on what the config directories on those platforms are.