Skip to content
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

Linux international desktop location #15

Open
martinohanlon opened this issue Jun 4, 2018 · 5 comments
Open

Linux international desktop location #15

martinohanlon opened this issue Jun 4, 2018 · 5 comments

Comments

@martinohanlon
Copy link
Owner

call xdg-user-dir if possible to return the desktop location

    def _get_desktop_folder(self):
        import subprocess
        try:
            return subprocess.check_output(['xdg-user-dir',
                                            'DESKTOP']).decode('utf-8').strip()
        except subprocess.CalledProcessError:
            return os.path.join(os.path.join(os.path.expanduser('~')), 'Desktop')

Based on requests in #7 from @kiwi0fruit

@martinohanlon
Copy link
Owner Author

See https://github.com/jleclanche/python-xdg/blob/master/xdg/basedir.py for a potential solution for getting xdg environment data without having to use subprocess.

@kiwi0fruit
Copy link

@martinohanlon I guess this doesn't affect fallback behavior: if xdg-user-dir is installed then env vars are set and vice versa (if we are ever to encouter fallback behaviour). So this gives the same result.

@martinohanlon
Copy link
Owner Author

This code pulls back the xdg desktop directory

import os
os.environ.get("XDG_DESKTOP_DIR", os.path.join(os.path.expanduser("~"), "Desktop"))

Tested on ubuntu, raspbian, nix.

Interestingly this works on nix, but the xdg-user-dir isnt installed.

@kiwi0fruit
Copy link

@martinohanlon echo ${XDG_DESKTOP_DIR} gives me empty string in bash on Ubuntu.

@kiwi0fruit
Copy link

@martinohanlon I guess your code always uses default value so it works on nix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants