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 @@
22 #
33 # basic confirmation dialog
44
5-if [ $# -eq 0 ]; then
5+if [[ $# -eq 0 ]]; then
66 echo "Usage: ask [COMMAND]"
77 exit 1
88 fi
99
10-gum confirm && $@ || echo "nope"
10+gum confirm && "$@" || echo "nope"
+2, -2
......@@ -1,7 +1,7 @@
11 #!/usr/bin/env bash
22
33 warning() {
4- if [[ "$*" =~ $(df . | awk {'print $1'} | tail -n1) ]]; then
4+ if [[ "$*" =~ $(df . | awk "{print $1}" | tail -n1) ]]; then
55 if ! gum confirm "WARNING: you are executing this command on your current drive! be careful!" --default="false" --timeout="15s"; then
66 echo "nope"
77 exit 1
......@@ -9,4 +9,4 @@ warning() {
99 fi
1010 }
1111
12-warning $@
12+warning "$@"
+1, -1
......@@ -6,7 +6,7 @@
66
77 word=$(echo " " | dmenu -i -c -l 10 -p "dictionary!")
88
9-if [ -n "$word" ]; then
9+if [[ -n "$word" ]]; then
1010 response=$(curl -s --connect-timeout 5 --max-time 10 "https://api.dictionaryapi.dev/api/v2/entries/en_US/$word")
1111 notif=$(echo "$response" | jq -r '[.[].meanings[] | {pos: .partOfSpeech, def: .definitions[].definition}] | .[:3].[] | "\n\(.pos). \(.def)"')
1212
+1, -1
......@@ -1,6 +1,6 @@
11 #!/usr/bin/env bash
22
3-if [ $# -eq 0 ]; then
3+if [[ $# -eq 0 ]]; then
44 echo "Usage: mksh [-b] [FILENAME]"
55 echo " --bin puts it in PATH"
66 echo " otherwise default to pwd"
+18, -6
......@@ -1,16 +1,28 @@
11 #!/usr/bin/env bash
22
3-if [ $# -eq 0 ]; then
3+if [[ $# -eq 0 ]]; then
44 echo "Usage: nag [MINUTES]"
55 exit 1
66 fi
77
8-DURATION=$(( "$1" * 60 ))
9-DURATION_M=$(( "$DURATION"/60%60 ))
8+NUM="$1"
109
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 ))
1117 MSG="it's been $DURATION_M minutes"
1218
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+}
1422
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
+1, -1
......@@ -20,5 +20,5 @@ password=$(printf '%s\n' "${password_files[@]}" | dmenu -i -c -l 10 "$@")
2020 if [[ $typeit -eq 0 ]]; then
2121 pass show -c "$password" 2>/dev/null
2222 else
23- pass show "$password" | { IFS= read -r pass; printf %s "$pass"; } | $xdotool
23+ pass show "$password" | { IFS= read -r pass; printf %s "$pass"; }
2424 fi
+1, -1
......@@ -22,7 +22,7 @@ end() {
2222
2323 cmd=$(printf "start\nend\n" | dmenu -i -c -l 2 -p "screen rec")
2424
25-if [ -z "$cmd" ]; then
25+if [[ -z "$cmd" ]]; then
2626 exit 0
2727 fi
2828
+4, -4
......@@ -2,13 +2,13 @@
22 #
33 # quickly share files
44
5-if [ $# -eq 0 ]; then
5+if [[ $# -eq 0 ]]; then
66 echo "Usage: share [FILENAME]"
77 exit 1
88 fi
99
10-FN_TEMP=$(uuidgen)_$(basename "${1// /_}")
10+upload_filename=$(uuidgen)_$(basename "${1// /_}")
1111
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
1313
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 @@
99 URL="$1"
1010 FILE_OUT_NAME="$2"
1111
12-if [ $# -eq 0 ]; then
12+if [[ $# -eq 0 || $# -ne 2 ]]; then
1313 echo "Usage: snsclip [URL] [FILENAME]"
1414 exit 1
1515 fi
+2, -2
......@@ -1,12 +1,12 @@
11 #!/usr/bin/env bash
22
33 # current date in ISO format
4-if [ $# -eq 0 ]; then
4+if [[ $# -eq 0 ]]; then
55 echo -e "$(date '+%Y-%m-%d')"
66 fi
77
88 # if you also want time then supply `time` arg:
99 # today time
10-if [ "$1" == "time" ]; then
10+if [[ "$1" == "time" ]]; then
1111 echo -e "$(date '+%Y-%m-%d__%I_%M%p')"
1212 fi
+1, -1
......@@ -2,7 +2,7 @@
22
33 URL="$1"
44
5-if [ $# -eq 0 ]; then
5+if [[ $# -eq 0 ]]; then
66 echo "Usage: ytbest [URL]"
77 exit 1
88 fi