Commit Diff


commit - 2558835daf6d88dc06ff5bf0232ea0ce6c692a25
commit + 3800af5fe26a13e289a4fa244c885adcf443991d
blob - df2427807396d46bfba7ba639269b976f61e4255
blob + a89850f02eb5f480df473ac7c0c503382251210d
--- modules/mixins/dotfiles/bin/monofetch
+++ modules/mixins/dotfiles/bin/monofetch
@@ -3,6 +3,11 @@
 crawl=0
 depth=3
 
+notify() {
+	[[ "$crawl" -eq 1 ]] && return
+	notify-send "$@"
+}
+
 while [[ "$1" == -* ]]; do
 	case "$1" in
 	-c | --crawl)
@@ -14,7 +19,7 @@ while [[ "$1" == -* ]]; do
 		shift 2
 		;;
 	*)
-		notify-send -u critical "Error" "Unknown option: $1"
+		notify -u critical "Error" "Unknown option: $1"
 		exit 1
 		;;
 	esac
@@ -28,12 +33,12 @@ else
 fi
 
 if [[ -z "$url" ]]; then
-	notify-send "No URL found"
+	notify "No URL found"
 	exit 1
 fi
 
 if [[ ! "$url" =~ ^https?:// ]]; then
-	notify-send "Invalid URL format" "$url"
+	notify "Invalid URL format" "$url"
 	exit 1
 fi
 
@@ -71,38 +76,38 @@ save_url() {
 	target_md_path="$HOME/misc/notes/www/$md_filename"
 
 	mkdir -p "$target_dir" || {
-		notify-send -u critical "Error" "Failed to create directory"
+		notify -u critical "Error" "Failed to create directory"
 		return 1
 	}
 	if monolith -o "$target_file_path" "$url"; then
-		[[ "$quiet" -eq 0 ]] && notify-send "Saved" "$url"
+		[[ "$quiet" -eq 0 ]] && notify "Saved" "$url"
 	else
-		notify-send -u critical "Error" "Failed to download $url"
+		notify -u critical "Error" "Failed to download $url"
 		return 1
 	fi
 
 	cat "$target_file_path" | html2markdown >"$target_md_path"
 
 	if [[ ! -s "$target_md_path" ]]; then
-		notify-send -u critical "Error" "Conversion failed"
+		notify -u critical "Error" "Conversion failed"
 	fi
 }
 
 if [[ "$crawl" -eq 1 ]]; then
 	if ! command -v katana >/dev/null 2>&1; then
-		notify-send -u critical "Error" "katana not found in PATH"
+		notify -u critical "Error" "katana not found in PATH"
 		exit 1
 	fi
 
 	tmp_urls=$(mktemp)
 	trap 'rm -f "$tmp_urls"' EXIT
 
-	notify-send "Crawling" "$url"
-	printf 'Crawling %s (depth %s)…\n' "$url" "$depth"
+	notify "Crawling" "$url"
+	printf 'Crawling %s (depth %s)\n' "$url" "$depth"
 	katana -u "$url" -d "$depth" -silent -nc >"$tmp_urls"
 
 	if [[ ! -s "$tmp_urls" ]]; then
-		notify-send -u critical "Error" "Katana found no URLs"
+		notify -u critical "Error" "Katana found no URLs"
 		exit 1
 	fi
 
@@ -116,7 +121,7 @@ if [[ "$crawl" -eq 1 ]]; then
 		fi
 	done <"$tmp_urls"
 
-	notify-send "Crawled" "Saved $count pages from $url"
+	notify "Crawled" "Saved $count pages from $url"
 	printf 'Done: saved %d pages from %s\n' "$count" "$url"
 else
 	save_url "$url"