You are not logged in.

#1 2010-12-26 12:18:19

Revelation60
Member
From: The Netherlands
Registered: 2009-03-19
Posts: 158
Website

sflock: simple X screen locker with basic user feedback

There are several applications out there that lock the X display. On the one side of the spectrum you have xscreensaver and xlockmore which provide screensavers and on the other side you have slock which provides nothing. sflock is an application that is built as an extension to slock, which provides very basic user feedback.

The need for me arrived because I wanted a screen locker that was trustworthy and that looks ok. Because I have no interest in screensavers and the xscreensaver unlock screen is one of the most ugly things I have ever seen, I turned to slock. This works fine, but there is no real way to tell that the screen is locked.  You just type a password on a black screen and if it's correct, the screen gets unlocked. fslock (at least the first version) shows a line on the screen and displays asterisks for every character entered.

The goal of the application is to be simple and small, but still look good. You can install sflock from the AUR under the name sflock-git or download it directly from github. Suggestions are of course welcome. smile

Offline

#2 2010-12-26 13:12:59

lymphatik
Member
From: Somewhere else
Registered: 2009-03-07
Posts: 119

Re: sflock: simple X screen locker with basic user feedback

There is also i3lock that might do what you want ^^

But good to know, there is another alternative.

Last edited by lymphatik (2010-12-26 13:22:22)

Offline

#3 2010-12-26 13:28:41

hut
Member
From: Hanover, Germany
Registered: 2010-03-12
Posts: 569
Website

Re: sflock: simple X screen locker with basic user feedback

Revelation60 wrote:

I turned to slock. This works fine, but there is no real way to tell that the screen is locked.  You just type a password on a black screen and if it's correct, the screen gets unlocked.

Btw. if you enable beeping (e.g. with alsamixer), slock beeps when you press enter.


"hut_" or "h00th00t" in irc.freenode.net #archlinux
Ranger Mailing List: https://lists.nongnu.org/mailman/listinfo/ranger-users

Offline

#4 2010-12-26 13:54:21

Revelation60
Member
From: The Netherlands
Registered: 2009-03-19
Posts: 158
Website

Re: sflock: simple X screen locker with basic user feedback

Btw. if you enable beeping (e.g. with alsamixer), slock beeps when you press enter.

I personally hate bleeps. I have left it in sflock for now, but I might remove it and set the background to red on a failed attempt.

edit: done.

Last edited by Revelation60 (2010-12-26 15:55:01)

Offline

#5 2010-12-26 20:32:05

Sirsurthur
Member
Registered: 2009-02-02
Posts: 124

Re: sflock: simple X screen locker with basic user feedback

Hi,

I tested it and it's nice and working good. One question thought : should the red color remain or just blink one time ?

Thanks again,
Sirsurthur

Offline

#6 2010-12-26 21:47:10

Revelation60
Member
From: The Netherlands
Registered: 2009-03-19
Posts: 158
Website

Re: sflock: simple X screen locker with basic user feedback

I have been thinking about that too. If the color remains red, you can see an intrusion attempt when you return to your computer. Flashing on the other hand is more calm for the eyes in the long run. Maybe I should make a command line option?

Offline

#7 2010-12-27 12:17:06

jlcordeiro
Member
From: Portugal
Registered: 2009-05-23
Posts: 76

Re: sflock: simple X screen locker with basic user feedback

My new X screen locker smile

I used slock before but I had a little problem with it. It was so simple that I could never tell if screen was locked or if monitor was idle. And typing my password when it was just idle and with a IM chat in front is not pleasant...


Thank you very much

Offline

#8 2010-12-29 22:11:31

ninian
Member
From: United Kingdom
Registered: 2008-02-24
Posts: 726
Website

Re: sflock: simple X screen locker with basic user feedback

Revelation60 wrote:

If the color remains red, you can see an intrusion attempt when you return to your computer.

Thank you very much for this little program - it seems to work very well.
I'd agree that it's important to see whether there has been an intrusion attempt.
I suppose you could have a command line option to set the password character to something other than the default '*', for example:

