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

add check for XDG_CONFIG_HOME env var #311

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
add check for XDG_CONFIG_HOME env var
add XDG Directory Specification check
Ian C committed May 6, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 10cc9dddf90e08fbbc6e410abac79d80f26ae45a
10 changes: 8 additions & 2 deletions protonvpn_cli/constants.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import os
import getpass
import pwd

from xdg import (
xdg_config_home
)
# This implementation is mostly for GUI support. See #168
try:
USER = pwd.getpwuid(int(os.environ["PKEXEC_UID"])).pw_name
@@ -11,7 +13,11 @@
except KeyError:
USER = getpass.getuser()

CONFIG_DIR = os.path.join(os.path.expanduser("~{0}".format(USER)), ".pvpn-cli")
try:
CONFIG_DIR = os.path.join(xdg_config_home(), "pvpn-cli")
except KeyError:
CONFIG_DIR = os.path.join(os.path.expanduser("~{0}".format(USER)), ".pvpn-cli")

CONFIG_FILE = os.path.join(CONFIG_DIR, "pvpn-cli.cfg")
SERVER_INFO_FILE = os.path.join(CONFIG_DIR, "serverinfo.json")
SPLIT_TUNNEL_FILE = os.path.join(CONFIG_DIR, "split_tunnel.txt")