Commit 4936460
xxwhirlpool
·
2026-03-18 11:08:06 -0400 EDT
parent 96382a2
script cleanup; fix up `nag` a lil
11 files changed,
+34,
-22
+2,
-2
| ... | ... | @@ -2,9 +2,9 @@ | |
| 2 | 2 | # | |
| 3 | 3 | # basic confirmation dialog | |
| 4 | 4 | ||
| 5 | - | if [ $# -eq 0 ]; then | |
| 5 | + | if [[ $# -eq 0 ]]; then | |
| 6 | 6 | echo "Usage: ask [COMMAND]" | |
| 7 | 7 | exit 1 | |
| 8 | 8 | fi | |
| 9 | 9 | ||
| 10 | - | gum confirm && $@ || echo "nope" | |
| 10 | + | gum confirm && "$@" || echo "nope" |
+2,
-2
| ... | ... | @@ -1,7 +1,7 @@ | |
| 1 | 1 | #!/usr/bin/env bash | |
| 2 | 2 | ||
| 3 | 3 | warning() { | |
| 4 | - | if [[ "$*" =~ $(df . | awk {'print $1'} | tail -n1) ]]; then | |
| 4 | + | if [[ "$*" =~ $(df . | awk "{print $1}" | tail -n1) ]]; then | |
| 5 | 5 | if ! gum confirm "WARNING: you are executing this command on your current drive! be careful!" --default="false" --timeout="15s"; then | |
| 6 | 6 | echo "nope" | |
| 7 | 7 | exit 1 |
+1,
-1
| ... | ... | @@ -6,7 +6,7 @@ | |
| 6 | 6 | ||
| 7 | 7 | word=$(echo " " | dmenu -i -c -l 10 -p "dictionary!") | |
| 8 | 8 | ||
| 9 | - | if [ -n "$word" ]; then | |
| 9 | + | if [[ -n "$word" ]]; then | |
| 10 | 10 | response=$(curl -s --connect-timeout 5 --max-time 10 "https://api.dictionaryapi.dev/api/v2/entries/en_US/$word") | |
| 11 | 11 | notif=$(echo "$response" | jq -r '[.[].meanings[] | {pos: .partOfSpeech, def: .definitions[].definition}] | .[:3].[] | "\n\(.pos). \(.def)"') | |
| 12 | 12 |
+1,
-1
| ... | ... | @@ -1,6 +1,6 @@ | |
| 1 | 1 | #!/usr/bin/env bash | |
| 2 | 2 | ||
| 3 | - | if [ $# -eq 0 ]; then | |
| 3 | + | if [[ $# -eq 0 ]]; then | |
| 4 | 4 | echo "Usage: mksh [-b] [FILENAME]" | |
| 5 | 5 | echo " --bin puts it in PATH" | |
| 6 | 6 | echo " otherwise default to pwd" |
+18,
-6
| ... | ... | @@ -1,16 +1,28 @@ | |
| 1 | 1 | #!/usr/bin/env bash | |
| 2 | 2 | ||
| 3 | - | if [ $# -eq 0 ]; then | |
| 3 | + | if [[ $# -eq 0 ]]; then | |
| 4 | 4 | echo "Usage: nag [MINUTES]" | |
| 5 | 5 | exit 1 | |
| 6 | 6 | fi | |
| 7 | 7 | ||
| 8 | - | DURATION=$(( "$1" * 60 )) | |
| 9 | - | DURATION_M=$(( "$DURATION"/60%60 )) | |
| 8 | + | NUM="$1" | |
| 10 | 9 | ||
| 10 | + | if [[ ! $NUM =~ ^[0-9]+$ ]]; then | |
| 11 | + | echo "duration cannot be a decimal" | |
| 12 | + | exit 1 | |
| 13 | + | fi | |
| 14 | + | ||
| 15 | + | DURATION=$(( "$NUM" * 60 )) | |
| 16 | + | DURATION_M=$(( "$DURATION"/60%60 )) | |
| 11 | 17 | MSG="it's been $DURATION_M minutes" | |
| 12 | 18 | ||
| 13 | - | notify-send "you'll get a reminder every $DURATION_M minutes" | |
| 19 | + | notif() { | |
| 20 | + | notify-send "$MSG" && sleep 1 && spd-say -t female3 "$MSG" | |
| 21 | + | } | |
| 14 | 22 | ||
| 15 | - | sleep "$DURATION" | |
| 16 | - | notify-send "$MSG" && sleep 1 && spd-say -t female3 "$MSG" | |
| 23 | + | logic() { | |
| 24 | + | notify-send "you'll get a reminder every $DURATION_M minutes" | |
| 25 | + | sleep "$DURATION" && notif | |
| 26 | + | } | |
| 27 | + | ||
| 28 | + | logic |
| ... | ... | @@ -20,5 +20,5 @@ password=$(printf '%s\n' "${password_files[@]}" | dmenu -i -c -l 10 "$@") | |
| 20 | 20 | if [[ $typeit -eq 0 ]]; then | |
| 21 | 21 | pass show -c "$password" 2>/dev/null | |
| 22 | 22 | else | |
| 23 | - | pass show "$password" | { IFS= read -r pass; printf %s "$pass"; } | $xdotool | |
| 23 | + | pass show "$password" | { IFS= read -r pass; printf %s "$pass"; } | |
| 24 | 24 | fi |
+1,
-1
| ... | ... | @@ -22,7 +22,7 @@ end() { | |
| 22 | 22 | ||
| 23 | 23 | cmd=$(printf "start\nend\n" | dmenu -i -c -l 2 -p "screen rec") | |
| 24 | 24 | ||
| 25 | - | if [ -z "$cmd" ]; then | |
| 25 | + | if [[ -z "$cmd" ]]; then | |
| 26 | 26 | exit 0 | |
| 27 | 27 | fi | |
| 28 | 28 |
| ... | ... | @@ -2,13 +2,13 @@ | |
| 2 | 2 | # | |
| 3 | 3 | # quickly share files | |
| 4 | 4 | ||
| 5 | - | if [ $# -eq 0 ]; then | |
| 5 | + | if [[ $# -eq 0 ]]; then | |
| 6 | 6 | echo "Usage: share [FILENAME]" | |
| 7 | 7 | exit 1 | |
| 8 | 8 | fi | |
| 9 | 9 | ||
| 10 | - | FN_TEMP=$(uuidgen)_$(basename "${1// /_}") | |
| 10 | + | upload_filename=$(uuidgen)_$(basename "${1// /_}") | |
| 11 | 11 | ||
| 12 | - | rsync -avzqp --chmod=664 "$1" athena:/var/www/stash/pics/dump/"$FN_TEMP" || exit 1 | |
| 12 | + | rsync -avzqp --chmod=664 "$1" athena:/var/www/stash/pics/dump/"$upload_filename" || exit 1 | |
| 13 | 13 | ||
| 14 | - | echo "https://stash.4-walls.net/pics/dump/$FN_TEMP" | lolcat | |
| 14 | + | echo "https://stash.4-walls.net/pics/dump/$upload_filename" | lolcat |
+1,
-1
| ... | ... | @@ -9,7 +9,7 @@ | |
| 9 | 9 | URL="$1" | |
| 10 | 10 | FILE_OUT_NAME="$2" | |
| 11 | 11 | ||
| 12 | - | if [ $# -eq 0 ]; then | |
| 12 | + | if [[ $# -eq 0 || $# -ne 2 ]]; then | |
| 13 | 13 | echo "Usage: snsclip [URL] [FILENAME]" | |
| 14 | 14 | exit 1 | |
| 15 | 15 | fi |
+2,
-2
| ... | ... | @@ -1,12 +1,12 @@ | |
| 1 | 1 | #!/usr/bin/env bash | |
| 2 | 2 | ||
| 3 | 3 | # current date in ISO format | |
| 4 | - | if [ $# -eq 0 ]; then | |
| 4 | + | if [[ $# -eq 0 ]]; then | |
| 5 | 5 | echo -e "$(date '+%Y-%m-%d')" | |
| 6 | 6 | fi | |
| 7 | 7 | ||
| 8 | 8 | # if you also want time then supply `time` arg: | |
| 9 | 9 | # today time | |
| 10 | - | if [ "$1" == "time" ]; then | |
| 10 | + | if [[ "$1" == "time" ]]; then | |
| 11 | 11 | echo -e "$(date '+%Y-%m-%d__%I_%M%p')" | |
| 12 | 12 | fi |
+1,
-1