shithub: view

Download patch

ref: ac1a4e7dbe0b0c96054aee63bdd167636e857b85
parent: d0c5e1bb15cdd6d57bef2c1086b87c48d9c0adcd
author: phil9 <telephil9@gmail.com>
date: Tue Nov 30 14:44:09 EST 2021

set window label to image filename

--- a/view.c
+++ b/view.c
@@ -39,6 +39,7 @@
 Image *img;
 Point pos;
 int zoomlevel;
+int lfd;
 
 const char* zoomlevels[] = {
 	"25%", "33%", "50%", "75%",
@@ -104,6 +105,14 @@
 void zoom(void);
 
 void
+setlabel(char *label)
+{
+	if(lfd < 0)
+		return;
+	fprint(lfd, "%s", label);
+}
+
+void
 setimage(Image *i, int move)
 {
 	if(img != nil && img != orig){
@@ -131,6 +140,7 @@
 		return -1;
 	zoomlevel = Defaultzoomlevel;
 	setimage(i, 1);
+	setlabel(filename);
 	return 0;
 }
 
@@ -438,6 +448,7 @@
 
 	img = nil;
 	zoomlevel = Defaultzoomlevel;
+	lfd = open("/dev/label", OWRITE);
 	ARGBEGIN{
 	default:
 		usage();