Added missing exit codes

This commit is contained in:
anntnzrb 2020-12-03 23:46:59 -05:00
parent b30ca735b6
commit 25a925f1dc
16 changed files with 23 additions and 23 deletions

View File

@ -5,12 +5,12 @@ do
"w") setbg "$file" & ;; "w") setbg "$file" & ;;
"c") "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")" [ -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." & cp "$file" "$destdir" && notify-send -i "$(readlink -f "$file")" "$file copied to $destdir." &
;; ;;
"m") "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")" [ -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." & mv "$file" "$destdir" && notify-send -i "$(readlink -f "$file")" "$file moved to $destdir." &
;; ;;
"r") "r")

View File

@ -2,7 +2,7 @@
# Requires ffmpeg (audio splitting) and my `tag` wrapper script. # 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 echo "Enter the album/book title:"; read -r booktitle

View File

@ -2,7 +2,7 @@
# Syncs repositories and downloads updates, meant to be run as a cronjob. # 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..." notify-send "📦 Repository Sync" "Checking for package updates..."

View File

@ -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}')" usbdrives="$(lsblk -rpo "name,type,size,mountpoint" | grep 'part\|rom' | awk '$4==""{printf "%s (%s)\n",$1,$3}')"
if [ -z "$usbdrives" ]; then 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." echo "Android device(s) detected."
mountandroid mountandroid
else else

View File

@ -24,7 +24,7 @@ killrecording() {
# even after SIGTERM, ffmpeg may still run, so SIGKILL it. # even after SIGTERM, ffmpeg may still run, so SIGKILL it.
sleep 3 sleep 3
kill -9 "$recpid" kill -9 "$recpid"
exit exit 0
} }
screencast() { \ screencast() { \
@ -119,5 +119,5 @@ case "$1" in
video) video;; video) video;;
*selected) videoselected;; *selected) videoselected;;
kill) killrecording;; kill) killrecording;;
*) ([ -f /tmp/recordingpid ] && asktoend && exit) || askrecording;; *) ([ -f /tmp/recordingpid ] && asktoend && exit 0) || askrecording;;
esac esac

View File

