💾 Archived View for thrig.me › tech › gemini › gembro.patch captured on 2023-11-04 at 13:05:21.

View Raw

More Information

⬅️ Previous capture (2023-07-22)

-=-=-=-=-=-=-

diff --git main.go main.go
index 18e0831..595c2b1 100644
--- main.go
+++ main.go
@@ -19,6 +19,7 @@ import (
 	"syscall"
 	"time"
 
+	"suah.dev/protect"
 	"git.sr.ht/~rafael/gembro/gemini"
 	"git.sr.ht/~rafael/gembro/internal/bookmark"
 	"git.sr.ht/~rafael/gembro/internal/history"
@@ -48,6 +49,14 @@ var builtinBookmarks = []bookmark.Bookmark{
 }
 
 func main() {
+	// NOTE "clipboard" package wants to run xclip which is not allowed here
+	protect.Pledge("cpath inet rpath stdio tty unveil wpath")
+	hpath, _ := os.UserHomeDir()
+	protect.Unveil("/", "r")
+	protect.Unveil(filepath.Join(hpath, ".cache/gembro"), "crw")
+	protect.Unveil(filepath.Join(hpath, "tmp"), "crw")
+	protect.UnveilBlock()
+
 	cacheDir := flag.String("cache-dir", "", "Directory to store cache files (like cert info and bookmarks)")
 	debug := flag.String("debug-url", "", "Debug an URL")
 	logFile := flag.String("log-file", "", "File to output log to")
@@ -253,7 +262,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
 	case tea.KeyMsg:
 		keys := msg.String()
 		switch keys {
-		case "ctrl+c":
+		case "q":
 			return m, fireEvent(QuitEvent{})
 		case "tab":
 			num := (m.currentTab + 1) % len(m.tabs)
diff --git utils.go utils.go
index 27bb502..35876b2 100644
--- utils.go
+++ utils.go
@@ -33,14 +33,14 @@ func getExt(mediaType string) string {
 
 func suggestDownloadPath(title, url, mediaType string) string {
 	hpath, _ := os.UserHomeDir()
-	downloadDir := filepath.Join(hpath, "Downloads")
+	downloadDir := filepath.Join(hpath, "tmp")
 	if _, err := os.Stat(downloadDir); err == nil { // Dir exists
 		hpath = downloadDir
 	}
-	name := title
-	if name == "" {
-		name = path.Base(url)
-	}
+	//name := title
+	//if name == "" {
+		name := path.Base(url)
+	//}
 	var ext string
 	if i := strings.LastIndex(name, "."); i != -1 {
 		ext = name[i:]
diff --git viewport.go viewport.go
index 77f8ada..46e7dec 100644
--- viewport.go
+++ viewport.go
@@ -54,7 +54,8 @@ func NewViewport(startURL string, scrollPos int, h *history.History) Viewport {
 		startScroll: scrollPos,
 		spinner:     s,
 		history:     h,
-		footer:      NewFooter(buttonBack, buttonFwd, buttonHome, buttonBookmark, buttonDownload, buttonHelp, buttonQuit),
+		//footer:      NewFooter(buttonBack, buttonFwd, buttonHome, buttonBookmark, buttonDownload, buttonHelp, buttonQuit),
+		footer:      NewFooter(),
 	}
 }