Hi to all dvtm users,
   i wrote a little'n simple routine which allow to lock the screen
until a passphrase has been inserted. It's doesn't deal with encrypted
key (that's because i don't need it; it's quite easy to implement, btw).
I hope someone else (other than me) will found it useful too.

In the attached patch i also removed the draw() function which is unused
at all.

Hope this help.

-- 
Claudio M. Alessi

-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/MU d-@ s: a--> C++(+++) UB++>$ P+> !L E--- W++(+++)
N+@ o--> K? w+@> O-@> M- V? PS+@ PE+@ Y+ PGP> t(-)@ 5?
X+ R? tv-- b+> DI-- D? G e+@> h--@> r y*
------END GEEK CODE BLOCK------

--- dvtm.c.orig	2008-05-31 13:37:04.884264616 +0200
+++ dvtm.c	2008-05-31 13:35:22.185846371 +0200
@@ -108,6 +108,7 @@
 void setlayout(const char *args[]);
 void redraw(const char *args[]);
 void zoom(const char *args[]);
+void lock(const char *key[]);
 
 #if defined(HANDLE_MOUSE)
 void mouse_focus(const char *args[]);
@@ -466,13 +467,6 @@
 }
 
 void
-draw(Client *c){
-	draw_content(c);
-	draw_border(c);
-	wrefresh(c->window);
-}
-
-void
 clear_workspace(){
 	unsigned int y;
 	for(y = 0; y < wah; y++)
@@ -545,6 +539,39 @@
 	}
 }
 
+/*
+ * Lock the screen until the key is typed
+ *
+ * NOTE: this function doesn't handle the input from clients. All
+ *       foreground operations are temporarly suspended since the
+ *       function doesn't return (screen is unlocked). Also there
+ *       is no password enc/dec handling (needed?).
+*/
+void
+lock(const char *key[])
+{
+   size_t size = strlen(key[0]);
+   int i = 0;
+
+   if( ! size )
+      return;
+
+   erase();
+   curs_set(0);
+   mvprintw(LINES / 2, COLS / 2 - 7, "Screen locked!");
+
+   while( i != (int)size ) {
+
+      for(i = 0; i < (int)size; i++) {
+         if( getch() != key[0][i] )
+            break;
+      }
+   }
+
+   arrange();
+
+} /* eof lock() */
+
 void
 killclient(const char *args[]){
 	if(!sel)
--- config.h.orig	2008-05-31 13:37:04.884264616 +0200
+++ config.h	2008-05-31 13:35:22.197847122 +0200
@@ -56,6 +56,7 @@
 
 /* you can at most specifiy MAX_ARGS (2) number of arguments */
 Key keys[] = {
+	{ MOD, 'X', { lock,           { "test" }  } },
 	{ MOD, 'c', { create,         { NULL }    } },
 	{ MOD, 'x', { killclient,     { NULL }    } },
 	{ MOD, 'j', { focusnext,      { NULL }    } },

Reply via email to