summaryrefslogtreecommitdiff
path: root/.scripts/upmenu
diff options
context:
space:
mode:
Diffstat (limited to '.scripts/upmenu')
-rwxr-xr-x.scripts/upmenu46
1 files changed, 46 insertions, 0 deletions
diff --git a/.scripts/upmenu b/.scripts/upmenu
new file mode 100755
index 0000000..f600e3a
--- /dev/null
+++ b/.scripts/upmenu
@@ -0,0 +1,46 @@
+#!/bin/sh
+
+# hello guys its mokuken!!
+
+function upmenu {
+ options="Upload a File\nRecent Uploads\nCancel"
+ selected=$(echo -e $options | dmenu -l 3 )
+ if [[ "$selected" == "Upload a File" ]]; then
+
+ target="$1"
+ [ -z "$target" ] && target="$(realpath .)"
+
+ while :; do
+ sel="$(ls -1a "$target" | grep -v '^\.$' | dmenu -l 25 )" || exit
+ if [ "$(echo "$sel" | cut -b1)" = "/" ]; then
+ newt="$sel"
+ else
+ newt="$(realpath "$target/$sel")"
+ fi
+ if [ -e "$newt" ]; then
+ target="$newt"
+ if [ ! -d "$target" ]; then
+ echo "Location: $target"
+ command="curl -s -F'file=@$target' https://0x0.st"
+ echo "Executing: $command"
+
+ url=$(eval $command)
+ echo "URL: $url"
+
+ printf "$url" | xclip -sel clip
+ notify-send "File Uploaded" "URL: $url \ncopied to clipboard" -t 5000 -i "$HOME/.program/icon.png"
+
+ entry="$(date '+%d-%m-%y-%H:%M:%S') $url $(echo $target | awk -F'/' '{print $(NF)}')"
+ echo $entry >> $HOME/.0x0_list
+ echo "Uploaded"; break
+ fi
+ fi
+ done
+ elif [[ "$selected" == "Recent Uploads" ]]; then
+ cat ~/.0x0_list | dmenu -l 10
+ elif [[ "$selected" == "Cancel" ]]; then
+ return
+ fi
+}
+
+upmenu