Compare commits

...

2 commits

3 changed files with 6 additions and 23 deletions

View file

@ -44,11 +44,12 @@ let
libwebp libwebp
fontforge fontforge
packwiz packwiz
xclip
# for scripts # for scripts
python312 python312
python312Packages.requests python312Packages.requests
python312Packages.tkinter python312Packages.pyperclip
]; ];
flakePackages = with inputs; [ compose2nix.packages.${system}.default ]; flakePackages = with inputs; [ compose2nix.packages.${system}.default ];
in { in {

View file

@ -1,5 +1,5 @@
#! /usr/bin/env nix-shell #! /usr/bin/env nix-shell
#! nix-shell -i python -p python312 #! nix-shell -i python -p python312 libnotify
import argparse import argparse
import os import os

View file

@ -1,34 +1,16 @@
#! /usr/bin/env nix-shell #! /usr/bin/env nix-shell
#! nix-shell -i python -p python312 python312Packages.tkinter python312Packages.requests libnotify #! nix-shell -i python -p python312 python312Packages.pyperclip python312Packages.requests libnotify
import argparse import argparse
import mimetypes import mimetypes
import os import os
import subprocess
from pathlib import Path from pathlib import Path
from shutil import which from shutil import which
from tkinter import Tk
from typing import Any from typing import Any
import requests # type: ignore import requests # type: ignore
from common.common import does_desktop_entry_exist, notify, read_secret_file from common.common import does_desktop_entry_exist, notify, read_secret_file
from pyperclip import copy
def copy_to_clipboard(text: str) -> None:
if which("xclip"):
subprocess.run(
["xclip", "-selection", "clipboard", "-t", "text/plain", "-i"],
input=text.encode(),
)
elif which("wl-copy"):
subprocess.run(["wl-copy", "--type", "text/plain"], input=text.encode())
else:
root = Tk()
root.withdraw()
root.clipboard_clear()
root.clipboard_append(text)
root.update()
root.destroy()
def zipline( def zipline(
@ -72,7 +54,7 @@ def zipline(
link = response_data.get("files", [None])[0] link = response_data.get("files", [None])[0]
if link: if link:
copy_to_clipboard(text=link) copy(text=link)
print(f"Link copied to clipboard: {link}") print(f"Link copied to clipboard: {link}")
if use_send_notify: if use_send_notify: