diff -ru feh-1.2.6/src/Makefile.am feh-1.2.6-an-screenlock/src/Makefile.am
--- feh-1.2.6/src/Makefile.am	2003-02-23 17:24:20.000000000 +0100
+++ feh-1.2.6-an-screenlock/src/Makefile.am	2004-09-21 12:20:14.915122208 +0200
@@ -16,7 +16,7 @@
 utils.c utils.h keyevents.c timers.c timers.h list.c collage.c debug.h \
 events.c events.h support.c support.h \
 thumbnail.c thumbnail.h ipc.c ipc.h
-feh_LDADD         = -lX11 @IMLIB_LIBS@ @GIBLIB_LIBS@
+feh_LDADD         = -lX11 @IMLIB_LIBS@ @GIBLIB_LIBS@ -lcrypt
 
 images_DATA = about.png menubg_default.png menubg_sky.png \
 menubg_chrome.png menubg_brushed.png \
diff -ru feh-1.2.6/src/feh.h feh-1.2.6-an-screenlock/src/feh.h
--- feh-1.2.6/src/feh.h	2003-02-23 17:34:47.000000000 +0100
+++ feh-1.2.6-an-screenlock/src/feh.h	2004-09-21 12:26:49.460142248 +0200
@@ -57,6 +57,12 @@
 #include <sys/wait.h>
 #include <math.h>
 
+
+#define _XOPEN_SOURCE
+#include <unistd.h>
+#include <shadow.h>
+
+
 #include <Imlib2.h>
 #include <giblib/giblib.h>
 
diff -ru feh-1.2.6/src/keyevents.c feh-1.2.6-an-screenlock/src/keyevents.c
--- feh-1.2.6/src/keyevents.c	2003-05-23 15:23:42.000000000 +0200
+++ feh-1.2.6-an-screenlock/src/keyevents.c	2004-09-21 13:46:31.460167744 +0200
@@ -29,10 +29,24 @@
 #include "winwidget.h"
 #include "options.h"
 
+int
+feh_check_passwd( char* pass )
+{
+	char		*cpass = NULL;
+	
+	cpass = crypt( pass, opt.screen_lock_pass );
+//	printf( "DEBUG: Crypted password: %s\n", cpass );
+	if( !strcmp( opt.screen_lock_pass, cpass ) ){
+		return( 1 );
+	}
+	return( 0 );
+}
+
 void
 feh_event_handle_keypress(XEvent * ev)
 {
    int len;
+   int tlen;
    char kbuf[20];
    KeySym keysym;
    XKeyEvent *kev;
@@ -53,6 +67,34 @@
    kev = (XKeyEvent *) ev;
    len = XLookupString(&ev->xkey, (char *) kbuf, sizeof(kbuf), &keysym, NULL);
 
+   if (opt.screen_lock){
+	/* for testing /
+	if( keysym == XK_Escape ){
+		winwidget_destroy_all();
+	}
+	/* end testing */
+	if( keysym == XK_Return ){
+		if( feh_check_passwd( opt.screen_lock_typed ) ){
+//		if( !strcmp (opt.screen_lock_pass, opt.screen_lock_typed) ) {
+			winwidget_destroy_all();
+		} else {
+			opt.screen_lock_typed[ 0 ] = 0;
+		}
+		D_RETURN_(4);
+	}
+	   
+	/* capture keys for password comparison */
+	tlen=strlen(opt.screen_lock_typed);
+	if( tlen<15 ){
+		if( isascii( kbuf[0] ) ){
+			opt.screen_lock_typed[ tlen ] = kbuf[0];
+			opt.screen_lock_typed[ tlen+1 ] = 0;
+			//         printf( "Key so far: >>%s<<\n", opt.screen_lock_typed );
+		}
+	}  
+	D_RETURN_(4);
+   }
+   
    /* menus are showing, so this is a menu control keypress */
    if (ev->xbutton.window == menu_cover) {
      selected_item = feh_menu_find_selected_r(menu_root, &selected_menu);
@@ -160,7 +202,7 @@
      D_RETURN_(4);
    }
    
-   
+
    switch (keysym)
    {
      case XK_Left:
diff -ru feh-1.2.6/src/main.c feh-1.2.6-an-screenlock/src/main.c
--- feh-1.2.6/src/main.c	2003-02-23 17:34:47.000000000 +0100
+++ feh-1.2.6-an-screenlock/src/main.c	2004-09-21 13:55:11.905048096 +0200
@@ -43,6 +43,8 @@
 
    init_parse_options(argc, argv);
 
+	/* drop root privileges */
+	setuid( getuid( ) );	/* getuid gets the _real_ uid, setuid sets the _effective_ uid */
    init_x_and_imlib();
 
    feh_event_init();
diff -ru feh-1.2.6/src/options.c feh-1.2.6-an-screenlock/src/options.c
--- feh-1.2.6/src/options.c	2003-04-11 12:34:18.000000000 +0200
+++ feh-1.2.6-an-screenlock/src/options.c	2004-09-21 13:58:23.110980376 +0200
@@ -76,6 +76,9 @@
 
    opt.xinerama = 0;
    opt.screen_clip = 1;
+   opt.screen_lock = 0;
+   opt.screen_lock_pass = "qPfnQ7bvq2/zg";
+   opt.screen_lock_typed[0] = 0;
 #ifdef HAVE_LIBXINERAMA
    /* if we're using xinerama, then enable it by default */
    opt.xinerama = 1;
@@ -393,6 +396,7 @@
       {"menu-border", 1, 0, 208},
       {"caption-path", 1, 0, 209},
       {"no-jump-on-resort",0,0,210},
+      {"screen-lock", 1, 0, 211},	/* CHECK: assign a different number ? */
       {0, 0, 0, 0}
    };
    int optch = 0, cmdx = 0, i = 0;
@@ -679,6 +683,33 @@
 	case 210:
            opt.no_jump_on_resort = 1;
            break;
+        case 211:
+           opt.screen_lock = atoi(optarg);
+		if( opt.screen_lock ){
+			char		*username = NULL;
+			struct passwd	*pwd = NULL;
+			struct spwd	*pwds = NULL;
+				
+			/* get the username */
+			username = getenv( "LOGNAME" );
+			/* get the passwd entry */
+			pwd = getpwnam( username );
+			if( !strcmp( pwd->pw_passwd, "x" ) ){
+				/* system uses shadow passwd */
+				pwds = getspnam( username );
+				if( !pwds ){
+					/* can't access shadow passwords :( */
+					printf( "On systems with shadow passwd, feh needs to be set uid root.\n" );
+					/* allow exit without passwd check to keep user from locking himself out of the system */
+					exit( 1 );
+				}
+				opt.screen_lock_pass = pwds->sp_pwdp;
+			}else{
+				opt.screen_lock_pass = pwd->pw_passwd;
+			}
+			
+		}
+           break;
         default:
            break;
       }
@@ -958,6 +989,7 @@
            "                            size.  WARNING: with this option disabled,\n"
            "                            image windows could become very large, making\n"
            "                            them unmanageable in certain window managers.\n."
+           "      --screen-lock [0|1]   Enable/disable window locking.\n"
            " FORMAT SPECIFIERS\n"
            "                            %%f image path/filename\n"
            "                            %%n image name\n"
diff -ru feh-1.2.6/src/options.h feh-1.2.6-an-screenlock/src/options.h
--- feh-1.2.6/src/options.h	2003-04-11 12:34:18.000000000 +0200
+++ feh-1.2.6-an-screenlock/src/options.h	2004-09-21 13:46:07.644788232 +0200
@@ -66,6 +66,9 @@
    unsigned char bgmode;
    unsigned char xinerama;
    unsigned char screen_clip;
+   unsigned char screen_lock;
+   unsigned char *screen_lock_pass;
+   unsigned char screen_lock_typed[16];
 
    char *output_file;
    char *output_dir;
diff -ru feh-1.2.6/src/winwidget.c feh-1.2.6-an-screenlock/src/winwidget.c
--- feh-1.2.6/src/winwidget.c	2003-04-11 12:46:50.000000000 +0200
+++ feh-1.2.6-an-screenlock/src/winwidget.c	2004-09-01 21:05:29.000000000 +0200
@@ -52,6 +52,7 @@
   ret->im_angle = 0;
   ret->bg_pmap = 0;
   ret->bg_pmap_cache = 0;
+  ret->cursor_lock = 0;
   ret->im = NULL;
   ret->name = NULL;
   ret->file = NULL;
@@ -261,6 +262,12 @@
   XSetCommand(disp, ret->win, cmdargv, cmdargc);
 
   winwidget_register(ret);
+
+  if (opt.screen_lock){
+    /* create the cursor used for locking */
+    ret->cursor_lock = XCreateFontCursor(disp, XC_circle);	/* PLAN: use a user supplied icon or hide the cursor */
+    XDefineCursor(disp, ret->win, ret->cursor_lock);
+  }
   D_RETURN_(4);
 }
 
@@ -634,6 +641,13 @@
     XFreePixmap(disp, winwid->bg_pmap);
     winwid->bg_pmap = None;
   }
+  if (opt.screen_lock){
+    XUngrabPointer(disp, CurrentTime );
+    XUngrabKeyboard(disp, CurrentTime );
+  }
+  if (winwid->cursor_lock) {
+    XFreeCursor(disp, winwid->cursor_lock);
+  }
   D_RETURN_(4);
 }
 
@@ -719,6 +733,12 @@
     XMaskEvent(disp, StructureNotifyMask, &ev);
     D(4, ("Window mapped\n"));
     winwid->visible = 1;
+    if (opt.screen_lock){
+      /* grab the pointer */
+      XGrabPointer(disp, winwid->win, False, ButtonPressMask|ButtonReleaseMask|PointerMotionMask, GrabModeAsync, GrabModeAsync, winwid->win, winwid->cursor_lock, CurrentTime );
+      /* grab the keyboard */
+      XGrabKeyboard(disp, winwid->win, False, GrabModeAsync, GrabModeAsync, CurrentTime );
+    }
   }
   D_RETURN_(4);
 }
@@ -990,6 +1010,9 @@
   unsigned int c;
   Window r;
 
+  if (opt.screen_lock) {
+	return;
+  }
   XQueryPointer(disp, winwid->win, &r, &r, &x, &y, &b, &b, &c);
   if (winwid->type == WIN_TYPE_ABOUT)
   {
diff -ru feh-1.2.6/src/winwidget.h feh-1.2.6-an-screenlock/src/winwidget.h
--- feh-1.2.6/src/winwidget.h	2003-02-23 17:34:47.000000000 +0100
+++ feh-1.2.6-an-screenlock/src/winwidget.h	2004-09-01 21:05:29.000000000 +0200
@@ -30,6 +30,7 @@
 
 # include <X11/X.h>
 # include <X11/Xproto.h>
+# include <X11/cursorfont.h>
 
 /* Motif window hints */
 #define MWM_HINTS_FUNCTIONS     (1L << 0)
@@ -91,6 +92,7 @@
    GC gc;
    Pixmap bg_pmap;
    Pixmap bg_pmap_cache;
+   Cursor	cursor_lock;
    char *name;
    gib_list *file;
    unsigned char visible;