@ -5,16 +5,16 @@
# Drives mounted at /, /boot and /home will not be options to unmount. # Drives mounted at /, /boot and /home will not be options to unmount.
unmountusb() { unmountusb() {
[ -z "$drives" ] && exit [ -z "$drives" ] && exit 1
chosen="$(echo "$drives" | dmenu -i -p "Unmount which drive?")" || exit 1 chosen="$(echo "$drives" | dmenu -i -p "Unmount which drive?")" || exit 1
chosen="$(echo "$chosen" | awk '{print $1}')" chosen="$(echo "$chosen" | awk '{print $1}')"
[ -z "$chosen" ] && exit [ -z "$chosen" ] && exit 1
sudo -A umount "$chosen" && notify-send "💻 USB unmounting" "$chosen unmounted." sudo -A umount "$chosen" && notify-send "💻 USB unmounting" "$chosen unmounted."
} }
unmountandroid() { \ unmountandroid() { \
chosen="$(awk '/simple-mtpfs/ {print $2}' /etc/mtab | dmenu -i -p "Unmount which device?")" || exit 1 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." 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}') 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 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." echo "Unmountable USB drive detected."
unmountusb unmountusb
else else

View File

@ -6,7 +6,7 @@
chosen=$(cut -d ';' -f1 ~/.local/share/larbs/emoji | dmenu -i -l 30 | sed "s/ .*//") chosen=$(cut -d ';' -f1 ~/.local/share/larbs/emoji | dmenu -i -l 30 | sed "s/ .*//")
# Exit if none chosen. # Exit if none chosen.
[ -z "$chosen" ] && exit [ -z "$chosen" ] && exit 1
# If you run this command with an argument, it will automatically insert the # If you run this command with an argument, it will automatically insert the
# character. Otherwise, show a message that the emoji has been copied. # character. Otherwise, show a message that the emoji has been copied.

View File

@ -1,5 +1,5 @@
#!/bin/sh #!/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 if [ -f "$1" ]; then
# Try to get DOI from pdfinfo or pdftotext output. # Try to get DOI from pdfinfo or pdftotext output.

View File

@ -1,5 +1,5 @@
#!/bin/sh #!/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:" echo "Run command with one of the following arguments for info about that program:"
ls "${XDG_DATA_HOME:-$HOME/.local/share}"/larbs/getkeys ls "${XDG_DATA_HOME:-$HOME/.local/share}"/larbs/getkeys

View File

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
# $1 is a url; $2 is a command # $1 is a url; $2 is a command
[ -z "$1" ] && exit [ -z "$1" ] && exit 1
base="$(basename "$1")" base="$(basename "$1")"
notify-send "⏳ Queuing $base..." notify-send "⏳ Queuing $base..."
cmd="$2" cmd="$2"

View File

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
! echo "$1" | grep "https*://\S\+\.[A-Za-z]\+\S*" >/dev/null && ! 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" RSSFILE="${XDG_CONFIG_HOME:-$HOME/.config}/newsboat/urls"
if awk '{print $1}' "$RSSFILE" | grep "^$1$" >/dev/null; then if awk '{print $1}' "$RSSFILE" | grep "^$1$" >/dev/null; then
notify-send "You already have this RSS feed." notify-send "You already have this RSS feed."

View File

@ -5,7 +5,7 @@
location=${1:-/} location=${1:-/}
[ -d "$location" ] || exit [ -d "$location" ] || exit 1
case $BLOCK_BUTTON in case $BLOCK_BUTTON in
1) notify-send "💽 Disk space" "$(df -h --output=target,used,size)" ;; 1) notify-send "💽 Disk space" "$(df -h --output=target,used,size)" ;;

View File

@ -5,6 +5,6 @@
# #
# https://www.maketecheasier.com/ip-address-geolocation-lookups-linux/ # https://www.maketecheasier.com/ip-address-geolocation-lookups-linux/
ifinstalled "geoip" || exit ifinstalled "geoip" || exit 1
addr="$(curl ifconfig.me 2>/dev/null)" || exit 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/;.*//" grep "flag: " "${XDG_DATA_HOME:-$HOME/.local/share}/larbs/emoji" | grep "$(geoiplookup "$addr" | sed 's/.*, //')" | sed "s/flag: //;s/;.*//"

View File

@ -13,7 +13,7 @@ case $BLOCK_BUTTON in
6) "$TERMINAL" -e "$EDITOR" "$0" ;; 6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac esac
[ $(pamixer --get-mute) = true ] && echo 🔇 && exit [ $(pamixer --get-mute) = true ] && echo 🔇 && exit 0
vol="$(pamixer --get-volume)" vol="$(pamixer --get-volume)"

View File

@ -6,7 +6,7 @@ if pidof transmission-daemon >/dev/null ;
then then
[ "$(printf "No\\nYes" | dmenu -i -p "Turn off transmission-daemon?")" = "Yes" ] && killall transmission-da && notify-send "transmission-daemon disabled." [ "$(printf "No\\nYes" | dmenu -i -p "Turn off transmission-daemon?")" = "Yes" ] && killall transmission-da && notify-send "transmission-daemon disabled."
else 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." [ "$(printf "No\\nYes" | dmenu -i -p "Turn on transmission daemon?")" = "Yes" ] && transmission-daemon && notify-send "tranmission-daemon enabled."
fi fi
sleep 3 && pkill -RTMIN+7 "${STATUSBAR:-dwmblocks}" sleep 3 && pkill -RTMIN+7 "${STATUSBAR:-dwmblocks}"

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/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..." ! pidof transmission-daemon >/dev/null && transmission-daemon && notify-send "Starting torrent daemon..."