Skip to content

Instantly share code, notes, and snippets.

@williamd1k0
Last active August 1, 2022 18:50
Show Gist options
  • Save williamd1k0/aa267c777ff8f18535e663ee336cde4b to your computer and use it in GitHub Desktop.
Save williamd1k0/aa267c777ff8f18535e663ee336cde4b to your computer and use it in GitHub Desktop.
Simple shell script to download a file using zenity as GUI (useful for file manager integration).
zenity
xclip
aria2
<action>
<icon>downline</icon>
<name>Download File...</name>
<unique-id>1633819767686351-2</unique-id>
<command>zenity-dl</command>
<description>Download a file to the current directory</description>
<patterns>*</patterns>
<directories/>
</action>
#!/usr/bin/sh
URL_CB="$(xclip -o -sel clip)"
if [ -n "$URL_CB" ]; then
if ! echo "$URL_CB" | rg -q '^https?://'; then
URL_CB=''
fi
fi
URL=$(zenity --entry --title="Download File" --text="Enter an URL to download:" --entry-text="$URL_CB" --ok-label="Download" --width 400)
if [ -n "$URL" ]; then
aria2c "$URL"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment