flip &&/|| instead of using !

This commit is contained in:
i-c-u-p 2022-07-05 04:51:04 -05:00
parent 688ea20708
commit b52a777fca
No known key found for this signature in database
GPG Key ID: ABB80C12170FC0D1
11 changed files with 16 additions and 16 deletions

View File

@ -30,12 +30,12 @@ case "$(file --dereference --brief --mime-type -- "$1")" in
audio/* | application/octet-stream) mediainfo "$1" || exit 1 ;; audio/* | application/octet-stream) mediainfo "$1" || exit 1 ;;
video/* ) video/* )
CACHE="${XDG_CACHE_HOME:-$HOME/.cache}/lf/thumb.$(stat --printf '%n\0%i\0%F\0%s\0%W\0%Y' -- "$(readlink -f "$1")" | sha256sum | cut -d' ' -f1)" CACHE="${XDG_CACHE_HOME:-$HOME/.cache}/lf/thumb.$(stat --printf '%n\0%i\0%F\0%s\0%W\0%Y' -- "$(readlink -f "$1")" | sha256sum | cut -d' ' -f1)"
[ ! -f "$CACHE" ] && ffmpegthumbnailer -i "$1" -o "$CACHE" -s 0 [ -f "$CACHE" ] || ffmpegthumbnailer -i "$1" -o "$CACHE" -s 0
image "$CACHE" "$2" "$3" "$4" "$5" "$1" image "$CACHE" "$2" "$3" "$4" "$5" "$1"
;; ;;
*/pdf) */pdf)
CACHE="${XDG_CACHE_HOME:-$HOME/.cache}/lf/thumb.$(stat --printf '%n\0%i\0%F\0%s\0%W\0%Y' -- "$(readlink -f "$1")" | sha256sum | cut -d' ' -f1)" CACHE="${XDG_CACHE_HOME:-$HOME/.cache}/lf/thumb.$(stat --printf '%n\0%i\0%F\0%s\0%W\0%Y' -- "$(readlink -f "$1")" | sha256sum | cut -d' ' -f1)"
[ ! -f "$CACHE.jpg" ] && pdftoppm -jpeg -f 1 -singlefile "$1" "$CACHE" [ -f "$CACHE.jpg" ] || pdftoppm -jpeg -f 1 -singlefile "$1" "$CACHE"
image "$CACHE.jpg" "$2" "$3" "$4" "$5" "$1" image "$CACHE.jpg" "$2" "$3" "$4" "$5" "$1"
;; ;;
*opendocument*) odt2txt "$1" ;; *opendocument*) odt2txt "$1" ;;

View File

