From f9e580106e108c2875414ed7e4c40b3005770cd3 Mon Sep 17 00:00:00 2001 From: Miles Alan Date: Sun, 7 Jun 2020 09:56:12 -0500 Subject: [PATCH] Shellcheck and tabindent all appscripts --- scripts/appscripts/sxmo_files.sh | 28 +++++----- scripts/appscripts/sxmo_rss.sh | 2 +- scripts/appscripts/sxmo_timer.sh | 84 +++++++++++++++--------------- scripts/appscripts/sxmo_weather.sh | 8 +-- scripts/appscripts/sxmo_youtube.sh | 46 ++++++++-------- 5 files changed, 84 insertions(+), 84 deletions(-) diff --git a/scripts/appscripts/sxmo_files.sh b/scripts/appscripts/sxmo_files.sh index 0423443..a58bd82 100755 --- a/scripts/appscripts/sxmo_files.sh +++ b/scripts/appscripts/sxmo_files.sh @@ -1,23 +1,23 @@ #!/usr/bin/env sh EDITOR=vis -cd /home/$USER/ +cd "/home/$USER/" || exit 1 handlefiles() { - echo "$1" | grep -iE ".(wav|webm|mp4|ogg|opus|m4a|flac|mov|avi)$" && st -e mpv "$@" && exit - echo "$1" | grep -iE ".(jpg|png|gif)$" && st -e sxiv "$@" && exit - st -e sh -ic "$EDITOR "$@"" && exit + echo "$1" | grep -iE ".(wav|webm|mp4|ogg|opus|m4a|flac|mov|avi)$" && st -e mpv "$@" && exit + echo "$1" | grep -iE ".(jpg|png|gif)$" && st -e sxiv "$@" && exit + st -e sh -ic "$EDITOR $*" && exit } while true; do - CHOICES="$(echo -e 'Close Menu\n../\n*\n'"$(ls -1p)")" - DIR="$(basename "$(pwd)")" - PICKED="$( - echo "$CHOICES" | - dmenu -fn Terminus-18 -c -p "$DIR" -l 20 - )" + CHOICES="$(printf %b 'Close Menu\n../\n*\n'"$(ls -1p)")" + DIR="$(basename "$(pwd)")" + PICKED="$( + echo "$CHOICES" | + dmenu -fn Terminus-18 -c -p "$DIR" -l 20 + )" - echo "$PICKED" | grep "Close Menu" && exit 0 - [ -d "$PICKED" ] && cd "$PICKED" && continue - echo "$PICKED" | grep -E '^[*]$' && handlefiles * - [ -f "$PICKED" ] && handlefiles "$PICKED" + echo "$PICKED" | grep "Close Menu" && exit 0 + [ -d "$PICKED" ] && cd "$PICKED" && continue + echo "$PICKED" | grep -E '^[*]$' && handlefiles ./* + [ -f "$PICKED" ] && handlefiles "$PICKED" done diff --git a/scripts/appscripts/sxmo_rss.sh b/scripts/appscripts/sxmo_rss.sh index 27b56d9..b6ff93d 100755 --- a/scripts/appscripts/sxmo_rss.sh +++ b/scripts/appscripts/sxmo_rss.sh @@ -46,7 +46,7 @@ FOLDER="/tmp/sfeed_$(echo "$TIMESPAN" | sed 's/ /_/g')" prep_temp_folder_with_items # Show list of items -PICKED=$(echo "$(list_items)" | dmenu -p "RSS" -c -l 20 -fn Terminus-15) +PICKED=$(list_items | dmenu -p "RSS" -c -l 20 -fn Terminus-15) # Handle picked item URL="$(echo "$PICKED" | gawk -F " " '{print $NF}')" diff --git a/scripts/appscripts/sxmo_timer.sh b/scripts/appscripts/sxmo_timer.sh index 6e5546b..eb685ba 100755 --- a/scripts/appscripts/sxmo_timer.sh +++ b/scripts/appscripts/sxmo_timer.sh @@ -1,51 +1,51 @@ #!/usr/bin/env sh timerrun() { - TIME=$( - echo "$@" | - sed 's#h#*60m#g'| - sed 's#m#*60s#g'| - sed 's#s#*1#g'| - sed 's# #+#g' | - bc - ) + TIME=$( + echo "$@" | + sed 's#h#*60m#g'| + sed 's#m#*60s#g'| + sed 's#s#*1#g'| + sed 's# #+#g' | + bc + ) - date1=$((`date +%s` + $TIME)); - while [ "$date1" -ge `date +%s` ]; do - echo -ne "$(date -u --date @$(($date1 - `date +%s`)) +%H:%M:%S) \r"; - sleep 0.1 - done - echo "Done with $@" + DATE1=$(($(date +%s) + TIME)); + while [ "$DATE1" -ge "$(date +%s)" ]; do + printf %b "$(date -u --date @$((DATE1 - $(date +%s))) +%H:%M:%S) \r"; + sleep 0.1 + done + echo "Done with $*" - while :; - do notify-send "Done with $@"; - sxmo_vibratepine 1000 - sleep 0.5 - done + while :; + do notify-send "Done with $*"; + sxmo_vibratepine 1000 + sleep 0.5 + done } menu() { - pidof svkbd-sxmo || svkbd-sxmo & - TIMEINPUT="$( - echo -e " - 1h - 10m - 9m - 8m - 7m - 6m - 5m - 4m - 3m - 2m - 1m - 30s - Close Menu - " | awk 'NF' | awk '{$1=$1};1' | dmenu -p Timer -c -fn "Terminus-30" -l 20 - )" - pkill svkbd-sxmo - [[ "Close Menu" == "$TIMEINPUT" ]] && exit 0 - - st -f Monospace-50 -e $0 timerrun $TIMEINPUT + pidof svkbd-sxmo || svkbd-sxmo & + TIMEINPUT="$( + echo " + 1h + 10m + 9m + 8m + 7m + 6m + 5m + 4m + 3m + 2m + 1m + 30s + Close Menu + " | awk 'NF' | awk '{$1=$1};1' | dmenu -p Timer -c -fn "Terminus-30" -l 20 + )" + pkill svkbd-sxmo + [ "Close Menu" = "$TIMEINPUT" ] && exit 0 + st -f Monospace-50 -e "$0" timerrun "$TIMEINPUT" } -[ $# -gt 0 ] && $@ || menu \ No newline at end of file +# shellcheck disable=SC2068 +if [ $# -gt 0 ]; then $@; else menu; fi \ No newline at end of file diff --git a/scripts/appscripts/sxmo_weather.sh b/scripts/appscripts/sxmo_weather.sh index fbe5f9a..ecefdd2 100755 --- a/scripts/appscripts/sxmo_weather.sh +++ b/scripts/appscripts/sxmo_weather.sh @@ -2,7 +2,7 @@ pidof svkbd-sxmo || svkbd-sxmo & ZIP=$( - echo -e " + printf %b " 10025 - NYC 60007 - Chicago 94016 - San Francisco @@ -15,9 +15,9 @@ ZIP=$( ) pkill svkbd-sxmo -LATLON=$(cat /usr/share/sxmo/zipcodes_for_weather.csv | grep "^$ZIP") -LAT=$(echo $LATLON | cut -d, -f2 | tr -d ' ') -LON=$(echo $LATLON | cut -d, -f3 | tr -d ' ') +LATLON="$(grep "^$ZIP" /usr/share/sxmo/zipcodes_for_weather.csv)" +LAT=$(echo "$LATLON" | cut -d, -f2 | tr -d ' ') +LON=$(echo "$LATLON" | cut -d, -f3 | tr -d ' ') URL="https://forecast.weather.gov/MapClick.php?lat=${LAT}&lon=${LON}&unit=0&lg=english&FcstType=text&TextType=1" st -f Monospace-20 -e w3m "$URL" diff --git a/scripts/appscripts/sxmo_youtube.sh b/scripts/appscripts/sxmo_youtube.sh index 3fbbed2..520142b 100755 --- a/scripts/appscripts/sxmo_youtube.sh +++ b/scripts/appscripts/sxmo_youtube.sh @@ -1,35 +1,35 @@ #!/usr/bin/env sh menu() { - pidof svkbd-sxmo || svkbd-sxmo & - SEARCHTERMS="$( - echo "Search term" | - dmenu -p "Yt Search" -c -l 10 -fn Terminus-20 - )" - pkill svkbd-sxmo + pidof svkbd-sxmo || svkbd-sxmo & + SEARCHTERMS="$( + echo "Search term" | + dmenu -p "Yt Search" -c -l 10 -fn Terminus-20 + )" + pkill svkbd-sxmo - IDIOTRESULTS="$(youtube-cli "$SEARCHTERMS")" - RESULT="$( - echo "$IDIOTRESULTS" | - grep -Ev '^(Channelid|Atom feed|Channel title|Published|Viewcount|Userid):' | - sed -E 's/^(URL|Duration):\s+/\t/g' | - tr -d '\n' | - sed 's/===/\n/g' | - gawk -F'\t' '{ print $3 " " $1 " " $2}' | - dmenu -c -l 10 -fn Terminus-20 - )" + IDIOTRESULTS="$(youtube-cli "$SEARCHTERMS")" + RESULT="$( + echo "$IDIOTRESULTS" | + grep -Ev '^(Channelid|Atom feed|Channel title|Published|Viewcount|Userid):' | + sed -E 's/^(URL|Duration):\s+/\t/g' | + tr -d '\n' | + sed 's/===/\n/g' | + gawk -F'\t' '{ print $3 " " $1 " " $2}' | + dmenu -c -l 10 -fn Terminus-20 + )" - [[ "CLOSE_MENU" == "$RESULT" ]] && exit 0 - URL=$(echo "$RESULT" | awk -F " " '{print $NF}') + [ "CLOSE_MENU" = "$RESULT" ] && exit 0 + URL=$(echo "$RESULT" | awk -F " " '{print $NF}') } video() { - menu - st -e mpv -v --ytdl-format='[height<420]' "$URL" + menu + st -e mpv -v --ytdl-format='[height<420]' "$URL" } audio() { - menu - st -e mpv -v --no-video "$URL" + menu + st -e mpv -v --no-video "$URL" } -$@ +$1