SHGetKnownFolderPath equivalent API in Linux

后端 未结 2 1922
耶瑟儿~
耶瑟儿~ 2021-01-16 10:08

I\'m porting some functionality from windows to linux and I\'m finding it harder to match the functionality of SHGetKnownFolderPath in linux. Actually there is an API in gli

2条回答
  •  失恋的感觉
    2021-01-16 10:19

    The status of the Linux desktop is a sad mess, especially for this kind of stuff. There are some FreeDesktop standards, but nothing close to Windows Shell APIs for both consistency and commitment to backwards compatibility.

    That being said, in my experience the safest thing to do is relying on utilities from XDG, in particular xdg-user-dir in your case (xdg utils can come in handy in other cases); nowadays they are almost universally installed, and they usually do the "right" thing. Also, many packages rely on them, so it's likely that any DE tests the integration at least on them (IOW: if someone writes configuration that breaks even xdg utils it's likely that they'll fix it; if it's out of spec garbage that happens to work with xdg utils they may not notice).

    Please don't try to be too clever with this kind of stuff. Firefox tries to be clever with file associations on Linux and it's 10 years that clicking "open folder" in it opens random applications (for the record, on my box it's extremely fond of opening Gwenview; in the past it liked more FileLight).

提交回复
热议问题