-c <char>

Offline

#9 2010-12-30 22:30:34

Revelation60
Member
From: The Netherlands
Registered: 2009-03-19
Posts: 158
Website

Re: sflock: simple X screen locker with basic user feedback

I have added options to modify the font, the password character and the vertical offset of the bar. The last is useful, because the bar may overlap the password characters if the font is different.

Example:

sflock -c \I -f  "-*-verdana-*-r-*-*-*-420-100-100-*-*-*-*" -b 60

Uses capital i for character, Verdana as font and the bar offset is 60.

Last edited by Revelation60 (2010-12-30 23:49:32)

Offline

#10 2010-12-30 23:26:34

silenc3r
Member
From: Poland
Registered: 2009-08-29
Posts: 149

Re: sflock: simple X screen locker with basic user feedback

That doesn't work for me

sudo ./sflock -c \I -f  "-*-verdana-*-r-*-*-*-420-100-100-*-*-*-*" -b 60

I get

sudo: ./sflock: command not found

Offline

#11 2010-12-30 23:30:34

Revelation60
Member
From: The Netherlands
Registered: 2009-03-19
Posts: 158
Website

Re: sflock: simple X screen locker with basic user feedback

oops, you should just use sflock:

sflock -c \I -f  "-*-verdana-*-r-*-*-*-420-100-100-*-*-*-*" -b 60

I did the testing in my project folder, so that's why I had the ./ in front of it.

Offline

#12 2011-01-01 22:39:41

Hiato
Member
Registered: 2009-01-21
Posts: 76

Re: sflock: simple X screen locker with basic user feedback

I have long wanted something slightly more than slock, but far less than xscreensaver - yet another archer making a nice solution. However, I thought that perhaps it would be nice to know when and how many times an incorrect password was entered. So, here's what I hacked up (allow me to apologise beforehand for whatever mistakes there may be in this patch - I actually have yet to learn how to code in C)

11a12
> #include <time.h>
67a69
>     time_t atmpt;
222,223c224,225
<                     if (running != 0)
<                         // change bakground on wrong password
---
>                     if (running != 0) {
>                         // change bakground on wrong password and print time of attempt
225c227,229
<                     len = 0;
---
>                         atmpt=time(NULL);
>                         printf("Password mismatch at %s",ctime(&atmpt));
>                     } len = 0;

It does compile, but I haven't tested it yet. Perhaps, instead of forcing the user to redirect stdout (or error), it should dump to some log - but this seems the most flexable way to do it.

EDIT: I happen to notice that in your makefile you had "@chmod 755 ...\n @chmod u+s ..." ==> "@chmod 4755 ..." ;]

Last edited by Hiato (2011-01-01 22:45:16)

Offline

#13 2011-01-09 21:23:06

some-guy94
Member
Registered: 2009-08-15
Posts: 360

Re: sflock: simple X screen locker with basic user feedback

I've been trying to get this to use Xft for rendering the fonts, but this is essentially my first time doing anything in C. Sflock builds properly but segfaults when I try to run it.

diff --git a/config.mk b/config.mk
index 3a42077..b6a72ed 100644
--- a/config.mk
+++ b/config.mk
@@ -12,8 +12,8 @@ X11INC = /usr/X11R6/include
 X11LIB = /usr/X11R6/lib
 
 # includes and libs
-INCS = -I. -I/usr/include -I${X11INC}
-LIBS = -L/usr/lib -lc -lcrypt -L${X11LIB} -lX11 -lXext
+INCS = -I. -I/usr/include -I${X11INC} -I/usr/include/freetype2
+LIBS = -L/usr/lib -lc -lcrypt -L${X11LIB} -lX11 -lXext -lXft
 
 # flags
 CPPFLAGS = -DVERSION=\"${VERSION}\" -DHAVE_SHADOW_H
diff --git a/sflock.c b/sflock.c
index 72b076b..3c51823 100644
--- a/sflock.c
+++ b/sflock.c
@@ -12,10 +12,12 @@
 #include <string.h>
 #include <unistd.h>
 #include <sys/types.h>
