~skiqqy/.dotfiles

c6923edc556014ef60f282ecffe5098b3f9f7fec — Stephen Cochrane 3 years ago e5c7647 bin
Tidy up
4 files changed, 1 insertions(+), 74 deletions(-)

M Makefile
D miscfiles/scripts/binary
D miscfiles/scripts/bip
D miscfiles/scripts/picbin
M Makefile => Makefile +1 -1
@@ 23,7 23,7 @@ submods:
setupbin:
	[ ! -d ~/bin ] && git clone https://github.com/skippy404/bin $$HOME/bin || echo "bin already exists"
	mkdir -p ~/bin/local
	cp $(DIR)/miscfiles/scripts/* ~/bin
	cp $(DIR)/miscfiles/scripts/* ~/bin/local/
	-rm -f ~/bin/local/upd # We need to custom build this

# Sets up custom updating script based on install location

D miscfiles/scripts/binary => miscfiles/scripts/binary +0 -7
@@ 1,7 0,0 @@
toBinary(){
	local n bit
	for (( n=$1 ; n>0 ; n >>= 1 )); do  bit="$(( n&1 ))$bit"; done
		printf "%s\n" "$bit"
}

toBinary $1

D miscfiles/scripts/bip => miscfiles/scripts/bip +0 -12
@@ 1,12 0,0 @@
toBinary(){
	local n bit
	for (( n=$1 ; n>0 ; n >>= 1 )); do  bit="$(( n&1 ))$bit"; done
		printf "%s\n" "$bit"
}

addr1=$(echo $1 | cut -d "." -f 1)
addr2=$(echo $1 | cut -d "." -f 2)
addr3=$(echo $1 | cut -d "." -f 3)
addr4=$(echo $1 | cut -d "." -f 4)

echo $(toBinary $addr1)"."$(toBinary $addr2)"."$(toBinary $addr3)"."$(toBinary $addr4)

D miscfiles/scripts/picbin => miscfiles/scripts/picbin +0 -54
@@ 1,54 0,0 @@
#/bin/bash
# @Auther Stephen Cochrane
# github: skippy404
set -e

usage () {
	echo "<usage> picbin [options]"
	echo "Args:"
	echo "h: Shows this message."
	echo "l: shows the link to the file in a dialog box"
	echo "p: path to the file"
	exit $1
}

while getopts "hp:l" opt
do
	case $opt in
		h)
			usage 0
			;;
		p)
			path="$OPTARG"
			;;
		l)
			link=1
			;;
		*)
			exit 2
			;;
	esac
done

if [ $path ]
then
	[ 0 -eq $# ] && usage 1
	[[ ! -f $path ]] && usage 1
else
	gnome-screenshot -f /tmp/picbin.png
	path="/tmp/picbin.png"
fi

abort() {
	echo "Aborting upload of $path"
	exit 0
}

zenity --question --text="Confirm upload."
[ ! $? ] && abort

echo "Uploading -> $path"

url=$(curl -F"file=@$path" https://0x0.st)
echo $url
[ $link ] && zenity --info --window-icon="info" --text="$url" || exit 0