Commit Diff


commit - 79d0b1c682aa0e077e1f1d413200f5a388768c28
commit + 112b904689ef18771a1bf710a36054681e5b9b54
blob - f3b0669094cf7628faa05efb8ddc03e1e9e26baf
blob + d2bd6acfe1bc0344ee93bf183dd3ba777a2e23e3
--- defaults.c
+++ defaults.c
@@ -26,7 +26,8 @@
 #include "telescope.h"
 #include "ui.h"
 
-char *new_tab_url = NULL;
+char	*download_path = NULL;
+char	*new_tab_url = NULL;
 
 int autosave = 20;
 int dont_wrap_pre = 0;
@@ -513,7 +514,10 @@ config_setvari(const char *var, int val)
 int
 config_setvars(const char *var, char *val)
 {
-	if (!strcmp(var, "new-tab-url")) {
+	if (!strcmp(var, "download-path")) {
+		free(download_path);
+		download_path = val;
+	} else if (!strcmp(var, "new-tab-url")) {
 		if (new_tab_url != NULL)
 			free(new_tab_url);
 		new_tab_url = val;
blob - aae4fb1d66e38db84b8a314c42c74059183477e8
blob + 3cba5204c6090a919e9696a2f3e47017b27aa334
--- defaults.h
+++ defaults.h
@@ -17,6 +17,7 @@
 #ifndef DEFAULTS_H
 #define DEFAULTS_H
 
+extern char	*download_path;
 extern char	*new_tab_url;
 
 extern int	 autosave;
blob - 990fb54da8d59910be7989f661dd0bb476603254
blob + 033bbbf0df103c110d8fd1e9184dc09f51133257
--- telescope.c
+++ telescope.c
@@ -416,8 +416,7 @@ handle_maybe_save_page(int dosave, struct tab *tab)
 	else
 		f++;
 
-	/* TODO: make base path customizable */
-	strlcpy(input, "/tmp/", sizeof(input));
+	strlcpy(input, download_path, sizeof(input));
 	strlcat(input, f, sizeof(input));
 
 	ui_read("Save to path", handle_save_page_path, tab, input);
@@ -1132,6 +1131,10 @@ main(int argc, char * const *argv)
 		exit(0);
 	}
 
+	if (download_path == NULL &&
+	    (download_path = strdup("/tmp/")) == NULL)
+		errx(1, "strdup");
+
 	fs_init();
 	if ((sessionfd = lock_session()) == -1)
 		errx(1, "can't lock session, is another instance of "