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

Enable use with both available python XDG modules #142

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
21 changes: 12 additions & 9 deletions jack_mixer/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,19 @@

try:
import xdg
from xdg import BaseDirectory

try:
confdir = xdg.XDG_CONFIG_HOME / "jack_mixer"
datadir = xdg.XDG_DATA_HOME / "jack_mixer"
except AttributeError:
confdir = xdg.BaseDirectory.save_config_path("jack_mixer")
datadir = xdg.BaseDirectory.save_data_path("jack_mixer")
except ImportError:
xdg = None
confdir = None
datadir = None

from .serialization import SerializedObject


log = logging.getLogger(__name__)


Expand All @@ -56,11 +62,9 @@ def __init__(self, topwindow, meter_scales, slider_scales):
self.meter_scales = meter_scales
self.slider_scales = slider_scales
self.set_default_preferences()
if xdg:
if confdir:
self.config = configparser.ConfigParser()
self.path = os.path.join(
BaseDirectory.save_config_path("jack_mixer"), "preferences.ini"
)
self.path = os.path.join(confdir, "preferences.ini")
if os.path.isfile(self.path):
self.read_preferences()
else:
Expand Down Expand Up @@ -217,8 +221,7 @@ def get_default_meter_scale(self):
def get_default_project_path(self):
if self.default_project_path:
return os.path.expanduser(self.default_project_path)
elif xdg:
return BaseDirectory.save_data_path("jack_mixer")
return datadir

def get_default_slider_scale(self):
return self.default_slider_scale
Expand Down