From 658fd8a9bf4f4fe704ecd233eb44d95e42ada57a Mon Sep 17 00:00:00 2001
From: Siraaj Khandkar <siraaj@khandkar.net>
Date: Wed, 26 Apr 2023 12:27:12 -0400
Subject: [PATCH] Accept a name for dl and include starter script file

---
 home/lib/login_functions.sh | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/home/lib/login_functions.sh b/home/lib/login_functions.sh
index 4f62b82..56e0c2b 100644
--- a/home/lib/login_functions.sh
+++ b/home/lib/login_functions.sh
@@ -26,13 +26,30 @@ notify_done() {
     fi
 }
 
+_dl_script() {
+cat << EOF
+#! /bin/bash
+wget -c \$(< ./url)
+EOF
+}
+
 dl() {
+    local -r name="$1"
+    local -r url="$2"
+
     local -r timestamp="$(date --iso-8601=ns)"
-    local -r dir="$HOME"/dl/adhoc/"$timestamp"
+    local -r dir="$HOME"/dl/adhoc/"$timestamp"--"$name"
     local -r url_file_path="${dir}/url"
+    local -r dl_file_path="${dir}/dl"
 
     mkdir -p "$dir"
     touch "$url_file_path"
+    if [ "$url" != '' ]
+    then
+        echo "$url" > "$url_file_path"
+    fi
+    _dl_script > "$dl_file_path"
+    chmod +x "$dl_file_path"
     cd "$dir"
 }
 
-- 
2.20.1