From a9d750a5faf995e55fb6c68bede1b8f4712a0361 Mon Sep 17 00:00:00 2001 From: Johan Viirok Date: Fri, 28 Aug 2020 09:38:22 +0300 Subject: [PATCH 1/2] Fix user home path for macos --- liquidctl/keyval.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/liquidctl/keyval.py b/liquidctl/keyval.py index a1e71bf67..8c2d787be 100644 --- a/liquidctl/keyval.py +++ b/liquidctl/keyval.py @@ -23,7 +23,7 @@ def get_runtime_dirs(appname='liquidctl'): if sys.platform == 'win32': dirs = [os.path.join(os.getenv('TEMP'), appname)] elif sys.platform == 'darwin': - dirs = [os.path.join('~/Library/Caches', appname)] + dirs = [os.path.expanduser(os.path.join('~/Library/Caches', appname))] elif sys.platform == 'linux': # threat all other platforms as *nix and conform to XDG basedir spec dirs = [] From e440c47705cd33e96bf151d266e32da98dcc47eb Mon Sep 17 00:00:00 2001 From: Johan Viirok Date: Fri, 28 Aug 2020 13:04:45 +0300 Subject: [PATCH 2/2] Set the sticky bit always on linux and never when not on linux --- liquidctl/keyval.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/liquidctl/keyval.py b/liquidctl/keyval.py index 8c2d787be..10289220e 100644 --- a/liquidctl/keyval.py +++ b/liquidctl/keyval.py @@ -56,12 +56,10 @@ def __init__(self, key_prefixes): self._read_dirs = [os.path.join(x, *key_prefixes) for x in get_runtime_dirs()] self._write_dir = self._read_dirs[0] os.makedirs(self._write_dir, exist_ok=True) - if XDG_RUNTIME_DIR and os.path.commonpath([XDG_RUNTIME_DIR, self._write_dir]): + if sys.platform == 'linux': # set the sticky bit to prevent removal during cleanup os.chmod(self._write_dir, 0o1700) - LOGGER.debug('data in %s (within XDG_RUNTIME_DIR)', self._write_dir) - else: - LOGGER.debug('data in %s', self._write_dir) + LOGGER.debug('data in %s', self._write_dir) def load(self, key): for base in self._read_dirs: