From cf007616b7a8c9a3563bdfd6c7a87f46de10f27d Mon Sep 17 00:00:00 2001 From: benton Date: Mon, 16 Aug 2021 15:20:20 -0500 Subject: [PATCH] using xdg config instead of hardcoded location for config stuff --- flake.nix | 9 +++++++-- knock | 3 ++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/flake.nix b/flake.nix index 6fff0a0..fe432c6 100644 --- a/flake.nix +++ b/flake.nix @@ -16,13 +16,18 @@ in { defaultPackage.x86_64-linux = nixpkgs.stdenv.mkDerivation { pname = "knock"; - version = "0.1.0-alpha"; + version = "1.0.0-alpha"; src = self; nativeBuildInputs = [ nixpkgs.makeWrapper ]; buildInputs = [ - (nixpkgs.python3.withPackages(python3Packages: [ python3Packages.python_magic ])) + (nixpkgs.python3.withPackages + (python3Packages: [ + python3Packages.python_magic + python3Packages.xdg + ]) + ) libgourou-utils inept-epub ]; diff --git a/knock b/knock index a54d07f..f037704 100644 --- a/knock +++ b/knock @@ -3,6 +3,7 @@ import os, sys, argparse, subprocess, magic, shutil from pathlib import Path from getpass import getpass +from xdg import xdg_config_home parser = argparse.ArgumentParser(prog='knock', description='Convert an ACSM file to a DRM-free EPUB file') parser.add_argument('acsm_file', metavar='file', type=str, help='the ACSM file to convert') @@ -12,7 +13,7 @@ args = parser.parse_args() args.acsm_file = Path(args.acsm_file).expanduser().resolve() args.drm_file = args.acsm_file.with_suffix('.drm') args.epub_file = args.acsm_file.with_suffix('.epub') -args.adobe_dir = Path('~/.config/knock').expanduser() +args.adobe_dir = xdg_config_home() / 'knock' if not args.acsm_file.exists(): sys.exit(f'ERROR: {str(args.acsm_file)} does not exist.')