From ba5680253d204cb40e841d35e2b5f459b50a2901 Mon Sep 17 00:00:00 2001 From: Flinner Yuu Date: Wed, 27 Sep 2023 00:31:04 +0300 Subject: [PATCH] feat: fix isbn -> bibtex --- bin/bin/isbn_to_bibtex.py | 7 +++++-- bin/bin/rofi_bin_launcher.py | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/bin/bin/isbn_to_bibtex.py b/bin/bin/isbn_to_bibtex.py index 92004df..6f77cbe 100755 --- a/bin/bin/isbn_to_bibtex.py +++ b/bin/bin/isbn_to_bibtex.py @@ -9,7 +9,9 @@ import fileinput # 2: Network error def eprint(*args, **kwargs): + # uncomment to enable debug... #print(*args, file=sys.stderr, **kwargs) + pass #isbn can be a csv list def convert_isbn_to_bibtex(isbn): @@ -30,8 +32,8 @@ def convert_isbn_to_bibtex(isbn): isbn = None -if not sys.stdin.isatty() : - stdin_ = list(fileinput.input().splitlines()) +if not sys.stdin.isatty() and fileinput.input(): + stdin_ = list(fileinput.input()) isbn = ",".join(stdin_) print("isbn from stdin:", isbn) @@ -51,3 +53,4 @@ if bibtex: else: print("Failed to convert ISBN to BibTeX") sys.exit(2) +sys.exit(0) diff --git a/bin/bin/rofi_bin_launcher.py b/bin/bin/rofi_bin_launcher.py index eddf209..ad2b384 100755 --- a/bin/bin/rofi_bin_launcher.py +++ b/bin/bin/rofi_bin_launcher.py @@ -24,7 +24,8 @@ def read_clipboard(): def write_to_clipboard(text): # Write the text to the clipboard on Linux - subprocess.run(["echo", "-n", text, "|", "xclip", "-selection", "clipboard"], shell=True) + subprocess.run(["xclip", "-selection", "clipboard"], input = text.strip().encode('utf-8'), check=True) + # bash_it("echo " + text + "|" + "xclip -sel c") # Write the text to the clipboard on macOS # subprocess.run(["echo", "-n", text, "|", "pbcopy"], shell=True)