I am making a GUI app that is essentially a hyper-specialized file editor/manager (GUI app to edit and manage files within ~/.config/scopebuddy) for the scopebuddy program. When trying to make a symlink to ~/.config/scopebuddy/AppID, it actually makes a symlink to ~/.var/app/io.github.rfrench3.scopebuddy-gui/config/scopebuddy/AppID. While this works fine for the GUI it would not be great to make scopebuddy handle that, so how can I make a normal symlink? (I have create access to xdg-config/scopebuddy)
I don’t understand how you’re doing your symlink & why it would point to the wrong location. Maybe provide an example.
I figured it out, I needed to use a relative path for the symlink and not an absolute path. Here’s what I did before and what I switched to doing:
def create_directory() -> None:
"""Create the directory for /scopebuddy/AppID, and a symlink from AppID/steam back to AppID."""
APPID_DIR = os.path.join(os.environ.get("XDG_CONFIG_HOME", os.path.expanduser("~/.config")), "scopebuddy", "AppID")
os.makedirs(APPID_DIR, exist_ok=True)
steam_symlink = os.path.join(APPID_DIR, "steam")
if not os.path.exists(steam_symlink):
# did not work
os.symlink(APPID_DIR, steam_symlink, target_is_directory=True)
# does work
os.symlink(".", steam_symlink, target_is_directory=True)
Inside the sandbox, XDG_CONFIG_HOME is always set to ~/.var/app/<app_id>/config.
Use HOST_XDG_CONFIG_HOME if you need the actual user set value.