53 lines
998 B
Bash
Executable File
53 lines
998 B
Bash
Executable File
#!/bin/sh
|
|
|
|
## upload files and share with transfer.sh in non-X sessions ##
|
|
|
|
# a simple menu
|
|
if [ -n "$DISPLAY" ]; then
|
|
MENU=dmenu.sh
|
|
|
|
else
|
|
MENU=fzfmenu.sh
|
|
|
|
fi
|
|
|
|
OPT=$(echo "documentos\nimágenes\nmúsica\nscripts\nvídeos" | $MENU)
|
|
|
|
# define filters
|
|
case $OPT in
|
|
documentos)
|
|
filter=".pdf|.txt"
|
|
;;
|
|
imágenes)
|
|
filter=".png|.jpg|.jpeg"
|
|
;;
|
|
música)
|
|
filter=".mp3|.flac|.wav|.ogg|.webm"
|
|
;;
|
|
scripts)
|
|
filter=".pl|.py|.sh|.bash"
|
|
;;
|
|
vídeos)
|
|
filter=".mp4|.avi|.mkv"
|
|
;;
|
|
esac
|
|
|
|
# do the thing
|
|
if [ -n "$filter" ]; then
|
|
|
|
filepath=$(find $HOME -type f | grep -E "$filter" | $MENU) # path to file
|
|
if [ -n "$filepath" ]; then # if filepath
|
|
if [ -n "$DISPLAY" ]; then
|
|
# upload the file and save it to the clipboard
|
|
curl -F "file=@$filepath" -F "secret=" https://0x0.st | xclip
|
|
|
|
# make it available to other programs
|
|
xclip -o | xclip -sel c
|
|
|
|
else
|
|
curl -F "file=@$filepath" -F "secret=" https://0x0.st > /tmp/share.txt
|
|
|
|
fi
|
|
fi
|
|
fi
|