using xdg config instead of hardcoded location for config stuff

This commit is contained in:
benton 2021-08-16 15:20:20 -05:00
parent adca02ef27
commit cf007616b7
2 changed files with 9 additions and 3 deletions

View file

@ -16,13 +16,18 @@
in { in {
defaultPackage.x86_64-linux = nixpkgs.stdenv.mkDerivation { defaultPackage.x86_64-linux = nixpkgs.stdenv.mkDerivation {
pname = "knock"; pname = "knock";
version = "0.1.0-alpha"; version = "1.0.0-alpha";
src = self; src = self;
nativeBuildInputs = [ nixpkgs.makeWrapper ]; nativeBuildInputs = [ nixpkgs.makeWrapper ];
buildInputs = [ buildInputs = [
(nixpkgs.python3.withPackages(python3Packages: [ python3Packages.python_magic ])) (nixpkgs.python3.withPackages
(python3Packages: [
python3Packages.python_magic
python3Packages.xdg
])
)
libgourou-utils inept-epub libgourou-utils inept-epub
]; ];

3
knock
View file

@ -3,6 +3,7 @@
import os, sys, argparse, subprocess, magic, shutil import os, sys, argparse, subprocess, magic, shutil
from pathlib import Path from pathlib import Path
from getpass import getpass 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 = 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') 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.acsm_file = Path(args.acsm_file).expanduser().resolve()
args.drm_file = args.acsm_file.with_suffix('.drm') args.drm_file = args.acsm_file.with_suffix('.drm')
args.epub_file = args.acsm_file.with_suffix('.epub') 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(): if not args.acsm_file.exists():
sys.exit(f'ERROR: {str(args.acsm_file)} does not exist.') sys.exit(f'ERROR: {str(args.acsm_file)} does not exist.')