yadus: add url shortening shortcut
This commit is contained in:
parent
41a6e1c0fe
commit
60253a0aec
3 changed files with 34 additions and 0 deletions
22
files/.config/i3/bin/yadus-i3
Executable file
22
files/.config/i3/bin/yadus-i3
Executable file
|
@ -0,0 +1,22 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
YADUS_URL="https://tiny.tobast.fr/+submit"
|
||||||
|
|
||||||
|
if [ "$#" -lt "1" ]; then
|
||||||
|
url=$(/usr/bin/dmenu -p "Url to shorten" < /dev/null) || exit 1
|
||||||
|
else
|
||||||
|
url=$1
|
||||||
|
fi
|
||||||
|
|
||||||
|
curl_out=$(/usr/bin/curl -sw '\n%{http_code}' -X POST -d url="$url" "$YADUS_URL")
|
||||||
|
http_code=$(echo -e "$curl_out" | tail -n 1)
|
||||||
|
http_body=$(echo -e "$curl_out" | head -n -1)
|
||||||
|
|
||||||
|
if [ "$http_code" -ne "200" ] ; then
|
||||||
|
# error
|
||||||
|
echo -n "" | /usr/bin/xclip -selection clipboard
|
||||||
|
/usr/bin/notify-send -t 2000 "Yadus error" \
|
||||||
|
"Could not shorten URL ($http_code): $http_body."
|
||||||
|
else
|
||||||
|
echo -n "$http_body" | /usr/bin/xclip -selection clipboard
|
||||||
|
fi
|
8
files/.config/i3/bin/yadus-i3-clip
Executable file
8
files/.config/i3/bin/yadus-i3-clip
Executable file
|
@ -0,0 +1,8 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
clip_content=$(/usr/bin/xclip -selection clipboard -out)
|
||||||
|
if [ -z "$clip_content" ]; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
yadus-i3 "$clip_content"
|
|
@ -48,6 +48,10 @@ bindsym $mod+d exec dmenu_run
|
||||||
|
|
||||||
# Passmenu
|
# Passmenu
|
||||||
bindsym $mod+Shift+p exec /usr/bin/passmenu
|
bindsym $mod+Shift+p exec /usr/bin/passmenu
|
||||||
|
|
||||||
|
# Yadus — shorten stuff
|
||||||
|
bindsym $mod+y exec ~/.config/i3/bin/yadus-i3
|
||||||
|
bindsym $mod+Shift+y exec ~/.config/i3/bin/yadus-i3-clip
|
||||||
##
|
##
|
||||||
|
|
||||||
# change focus
|
# change focus
|
||||||
|
|
Loading…
Reference in a new issue