+#include <fontconfig/fontconfig.h>
 #include <X11/keysym.h>
 #include <X11/Xlib.h>
 #include <X11/Xutil.h>
 #include <X11/extensions/dpms.h>
+#include <X11/Xft/Xft.h>
 
 #if HAVE_BSD_AUTH
 #include <login_cap.h>
@@ -79,7 +81,10 @@ main(int argc, char **argv) {
     XColor black, red, dummy;
     XEvent ev;
     XSetWindowAttributes wa;
-    XFontStruct* font;
+    XftFont *font;
+    XftColor *xftcolor;
+    XftDraw *xftdraw;
+    XGlyphInfo *extents;
     GC gc; 
     XGCValues values;
 
@@ -145,14 +150,14 @@ main(int argc, char **argv) {
     XDefineCursor(dpy, w, invisible);
     XMapRaised(dpy, w);
 
-    font = XLoadQueryFont(dpy, fontname);
+    font = XftFontOpenXlfd(dpy, screen, fontname);
+    XftColorAllocName(dpy, DefaultVisual(dpy, screen), DefaultColormap(dpy, screen), "white", xftcolor);
 
     if (font == 0) {
         die("error: could not find font. Try using a full description.\n");
     }
 
     gc = XCreateGC(dpy, w, (unsigned long)0, &values);
-    XSetFont(dpy, gc, font->fid);
     XSetForeground(dpy, gc, XWhitePixel(dpy, screen));
 
     for(len = 1000; len; len--) {
@@ -187,7 +192,8 @@ main(int argc, char **argv) {
         if (update) {
             XClearWindow(dpy, w);
             XDrawLine(dpy, w, gc, width * 3 / 8 , (height + baroffset) / 2, width * 5 / 8, (height + baroffset) / 2);
-            XDrawString(dpy,w,gc, (width - XTextWidth(font, passdisp, len)) / 2, (height+42) / 2, passdisp, len);
+            XftTextExtentsUtf8(dpy, font, (XftChar8 *)passdisp, len, extents);
+            XftDrawStringUtf8(xftdraw, xftcolor, font, (width - extents->width) / 2, (height+42) / 2, (XftChar8 *)passdisp, len);
             update = False;
         }
 
@@ -251,7 +257,9 @@ main(int argc, char **argv) {
 
     XUngrabPointer(dpy, CurrentTime);
     XFreePixmap(dpy, pmap);
-    XFreeFont(dpy, font);
+    XftFontClose(dpy, font);
+    XftColorFree(dpy, DefaultVisual(dpy, screen), DefaultColormap(dpy, screen), xftcolor);
+    XftDrawDestroy(xftdraw);
     XFreeGC(dpy, gc);
     XDestroyWindow(dpy, w);
     XCloseDisplay(dpy);

Offline

#14 2011-01-10 10:34:03

Revelation60
Member
From: The Netherlands
Registered: 2009-03-19
Posts: 158
Website

Re: sflock: simple X screen locker with basic user feedback

I have fixed your code and have added it to the xft branch: https://github.com/benruijl/sflock/tree/xft.

What went wrong was that you didn't allocate xftdraw, xftcolor and extents. For the first there is a function (XftDrawCreate) and for the latter ones you just say XftColor xftcolor instead of  XftColor *xftcolor. But this is a very good first attempt at C! Thanks for the patch smile

Offline

#15 2011-01-13 01:34:54

ApotheoZ
Member
Registered: 2009-08-10
Posts: 40

Re: sflock: simple X screen locker with basic user feedback

error : could not find font. Try using a full description.

how sad :<

Offline

#16 2011-01-13 07:46:38

Revelation60
Member
From: The Netherlands
Registered: 2009-03-19
Posts: 158
Website

Re: sflock: simple X screen locker with basic user feedback

Did you use the default font? That one is in the ttf-ms-fonts package in the aur. You can use the -f option to specify another font. This may work:

sflock -f "-*-fixed-*-r-*-*-*-420-*-*-*-*-*-*"

Offline

#17 2011-01-13 14:49:42

Revelation60
Member
From: The Netherlands
Registered: 2009-03-19
Posts: 158
Website

Re: sflock: simple X screen locker with basic user feedback

I have added the username to the screen, and made the position of the bar relative to the text extents, so it will never overlap. Thus the -b option is deprecated. I am thinking about merging the xft branch and making it a compile flag.

By the way, if anyone wants to alter the design to make it look better, you are more than welcome!

Offline

#18 2011-01-13 21:53:14

anrxc
Member
From: Croatia
Registered: 2008-03-22
Posts: 834
Website

Re: sflock: simple X screen locker with basic user feedback

Hi guys, what about the fact that no screen locker actually locks the screen? Ctrl+alt+backspace if enabled will crash X, you can switch to a console or put the keyboard in raw mode... It's also pathetic that in 2010 both kscreenlocker and gnome locker had a bug where they could be crashed to unlock the desktop just by pressing and holding Return.

startx where used should be replaced with alias or script to exit the shell after starting X. Login managers are useful at least for this.

Edit: I forgot to say something on topic smile I'll be using this software too, kscreenlocker though patched the bug, is annoying, i.e. on half the locks it fails to blank the screen.

Last edited by anrxc (2011-01-13 22:18:26)


You need to install an RTFM interface.

Offline

#19 2011-01-13 23:03:41

ninian
Member
From: United Kingdom
Registered: 2008-02-24
Posts: 726
Website

Re: sflock: simple X screen locker with basic user feedback

Oh dear, I'm afraid I have big problems with the latest version: sflock-git-20110113-1
It works fine from a terminal, but fails to lock when I run sflock from within a Bash script or an Openbox menu. All that happens is that the screen flickers blank for an instant then returns to the desktop just as it was!

However, reverting to sflock-git-20101230-1 works fine. (Afraid I haven't had the time to have a look at the code yet.)

Offline

#20 2011-01-14 03:41:21

some-guy94
Member
Registered: 2009-08-15
Posts: 360

Re: sflock: simple X screen locker with basic user feedback

No -b option? I was actually using it to get rid of the bar, could you add an easy way to disable it?

Offline

#21 2011-01-14 08:50:29

Revelation60
Member
From: The Netherlands
Registered: 2009-03-19
Posts: 158
Website

Re: sflock: simple X screen locker with basic user feedback

It's not the latest version anymore smile There was a problem with the getlogin() function, which I fixed last night (about the time you posted this). It's a shame you can't tell whether there is a new version with git packages.

No -b option? I was actually using it to get rid of the bar, could you add an easy way to disable it?

I'll add a switch soon.

Offline

#22 2011-01-14 21:22:37

ninian
Member
From: United Kingdom
Registered: 2008-02-24
Posts: 726
Website

Re: sflock: simple X screen locker with basic user feedback

Revelation60 wrote:

It's not the latest version anymore smile There was a problem with the getlogin() function, which I fixed last night (about the time you posted this). It's a shame you can't tell whether there is a new version with git packages.

Aha,  thank you - working fine now.
smile

Offline

#23 2011-01-14 21:32:05

ApotheoZ
Member
Registered: 2009-08-10
Posts: 40

Re: sflock: simple X screen locker with basic user feedback

With ttf-ms-fonts, it's run very well, but I've got the same remark to do as anrxc : Ctrl + Alt + F1 -> Ctrl + C = you've got a full running session.

hmm

Offline

#24 2011-01-14 21:57:22

Revelation60
Member
From: The Netherlands
Registered: 2009-03-19
Posts: 158
Website

Re: sflock: simple X screen locker with basic user feedback

That doesn't work for me, apotheoz. But you could of course always do alt+sysreq+k to kill it. But I use sflock in combination with a login manager.

Offline

#25 2011-03-05 10:54:07

Revelation60
Member
From: The Netherlands
Registered: 2009-03-19
Posts: 158
Website

Re: sflock: simple X screen locker with basic user feedback

I have made an update today that prevents changing to a tty when sflock is enabled. This should improve security smile

Offline

Board footer

Powered by FluxBB