binscripts: make indentation consistent

This commit is contained in:
Henrik Lissner 2017-12-18 01:12:13 -05:00
parent e6ace9c085
commit 9166534b29
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
5 changed files with 63 additions and 63 deletions

View file

@ -4,26 +4,26 @@
# Linux). # Linux).
if [[ -t 0 ]]; then if [[ -t 0 ]]; then
if command -v xclip >/dev/null; then if command -v xclip >/dev/null; then
xclip -display :0 -selection clipboard -out xclip -display :0 -selection clipboard -out
elif command -v xsel >/dev/null; then elif command -v xsel >/dev/null; then
xsel --clipboard --output xsel --clipboard --output
elif command -v pbpaste >/dev/null; then elif command -v pbpaste >/dev/null; then
pbpaste pbpaste
else else
>&2 echo "No clipboard detected. Aborting." >&2 echo "No clipboard detected. Aborting."
exit 1 exit 1
fi fi
else else
if command -v xclip >/dev/null; then if command -v xclip >/dev/null; then
xclip -display :0 -selection clipboard -in xclip -display :0 -selection clipboard -in
elif command -v xsel >/dev/null; then elif command -v xsel >/dev/null; then
xsel --clipboard --input xsel --clipboard --input
elif command -v pbcopy >/dev/null; then elif command -v pbcopy >/dev/null; then
pbcopy pbcopy
else else
>&2 echo "No clipboard detected. Aborting." >&2 echo "No clipboard detected. Aborting."
exit 1 exit 1
fi fi
fi fi

View file

@ -7,34 +7,34 @@
set -e set -e
if (($# == 0)); then if (($# == 0)); then
>&2 echo "Usage: $0 <FILE|DIRECTORY> [DEST]" >&2 echo "Usage: $0 <FILE|DIRECTORY> [DEST]"
exit 1 exit 1
fi fi
ext='clump' ext='clump'
target="$1" target="$1"
cmd= cmd=
if [[ -f $target ]]; then if [[ -f $target ]]; then
cmd=unpack cmd=unpack
elif [[ -d $target ]]; then elif [[ -d $target ]]; then
cmd=pack cmd=pack
else else
>&2 echo "Not a valid target: '$target'" >&2 echo "Not a valid target: '$target'"
exit 1 exit 1
fi fi
case $cmd in case $cmd in
p|pack) p|pack)
if [[ -f $target.$ext ]]; then if [[ -f $target.$ext ]]; then
>&2 echo "Destination file already exists" >&2 echo "Destination file already exists"
exit 2 exit 2
fi fi
tar -pcvf - "$target" | gpg -c > "$target.$ext" tar -pcvf - "$target" | gpg -c > "$target.$ext"
echo "Packed into $target.$ext" echo "Packed into $target.$ext"
;; ;;
u|unpack) u|unpack)
tmpfile=$(mktemp) tmpfile=$(mktemp)
gpg -d "$target" > "$tmpfile" && tar -pxvf "$tmpfile" gpg -d "$target" > "$tmpfile" && tar -pxvf "$tmpfile"
rm -f "$tmpfile" rm -f "$tmpfile"
;; ;;
esac esac

View file

@ -15,10 +15,10 @@ ENTITIES = {value: key for key, value in entitydefs.items()}
def encode(text): def encode(text):
t = "" t = ""
for c in text: for c in text:
if c in ENTITIES: if c in ENTITIES:
t += "&" + ENTITIES[c] + ";" t += "&" + ENTITIES[c] + ";"
else: else:
t += c t += c
return t return t
def decode(text): def decode(text):

View file

@ -21,26 +21,26 @@ bin="${0##*/}"
flags= flags=
while getopts p:i:l: opt; do while getopts p:i:l: opt; do
case $opt in case $opt in
p) flags+=" -p $OPTARG" ;; p) flags+=" -p $OPTARG" ;;
i) flags+=" -i $OPTARG" ;; i) flags+=" -i $OPTARG" ;;
l) flags+=" -l $OPTARG" ;; l) flags+=" -l $OPTARG" ;;
*) >&2 echo "Invalid option $OPTARG" *) >&2 echo "Invalid option $OPTARG"
exit 1 exit 1
;; ;;
esac esac
done done
shift $((OPTIND-1)) shift $((OPTIND-1))
target="$1" target="$1"
if [[ $target ]]; then if [[ $target ]]; then
if [[ -t 0 ]]; then if [[ -t 0 ]]; then
pb | $bin $target pb | $bin $target
else else
ssh $flags -qt "$target" "pb" && echo "Sent to $target" ssh $flags -qt "$target" "pb" && echo "Sent to $target"
fi fi
else else
pb pb
fi fi
# vim:set ft=sh: # vim:set ft=sh:

View file

@ -2,11 +2,11 @@
# A script that takes a screenshot and stores it in the clipboard # A script that takes a screenshot and stores it in the clipboard
tmp=$(mktemp) tmp=$(mktemp)
if maim -us >"$tmp"; then if maim -us >"$tmp"; then
xclip -selection clipboard -t image/png "$tmp" && \ xclip -selection clipboard -t image/png "$tmp" && \
ding && \ ding && \
notify-send "Screenshot saved" notify-send "Screenshot saved"
else else
notify-send -u low "Screenshot aborted" notify-send -u low "Screenshot aborted"
ding error ding error
fi fi
rm -f "$tmp" rm -f "$tmp"