diff --git a/imgur b/imgur index 0b42bdd..f7ace13 100755 --- a/imgur +++ b/imgur @@ -5,20 +5,25 @@ import json import sys import os import aiohttp +import pyperclip import subprocess +icon_path = os.path.expanduser("~/.local/share/icons/hicolor/256x256/apps/imgur.png") + async def upload_image(session, image_path): async with session.post("https://api.imgur.com/3/upload", headers={"Authorization": f"Bearer {token}"}, data={"image": open(image_path, "rb")}) as response: response_json = await response.json() link = response_json["data"]["link"] - subprocess.run(["xclip", "-sel", "clip"], input=link, encoding='ascii') + # subprocess.run(["xclip", "-sel", "clip"], input=link, encoding='ascii') + pyperclip.copy(link) print(f"Uploaded {image_path}, link copied to clipboard: {link}") async def main(): async with aiohttp.ClientSession() as session: tasks = [upload_image(session, image) for image in image_paths] await asyncio.gather(*tasks) - subprocess.run(["notify-send", "imgur", "All images have been uploaded!"]) + subprocess.run(["notify-send", "All Image uploaded", "-i", icon_path]) + if __name__ == "__main__": config_file_path = os.path.expanduser("~/.config/imgur/config") diff --git a/imgur.desktop b/imgur.desktop index 1c0e617..b59a703 100644 --- a/imgur.desktop +++ b/imgur.desktop @@ -6,7 +6,7 @@ X-KDE-StartupNotify=false X-KDE-Priority=TopLevel [Desktop Action Upload2Imgur] -Exec=imgur %U +Exec=$HOME/.local/bin/imgur %U Name=Upload to imgur.com Name[nl]=Uploaden naar imgur.com -Icon=/usr/share/pixmaps/imgur.png +Icon=imgur diff --git a/install.sh b/install.sh index 8a886d0..69eb270 100755 --- a/install.sh +++ b/install.sh @@ -1,6 +1,21 @@ #!/bin/bash +# Install pyperclip +pip install --user pyperclip + +# Set the installation paths +icon_path="$HOME/.local/share/icons/hicolor/256x256/apps" + +# Create the directories if they don't exist +mkdir -p "$icon_path" + +install -m 644 imgur.png "$icon_path" + install -m 644 imgur.desktop `kf5-config --path services | cut -f1 -d':'` -sudo install -m 644 imgur.png /usr/share/pixmaps/ -sudo install -m 755 imgur /usr/bin/ +install -m 755 imgur $HOME/.local/bin/ +if ! echo "$PATH" | grep -q "$HOME/.local/bin"; then + echo 'export PATH="$PATH:$HOME/.local/bin"' >> ~/.bashrc + source ~/.bashrc +fi + diff --git a/uninstall.sh b/uninstall.sh index c6a3e7a..202bbaa 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -1,4 +1,4 @@ #!/bin/bash rm "`kf5-config --path services | cut -f1 -d':'`imgur.desktop" -sudo rm /usr/share/pixmaps/imgur.png -sudo rm /usr/bin/imgur +rm $HOME/.local/share/icons/hicolor/256x256/apps/imgur.png +rm $HOME/.local/bin/imgur