From 25a925f1dcbd592a19dd38ccda9ff31037cf980c Mon Sep 17 00:00:00 2001 From: anntnzrb Date: Thu, 3 Dec 2020 23:46:59 -0500 Subject: [PATCH] Added missing exit codes --- .config/sxiv/exec/key-handler | 4 ++-- .local/bin/booksplit | 4 ++-- .local/bin/cron/checkup | 2 +- .local/bin/dmenumount | 2 +- .local/bin/dmenurecord | 4 ++-- .local/bin/dmenuumount | 8 ++++---- .local/bin/dmenuunicode | 2 +- .local/bin/getbib | 2 +- .local/bin/getkeys | 2 +- .local/bin/qndl | 2 +- .local/bin/rssadd | 2 +- .local/bin/statusbar/disk | 2 +- .local/bin/statusbar/iplocate | 4 ++-- .local/bin/statusbar/volume | 2 +- .local/bin/td-toggle | 2 +- .local/bin/torwrap | 2 +- 16 files changed, 23 insertions(+), 23 deletions(-) diff --git a/.config/sxiv/exec/key-handler b/.config/sxiv/exec/key-handler index 3d9565fc..58b2524b 100755 --- a/.config/sxiv/exec/key-handler +++ b/.config/sxiv/exec/key-handler @@ -5,12 +5,12 @@ do "w") setbg "$file" & ;; "c") [ -z "$destdir" ] && destdir="$(sed "s/\s.*#.*$//;/^\s*$/d" ${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs | awk '{print $2}' | dmenu -l 20 -i -p "Copy file(s) to where?" | sed "s|~|$HOME|g")" - [ ! -d "$destdir" ] && notify-send "$destdir is not a directory, cancelled." && exit + [ ! -d "$destdir" ] && notify-send "$destdir is not a directory, cancelled." && exit 1 cp "$file" "$destdir" && notify-send -i "$(readlink -f "$file")" "$file copied to $destdir." & ;; "m") [ -z "$destdir" ] && destdir="$(sed "s/\s.*#.*$//;/^\s*$/d" ${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs | awk '{print $2}' | dmenu -l 20 -i -p "Move file(s) to where?" | sed "s|~|$HOME|g")" - [ ! -d "$destdir" ] && notify-send "$destdir is not a directory, cancelled." && exit + [ ! -d "$destdir" ] && notify-send "$destdir is not a directory, cancelled." && exit 1 mv "$file" "$destdir" && notify-send -i "$(readlink -f "$file")" "$file moved to $destdir." & ;; "r") diff --git a/.local/bin/booksplit b/.local/bin/booksplit index 7730ac23..29ca9b33 100755 --- a/.local/bin/booksplit +++ b/.local/bin/booksplit @@ -2,7 +2,7 @@ # Requires ffmpeg (audio splitting) and my `tag` wrapper script. -[ ! -f "$2" ] && printf "The first file should be the audio, the second should be the timecodes.\\n" && exit +[ ! -f "$2" ] && printf "The first file should be the audio, the second should be the timecodes.\\n" && exit 1 echo "Enter the album/book title:"; read -r booktitle @@ -43,4 +43,4 @@ done < "$2" echo "From $start to the end: $title" file="$escbook/$(printf "%.2d" "$track")-$esctitle.$ext" echo "Splitting \"$title\"..." && ffmpeg -nostdin -y -loglevel -8 -i "$inputaudio" -ss "$start" -vn -c copy "$file" && - echo "Tagging \"$title\"..." && tag -a "$author" -A "$booktitle" -t "$title" -n "$track" -N "$total" -d "$year" "$file" \ No newline at end of file + echo "Tagging \"$title\"..." && tag -a "$author" -A "$booktitle" -t "$title" -n "$track" -N "$total" -d "$year" "$file" diff --git a/.local/bin/cron/checkup b/.local/bin/cron/checkup index 4cfb856a..1f6d0673 100755 --- a/.local/bin/cron/checkup +++ b/.local/bin/cron/checkup @@ -2,7 +2,7 @@ # Syncs repositories and downloads updates, meant to be run as a cronjob. -ping -q -c 1 example.org > /dev/null || exit +ping -q -c 1 example.org > /dev/null || exit 1 notify-send "📦 Repository Sync" "Checking for package updates..." diff --git a/.local/bin/dmenumount b/.local/bin/dmenumount index b98b6a3a..4d23677d 100755 --- a/.local/bin/dmenumount +++ b/.local/bin/dmenumount @@ -53,7 +53,7 @@ anddrives=$(simple-mtpfs -l 2>/dev/null) usbdrives="$(lsblk -rpo "name,type,size,mountpoint" | grep 'part\|rom' | awk '$4==""{printf "%s (%s)\n",$1,$3}')" if [ -z "$usbdrives" ]; then - [ -z "$anddrives" ] && echo "No USB drive or Android device detected" && exit + [ -z "$anddrives" ] && echo "No USB drive or Android device detected" && exit 1 echo "Android device(s) detected." mountandroid else diff --git a/.local/bin/dmenurecord b/.local/bin/dmenurecord index b1a034a3..4d83d0bf 100755 --- a/.local/bin/dmenurecord +++ b/.local/bin/dmenurecord @@ -24,7 +24,7 @@ killrecording() { # even after SIGTERM, ffmpeg may still run, so SIGKILL it. sleep 3 kill -9 "$recpid" - exit + exit 0 } screencast() { \ @@ -119,5 +119,5 @@ case "$1" in video) video;; *selected) videoselected;; kill) killrecording;; - *) ([ -f /tmp/recordingpid ] && asktoend && exit) || askrecording;; + *) ([ -f /tmp/recordingpid ] && asktoend && exit 0) || askrecording;; esac diff --git a/.local/bin/dmenuumount b/.local/bin/dmenuumount index 26612efe..897bff3f 100755 --- a/.local/bin/dmenuumount +++ b/.local/bin/dmenuumount @@ -5,16 +5,16 @@ # Drives mounted at /, /boot and /home will not be options to unmount. unmountusb() { - [ -z "$drives" ] && exit + [ -z "$drives" ] && exit 1 chosen="$(echo "$drives" | dmenu -i -p "Unmount which drive?")" || exit 1 chosen="$(echo "$chosen" | awk '{print $1}')" - [ -z "$chosen" ] && exit + [ -z "$chosen" ] && exit 1 sudo -A umount "$chosen" && notify-send "💻 USB unmounting" "$chosen unmounted." } unmountandroid() { \ chosen="$(awk '/simple-mtpfs/ {print $2}' /etc/mtab | dmenu -i -p "Unmount which device?")" || exit 1 - [ -z "$chosen" ] && exit + [ -z "$chosen" ] && exit 1 sudo -A umount -l "$chosen" && notify-send "🤖 Android unmounting" "$chosen unmounted." } @@ -29,7 +29,7 @@ asktype() { \ drives=$(lsblk -nrpo "name,type,size,mountpoint" | awk '$4!~/\/boot|\/home$|SWAP/&&length($4)>1{printf "%s (%s)\n",$4,$3}') if ! grep simple-mtpfs /etc/mtab; then - [ -z "$drives" ] && echo "No drives to unmount." && exit + [ -z "$drives" ] && echo "No drives to unmount." && exit 1 echo "Unmountable USB drive detected." unmountusb else diff --git a/.local/bin/dmenuunicode b/.local/bin/dmenuunicode index de1421b9..b653be53 100755 --- a/.local/bin/dmenuunicode +++ b/.local/bin/dmenuunicode @@ -6,7 +6,7 @@ chosen=$(cut -d ';' -f1 ~/.local/share/larbs/emoji | dmenu -i -l 30 | sed "s/ .*//") # Exit if none chosen. -[ -z "$chosen" ] && exit +[ -z "$chosen" ] && exit 1 # If you run this command with an argument, it will automatically insert the # character. Otherwise, show a message that the emoji has been copied. diff --git a/.local/bin/getbib b/.local/bin/getbib index ed441c56..a9e684d4 100755 --- a/.local/bin/getbib +++ b/.local/bin/getbib @@ -1,5 +1,5 @@ #!/bin/sh -[ -z "$1" ] && echo "Give either a pdf file or a DOI as an argument." && exit +[ -z "$1" ] && echo "Give either a pdf file or a DOI as an argument." && exit 1 if [ -f "$1" ]; then # Try to get DOI from pdfinfo or pdftotext output. diff --git a/.local/bin/getkeys b/.local/bin/getkeys index 266f29a6..e87b1a4e 100755 --- a/.local/bin/getkeys +++ b/.local/bin/getkeys @@ -1,5 +1,5 @@ #!/bin/sh -cat "${XDG_DATA_HOME:-$HOME/.local/share}"/larbs/getkeys/"$1" 2>/dev/null && exit +cat "${XDG_DATA_HOME:-$HOME/.local/share}"/larbs/getkeys/"$1" 2>/dev/null && exit 0 echo "Run command with one of the following arguments for info about that program:" ls "${XDG_DATA_HOME:-$HOME/.local/share}"/larbs/getkeys diff --git a/.local/bin/qndl b/.local/bin/qndl index f6fbe87c..b4eb3d5b 100755 --- a/.local/bin/qndl +++ b/.local/bin/qndl @@ -1,7 +1,7 @@ #!/bin/sh # $1 is a url; $2 is a command -[ -z "$1" ] && exit +[ -z "$1" ] && exit 1 base="$(basename "$1")" notify-send "⏳ Queuing $base..." cmd="$2" diff --git a/.local/bin/rssadd b/.local/bin/rssadd index 2ce421bd..bf54eaa3 100755 --- a/.local/bin/rssadd +++ b/.local/bin/rssadd @@ -1,7 +1,7 @@ #!/bin/sh ! echo "$1" | grep "https*://\S\+\.[A-Za-z]\+\S*" >/dev/null && - notify-send "That doesn't look like a full URL." && exit + notify-send "That doesn't look like a full URL." && exit 1 RSSFILE="${XDG_CONFIG_HOME:-$HOME/.config}/newsboat/urls" if awk '{print $1}' "$RSSFILE" | grep "^$1$" >/dev/null; then notify-send "You already have this RSS feed." diff --git a/.local/bin/statusbar/disk b/.local/bin/statusbar/disk index e947509d..5ad8e94c 100755 --- a/.local/bin/statusbar/disk +++ b/.local/bin/statusbar/disk @@ -5,7 +5,7 @@ location=${1:-/} -[ -d "$location" ] || exit +[ -d "$location" ] || exit 1 case $BLOCK_BUTTON in 1) notify-send "💽 Disk space" "$(df -h --output=target,used,size)" ;; diff --git a/.local/bin/statusbar/iplocate b/.local/bin/statusbar/iplocate index 02adab8d..59512001 100755 --- a/.local/bin/statusbar/iplocate +++ b/.local/bin/statusbar/iplocate @@ -5,6 +5,6 @@ # # https://www.maketecheasier.com/ip-address-geolocation-lookups-linux/ -ifinstalled "geoip" || exit -addr="$(curl ifconfig.me 2>/dev/null)" || exit +ifinstalled "geoip" || exit 1 +addr="$(curl ifconfig.me 2>/dev/null)" || exit 1 grep "flag: " "${XDG_DATA_HOME:-$HOME/.local/share}/larbs/emoji" | grep "$(geoiplookup "$addr" | sed 's/.*, //')" | sed "s/flag: //;s/;.*//" diff --git a/.local/bin/statusbar/volume b/.local/bin/statusbar/volume index 61588c3f..699f51a9 100755 --- a/.local/bin/statusbar/volume +++ b/.local/bin/statusbar/volume @@ -13,7 +13,7 @@ case $BLOCK_BUTTON in 6) "$TERMINAL" -e "$EDITOR" "$0" ;; esac -[ $(pamixer --get-mute) = true ] && echo 🔇 && exit +[ $(pamixer --get-mute) = true ] && echo 🔇 && exit 0 vol="$(pamixer --get-volume)" diff --git a/.local/bin/td-toggle b/.local/bin/td-toggle index d2ba76ae..33d7e76b 100755 --- a/.local/bin/td-toggle +++ b/.local/bin/td-toggle @@ -6,7 +6,7 @@ if pidof transmission-daemon >/dev/null ; then [ "$(printf "No\\nYes" | dmenu -i -p "Turn off transmission-daemon?")" = "Yes" ] && killall transmission-da && notify-send "transmission-daemon disabled." else - ifinstalled transmission-cli || exit + ifinstalled transmission-cli || exit 1 [ "$(printf "No\\nYes" | dmenu -i -p "Turn on transmission daemon?")" = "Yes" ] && transmission-daemon && notify-send "tranmission-daemon enabled." fi sleep 3 && pkill -RTMIN+7 "${STATUSBAR:-dwmblocks}" diff --git a/.local/bin/torwrap b/.local/bin/torwrap index 4f94053e..419573e5 100755 --- a/.local/bin/torwrap +++ b/.local/bin/torwrap @@ -1,6 +1,6 @@ #!/bin/sh -ifinstalled tremc-git transmission-cli || exit +ifinstalled tremc-git transmission-cli || exit 1 ! pidof transmission-daemon >/dev/null && transmission-daemon && notify-send "Starting torrent daemon..."