Browse Source

Added teknik script for upload replacement. Updated i3 accordingly

pull/2/head
Josh Wolfe 5 years ago
parent
commit
971824b12e
  1. 182
      bin/bin/teknik
  2. 5
      git/.gitconfig
  3. 6
      i3/.config/i3/config
  4. 1
      zsh/.zshrc

182
bin/bin/teknik

@ -0,0 +1,182 @@ @@ -0,0 +1,182 @@
#!/bin/bash
#
# teknik - Upload files/scrots/urls to teknik.io (rip pomf & uguu ;_;7)
# This script requires maim / xclip / wget be installed.
# By onodera, modified by SirCmpwn
# Further modified by alusion
## CONFIGURATION
# Copy links to clipboard after upload (requires xclip)
clipboard=true
# Send a notification when done
notify=true
# Open URL in browser
browser=false
# Log URLs
log=true
# Log file location
logfile="$HOME/.teknik"
## FUNCTIONS
bin_there() {
if ! type "$@" >/dev/null 2>&1 ; then
echo "$@ not installed."
exit 1
fi
}
# This function sets $file to a selection scrot
selection() {
bin_there "maim"
uploadme="/tmp/scrot.png"
maim --hidecursor -s -m 10 -b 3 -c 250,250,250 "$uploadme" 2> "/dev/null"
if [[ "$?" -ge 1 ]]; then
echo "Selection cancelled.">&2
exit 1
fi
word=selection
}
# This function sets $file to your clipboard contents
clipboard() {
bin_there "xclip"
uploadme="/tmp/scrot.txt"
xclip -o > "$uploadme"
word=clipboard
}
# This function sets $file an url
url() {
bin_there "wget"
type="$(echo "$location" | rev | cut -d "." -f 1 | rev)"
uploadme="/tmp/url.$type"
wget --quiet "$location" -O "$uploadme"
word=url
}
# This function sets $file a file
file() {
if [[ -f "$location" ]]; then
uploadme="$location"
else
echo "File not found.">&2
exit 1
fi
word=file
}
# This function sets $file to a full screen scrot
desktop() {
bin_there "maim"
uploadme="/tmp/scrot.png"
maim --hidecursor "$uploadme"
word=desktop
}
# This function uploads the $file
upload(){
if
[[ ${uploadme} =~ png ]]
then
url=$(curl -silent -F file="@$uploadme;type=image/png" "https://api.teknik.io/v1/Upload")
if
[[ "${url}" =~ "error" ]]; then
printf 'error uploading file!\n'
exit 1
else
url="${url##*fileName\":\"}"
url="https://u.teknik.io/${url%%\"*}"
fi
else
url=$(curl -silent -F file="@$uploadme" "https://api.teknik.io/v1/Upload")
if
[[ "${url}" =~ "error" ]]; then
printf 'error uploading file!\n'
exit 1
else
url="${url##*fileName\":\"}"
url="https://u.teknik.io/${url%%\"*}"
fi
fi
}
# This function logs the url, copies the url to the clipboard, and/or opens the url in your browser
feedback() {
# Copy url to clipboard
if [[ "$clipboard" == true ]]; then
bin_there "xclip"
echo "$url" | xclip -selection primary
echo "$url" | xclip -selection clipboard
fi
# Log url
if [[ "$log" == true ]]; then
echo "$url" >> "$logfile"
fi
# Open url in browser
if [[ "$browser" == true ]]; then
xdg-open "$url"
fi
# Send notification
if [[ "$notify" == true ]]; then
notify-send "Upload complete: $url"
fi
echo "${url}"
}
## EXECUTE
if [[ "$#" -ge 1 ]]; then
case "$@" in
-h|--help)
echo "usage: teknik [options] [file/url]"
echo "options:"
echo " -h, --help print help and exit"
echo " -p, --paste upload your clipboard as text"
echo " -s, --selection upload selection scrot"
echo " -v, --version print version and exit"
exit 0
;;
-s|--selection)
selection
;;
-v|--version)
echo "teknik 0.1.1"
exit 0
;;
-p|--paste)
clipboard
;;
http*)
location="$@"
url
;;
*)
location="$@"
file
;;
esac
else
desktop
fi
if [[ "$#" -eq 0 ]]; then
desktop
fi
upload
feedback

5
git/.gitconfig

@ -0,0 +1,5 @@ @@ -0,0 +1,5 @@
[user]
email = joshuafwolfe@gmail.com
name = Josh Wolfe
[push]
default = simple

6
i3/.config/i3/config

@ -8,7 +8,7 @@ exec --no-startup-id ~/bin/battery_notify @@ -8,7 +8,7 @@ exec --no-startup-id ~/bin/battery_notify
exec --no-startup-id powertop --auto-tune
exec --no-startup-id tlp start
exec --no-startup-id xset r rate 225 30
exec --no-startup-id ~/.config/i3/fibonacci.py
#exec --no-startup-id ~/.config/i3/fibonacci.py
# Disable window borders
for_window [class="^.*"] border pixel 2
@ -49,7 +49,7 @@ for_window [title="^QEMU$"] floating enable @@ -49,7 +49,7 @@ for_window [title="^QEMU$"] floating enable
bindsym XF86AudioRaiseVolume exec amixer -D pulse sset Master 2%+
bindsym XF86AudioLowerVolume exec amixer -D pulse sset Master 2%-
bindsym XF86AudioMute exec amixer set Master toggle
bindsym --release Print exec ~/bin/shot_upload
bindsym --release Print exec ~/bin/teknik -s
# brightness keys
bindsym XF86MonBrightnessUp exec xbacklight -inc 2
@ -86,7 +86,7 @@ bindsym $mod+Shift+q kill @@ -86,7 +86,7 @@ bindsym $mod+Shift+q kill
# start dmenu (a program launcher)
bindsym $mod+space exec rofi -show run
bindsym $mod+c exec google-chrome-stable
bindsym $mod+c exec vivaldi-snapshot
bindsym $mod+n exec "~/bin/lock.sh"
# change focus

1
zsh/.zshrc

@ -126,6 +126,7 @@ bindkey -M viins '^u' backward-kill-line @@ -126,6 +126,7 @@ bindkey -M viins '^u' backward-kill-line
alias :q='exit'
alias less='less -R'
alias grep='grep --color=always'
alias pacaur='pacaur --color=always'
alias open='xdg-open'
alias wttr='~/bin/weather'
alias ducolor='cdu -i -s -dh'

Loading…
Cancel
Save