@ -140,11 +140,11 @@ ex=🎯:\
*.java=♨:\ *.java=♨:\
" "
[ ! -f ${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutrc ] && shortcuts >/dev/null 2>&1 & [ -f ${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutrc ] || shortcuts >/dev/null 2>&1 &
if pacman -Qs libxft-bgra >/dev/null 2>&1; then if pacman -Qs libxft-bgra >/dev/null 2>&1; then
# Start graphical server on user's current tty if not already running. # Start graphical server on user's current tty if not already running.
[ "$(tty)" = "/dev/tty1" ] && ! pidof -s Xorg >/dev/null 2>&1 && exec startx "$XINITRC" [ "$(tty)" = "/dev/tty1" ] && pidof -s Xorg >/dev/null 2>&1 || exec startx "$XINITRC"
else else
echo "\033[31mIMPORTANT\033[0m: Note that \033[32m\`libxft-bgra\`\033[0m must be installed for this build of dwm. echo "\033[31mIMPORTANT\033[0m: Note that \033[32m\`libxft-bgra\`\033[0m must be installed for this build of dwm.
Please run: Please run:

View File

@ -5,12 +5,12 @@ do
"w") setbg "$file" & ;; "w") setbg "$file" & ;;
"c") "c")
[ -z "$destdir" ] && destdir="$(sed "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*$/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
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*$/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*$/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
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 # Requires ffmpeg
[ ! -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
echo "Enter the album/book title:"; read -r booktitle echo "Enter the album/book title:"; read -r booktitle
echo "Enter the artist/author:"; read -r author echo "Enter the artist/author:"; read -r author
@ -14,7 +14,7 @@ ext="${1#*.}"
# Get a safe file name from the book. # Get a safe file name from the book.
escbook="$(echo "$booktitle" | iconv -cf UTF-8 -t ASCII//TRANSLIT | tr -d '[:punct:]' | tr '[:upper:]' '[:lower:]' | tr ' ' '-' | sed "s/-\+/-/g;s/\(^-\|-\$\)//g")" escbook="$(echo "$booktitle" | iconv -cf UTF-8 -t ASCII//TRANSLIT | tr -d '[:punct:]' | tr '[:upper:]' '[:lower:]' | tr ' ' '-' | sed "s/-\+/-/g;s/\(^-\|-\$\)//g")"
! mkdir -p "$escbook" && mkdir -p "$escbook" ||
echo "Do you have write access in this directory?" && echo "Do you have write access in this directory?" &&
exit 1 exit 1

View File

@ -11,7 +11,7 @@ share=$(smbclient -L "$srvname" -N | grep Disk | awk '{print $1}' | dmenu -i -p
share2mnt=//"$srvname".local/"$share" share2mnt=//"$srvname".local/"$share"
sharemount() { sharemount() {
mounted=$(mount -v | grep "$share2mnt") || ([ ! -d /mnt/"$share" ] && sudo mkdir /mnt/"$share") mounted=$(mount -v | grep "$share2mnt") || ([ -d /mnt/"$share" ] || sudo mkdir /mnt/"$share")
[ -z "$mounted" ] && sudo mount -t cifs "$share2mnt" -o user=nobody,password="",noperm /mnt/"$share" && notify-send "Netshare $share mounted" && exit 0 [ -z "$mounted" ] && sudo mount -t cifs "$share2mnt" -o user=nobody,password="",noperm /mnt/"$share" && notify-send "Netshare $share mounted" && exit 0
notify-send "Netshare $share already mounted"; exit 1 notify-send "Netshare $share already mounted"; exit 1
} }

View File

@ -14,7 +14,7 @@ cleanup() {
if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
lf "$@" lf "$@"
else else
[ ! -d "$HOME/.cache/lf" ] && mkdir -p "$HOME/.cache/lf" [ -d "$HOME/.cache/lf" ] || mkdir -p "$HOME/.cache/lf"
export FIFO_UEBERZUG="$HOME/.cache/lf/ueberzug-$$" export FIFO_UEBERZUG="$HOME/.cache/lf/ueberzug-$$"
mkfifo "$FIFO_UEBERZUG" mkfifo "$FIFO_UEBERZUG"
ueberzug layer -s <"$FIFO_UEBERZUG" -p json & ueberzug layer -s <"$FIFO_UEBERZUG" -p json &

View File

@ -94,10 +94,10 @@ do
if [ -f "$content" ]; then if [ -f "$content" ]; then
# If images have already been made in a previous run, do not recreate # If images have already been made in a previous run, do not recreate
# them unless -r was given. # them unless -r was given.
{ [ ! -f "$prepdir/$base" ] || [ -n "${redo+x}" ] ;} && { [ -f "$prepdir/$base" ] && [ -n "${redo+x}" ] ;} &&
convert -size "${res:-1920x1080}" canvas:"${bgc:-black}" -gravity center "$content" -resize 1920x1080 -composite "$prepdir/$base" convert -size "${res:-1920x1080}" canvas:"${bgc:-black}" -gravity center "$content" -resize 1920x1080 -composite "$prepdir/$base"
else else
{ [ ! -f "$prepdir/$base" ] || [ -n "${redo+x}" ] ;} && { [ -f "$prepdir/$base" ] && [ -n "${redo+x}" ] ;} &&
convert -size "${res:-1920x1080}" -background "${bgc:-black}" -fill "${fgc:-white}" -font "${font:-Sans}" -pointsize "${ppt:-150}" -gravity center label:"$content" "$prepdir/$base" convert -size "${res:-1920x1080}" -background "${bgc:-black}" -fill "${fgc:-white}" -font "${font:-Sans}" -pointsize "${ppt:-150}" -gravity center label:"$content" "$prepdir/$base"
fi fi

View File

@ -17,7 +17,7 @@ esac
# id total idle # id total idle
stats=$(awk '/cpu[0-9]+/ {printf "%d %d %d\n", substr($1,4), ($2 + $3 + $4 + $5), $5 }' /proc/stat) stats=$(awk '/cpu[0-9]+/ {printf "%d %d %d\n", substr($1,4), ($2 + $3 + $4 + $5), $5 }' /proc/stat)
[ ! -f $cache ] && echo "$stats" > "$cache" [ -f $cache ] || echo "$stats" > "$cache"
old=$(cat "$cache") old=$(cat "$cache")
printf "🪨" printf "🪨"
echo "$stats" | while read -r row; do echo "$stats" | while read -r row; do

View File

@ -266,7 +266,7 @@ getdoppler() {
showdoppler() { setsid -f mpv --no-osc --loop=inf --no-terminal "$doppler" ;} showdoppler() { setsid -f mpv --no-osc --loop=inf --no-terminal "$doppler" ;}
case $BLOCK_BUTTON in case $BLOCK_BUTTON in
1) [ ! -f "$radarloc" ] && pickloc && getdoppler 1) [ -f "$radarloc" ] || pickloc && getdoppler
[ $(($(date '+%s') - $(stat -c %Y "$doppler"))) -gt "$secs" ] && getdoppler [ $(($(date '+%s') - $(stat -c %Y "$doppler"))) -gt "$secs" ] && getdoppler
showdoppler ;; showdoppler ;;
2) pickloc && getdoppler && showdoppler ;; 2) pickloc && getdoppler && showdoppler ;;

View File

@ -30,7 +30,7 @@ shift $((OPTIND - 1))
file="$1" file="$1"
[ ! -f "$file" ] && echo "Provide file to tag." && err [ -f "$file" ] || echo "Provide file to tag." && err
[ -z "$title" ] && echo "Enter a title." && read -r title [ -z "$title" ] && echo "Enter a title." && read -r title
[ -z "$artist" ] && echo "Enter an artist." && read -r artist [ -z "$artist" ] && echo "Enter an artist." && read -r artist

View File

@ -2,6 +2,6 @@
ifinstalled tremc transmission-cli || exit ifinstalled tremc transmission-cli || exit
! pidof transmission-daemon >/dev/null && transmission-daemon && notify-send "Starting torrent daemon..." pidof transmission-daemon >/dev/null || transmission-daemon && notify-send "Starting torrent daemon..."
$TERMINAL -e tremc; pkill -RTMIN+7 "${STATUSBAR:-dwmblocks}" $TERMINAL -e tremc; pkill -RTMIN+7 "${STATUSBAR:-dwmblocks}"