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.

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);

Similar Messages

  • When upgrading the software my screen locked with image music connector with lights flashing how do I get out of this?

    I have a new latest apple tv.  I was asked do I want a software upgrade, when I said yes, after 5 minutes the screen locked with an image of a connector cable with music.
    I pulled the power, the hdmi and reconnected and it went back to the image on the screen.  the white light is flashing fast - does anyone know what to do?

    The update was interuppted. You will need to grab a micro usb cable and restore via iTunes
    http://support.apple.com/kb/HT4367

  • Is Screen Sharing with multiple users possible?

    I am trying to discuss some documents with multiple users. It works very well with just two users sharing the screen of one of them, so I was wondering if there was a way to have a third user participating. If iChat does not allow this, does anyone know a different software solution?
    Thanks
    Christian

    Hi,
    No. (Not in iChat)
    And I have not heard of anything either.
    10:39 PM Friday; October 22, 2010
    Please, if posting Logs, do not post any Log info after the line "Binary Images for iChat"

  • No screen lock with os4 !! reminds me of htc tilt !!!

    i have a major issue with the new software 4.0 seems they left out the screen lock option by pressing power button to lock the screen i always either hang up , put on hold or open a app while talking !! I'm very disappointed with apple i have many products and several phones at the price we are PAYING i would expect a better product

    I'm not sure what is "ridiculous".
    When on a call using the iPhone's earpiece - holding the iPhone up to your ear and face during a call, the iPhone includes a proximity sensor to automatically turn the screen off or lock the screen when doing so - there is no need to press the sleep/wake button while holding the iPhone up to your ear and face during a call. When pulling the iPhone away from your ear and face during a call to look at the screen and to use the iPhone for something else during the call or to hang up the call, etc., the screen turns back on. This is done automatically.

  • Screen locked with voice over and zero value

    My ipad screen is locked with voice over and every time I put in my pass code it just repeats and says zero value.  How do I get into my ipad without having to loose all my data.  Have icloud backup but not sure if that is working properly.Frustrated!

    Try triple-clicking the home button and see if that turns it off, and if it does you can then change what a triple-click does via Settings > General > Accessibility > Accessibility Shortcut (or Triple-Click Home depending upon the iOS version).
    If that doesn't turn it off then you can either turn it off directly on the iPad to go into Settings > General > Accessibility and turn VoiceOver 'off'. You need to use a tap-to-select and then double-tap to activate/type process and 3 fingered scrolling e.g. to type a digit of your passcode tap the digit so that it gets a box around it, and then double-tap the digit to type it.
    Or you can do it by connecting to your computer's iTunes (after typing in your passcode via the tap/double-tap process) : select the iPad  in iTunes, select its Summary tab, scroll to the bottom of that and click the 'configure accessibility' button :
    And on the popup select 'none' for the 'seeing' option :
    Clicking 'ok' should turn it 'off' on your iPad

  • Screen locked with non-English keyboard layout selected

    Hello,
    I use two keyboard character sets for keyboard. The switch between them is Command-Space.
    I also have password requirement for waking up or going from screen saver.
    Now if screensaver starts with non-English layout selected, I'm not able to login:
    password is not accepted because keyboard layout is not English and switching
    to English layout does not work in unlocking window.
    Is there any way to change layout while in the unlock window?
    Thanks

    Yes you are right, this is not a bug, it's just bad user interface. Just imagine the following scenario...
    Writing a paper, switching to Greek to enter a couple of characters and leaving the mac idle for 5 mins.
    The lock screen comes up asking for a password, unfortunately the user didn't change the language
    before the mac was left idle and there is no option to change the language in the lock screen.
    User has to hard reset to access the mac and let's hope that the user was saving his paper frequenlty.
    So from a coding point of view this is not a bug, but from a user interface design it is a huge flaw

  • No screen lock with gnome 3

    Hello guys
    My major problem with gnome 3 is that I'm unable to lock my screen.
    I tried every possible alternative such as locking after suspend via pm-suspend, the gnome-menu or closing the lid.
    Even lock screen via the gnome-menu doesn't work.
    Furthermore I changed my dconf and gconf multiple times ( especially the lock-use-screensaver setting) and tried every solution posted in the web. But nothing solved my problem.
    I also tested using GDM in stead of SLIM ( which I prefer ) but this solved my problem neither.
    My laptop is an Acer Aspire 3820TG Timeline X running the newest kernel ( 3.0 ) and Gnome 3.0.2.
    If you need more information don't hesitate to ask!

    I'm not sure what is "ridiculous".
    When on a call using the iPhone's earpiece - holding the iPhone up to your ear and face during a call, the iPhone includes a proximity sensor to automatically turn the screen off or lock the screen when doing so - there is no need to press the sleep/wake button while holding the iPhone up to your ear and face during a call. When pulling the iPhone away from your ear and face during a call to look at the screen and to use the iPhone for something else during the call or to hang up the call, etc., the screen turns back on. This is done automatically.

  • Should I use screen lock with find my iPad.

    Im using a wifi only iPad, so if it is lost or stolen the finder or thief will need to be able to access my iPad and connect to a wifi signal before I can track it. I therefore think I should not use keypad lock so that I can allow them

    You don't have to use one, it's personal preference as to whether you use one or not - I use one on my iPad Mini as I prefer the feel of them compared to the glass screen, other people don't like or use them as they prefer the glass (and some screen protectors can affect the clarity of the screen). Depending upon where you will be using the iPad (e.g. if it's dusty or dirty) you may want one to give the screen a bit of extra protection.

  • Need help with basic user events in Queued state machine example

    I have written a little queued state machine example to try to teach myself about creating and using user events.  The objective of the machine is to periodically choose a number (I'm doing it now with a control instead of a random number generator for troubleshooting), and compare that number with the number I have set in a control.  When they match, I want to cause an event to fire so I can do something about having found a match.  The examples in the LV Help file references show the events within the event structure, but I want to reach out of a state and cause an event ....
    Can someone point me in the right direction here?
    Thanks
    Hummer1
    Solved!
    Go to Solution.
    Attachments:
    User Event Generator Example01 snip.png ‏102 KB

    Yep....That was it...I had tried to do that but got fouled up with the variant definition...so defined the user event using a boolian and did the same in the case structure where I wanted to create the event and it worked great...
    Thanks.
    Here is the final version...not bulletproof, but does have a queued state machine using a user event to cause an event to fire.
    Hope you find it useful.
    Hummer1
    Attachments:
    User Event Generator Example01.vi ‏45 KB
    Operating States Enum Example01.ctl ‏5 KB

  • Screen Locked with box "Cannot Access Find My Friends"

    This has never happened...when I try to go on my iPad there is a box that says "cannot access find my friends" with 2 buttons "later" or "open". When I select either of those nothing happens.  I have tried shutting down and it won't let me select to power down.  I have asked Siri all sorts of questions and commands which she answers and follows.  When I ask her to go to the find my friends app it displays a white screen.  I never even use this app.  Here is a pic of what it looks like.

    Try a device reset:
    Device Reset (won't affect settings/data/music/apps/etc)
    1. Press and hold (& continue to hold) BOTH the Sleep/Wake button & the Home button.
    2. Continue to hold BOTH (ignoring any other messages that may show) until you see the Apple logo on the screen.
    3. Release BOTH buttons when you see the Apple logo and allow the device to boot normally.
    Afterwards, enter multitasking and close off the Find My Friends app as it may be running and throwing this message. It appears you are likely on iOS 6.x so I'll include the procedure to close off the app for that iOS as it's different than iOS 7 and above:
    Double-tap Home, press and hold one of the running app's icons (in your case, Find My Friends) until it wiggles, press the red - on the icon to close the app. Do this for all of the apps you want closed.
    Note that a similar pop-up message stating something like "This iPad had not been backed up for xxx amount of time" has also been know to appear with similar symptoms as this message. The only way to clear the message is with a device reset as mentioned above. Apple needs to address (at least) this "no backed up" message issue as it can prevent one from using their device unless they know of the reset.

  • Used iPad locked with old user.

    How do I reset an I-Pad that is still connected to the previous user/owner?

    If the iPad has Activation Lock - that is, it's asking for the previous owner's Apple ID and password to activate the device - then you will need that information, or you'll need to get the previous owner to remove the device from his/her iCloud account:
    http://support.apple.com/kb/PH2702
    If you can't reach the previous owner or he/she is unwilling to cooperate, then the device is unusable by you. Return the iPad for a refund if you can.
    Regards.

  • Help! after upgrade to ios5.1, my iphone keep going back to the screen lock 'slide to setup' screen

    help, after upgrade my iphone to ios5.1,my phone is in screen lock with 'slide to setup' mode. after going thru the setup, it says to start using iphone. but clicking that brings me to the apple icon and then back to the same lock screen with slide to setup mode. i cannot use my phone. i tried shutdown but still no use. pls help....

    Artnmotion wrote:
    Basically my Screen Lock has changed to the Silent Button like on a iPhone and my Volume Button does nothing any advise people???
    see art51's post in this thread: http://discussions.apple.com/message.jspa?messageID=12652155#12652155.
    JGG

  • IPOd is frozen after screen lock.

    Alright I'm having a bit of a problem, and the trouble shooting and tips I read on the support/ipod page didn't help. I put my iPod on a screen lock with the password. The next time I tried to use it I knew I would have to put the password in,but it wouldnt let me. It seemed to be frozen,but then finally a page showed up showing a file and and exclmation point,and an iPod with a sad face with http://apple.com/support/iPod I went there and followed the steps,but my iPOd has yet to work..can someone please help me?!!Thanks
    -audrey

    http://apple.com/support/iPod I went there and
    followed the steps,but my iPOd has yet to work..can
    someone please help me?!!Thanks
    -audrey
    You say you followed ALL the steps. Did you restore your ipod?

  • I have an iPad screen that won't swipe.  I cannot connect it to Itunes because it's locked with a pass code which I can't enter because I can't swipe.  Any suggestions on how to fix this?

    I have a 16GM Mini IPad.  The screen won't swipe.  I tried resetting it but that didn't work.  I attempted to connect to ITunes to try a restore but I can't do that.  This is because the IPad is locked with a pass code which I can't enter because I can't swipe.  Does anyone have any suggestions on how to fix this?

    If Ralph's suggestion doesn't work, try a Restore.  Note that it's nowhere near as quick as a Reset.  It could take well over an hour!  Connect via cable to the computer that you use for sync.  From iTunes, select the iPad/iPod and then select the Summary tab.  Follow the on-screen directions for Restore and be sure to say "yes" to the backup.  You will be warned that all data (apps, music, movies, etc.) will be erased but, as the Restore finishes, you will be asked if you wish the contents of the backup to be copied to the iPad/iPod.  Again, say "yes."
    At the end of the basic Restore, you will be asked if you wish to sync the iPad/iPod.  As before, say "yes."  Note that that sync selection will disappear and the Restore will end if you do not respond within a reasonable time.  If that happens, only the apps that are part of the IOS will appear on your device.  Corrective action is simple -  choose manual "Sync" from the bottom right of iTunes.
    If you're unable to do the Restore (or it doesn't help), go into Recovery Mode per the instructions here.  You WILL lose all of your data (game scores, etc,) but, for the most part, you can redownload apps and music without being charged again.  Also, if you have IOS-7, read this.

  • How do I used my iPhone if it is Lock with an Apple ID account of the previous user and i can't longer contact him?

    I bought an Apple Device namely iPhone 4s and this really bother and give me an intimate reason to contact Apple. How do I use the device, if it is Lock with an Apple ID account of the previous user, and everytime I open the phone the screen will show Activate iPhone with the Apple ID link on the Device. The worse thing is that, i couln't contact the seller any longer and the device is seems useless. I can't use it. Please give me some help how to fix this error and vulnerabilities.

    Sorry alvinguibz, but you have encountered an Activation Lock, and unless you can contact the previous owner and have them follow the steps below, you will not be able to use your device:
    Removing Previous Owner from Device
    There is no other way around this.
    Sorry,
    GB

Maybe you are looking for

  • How long do you need to charge a new iPhone 5 for before trying to turn it on?

    I received a new iphone 5 in the post today to replace the ne I had smashed the screen on. I was told that I would need to charge the phone and then insert my SIM and it would be good to go. The phone has been on charge since 14:00 and still wont tur

  • CRS 5 Backups fail with this error: Unknown error occured while connecting to the host

    Dear All, We have backup issue with  UCCX 5.0(2)SR03_Build317, while trying to take  backup giving following error "Unknown error occurred while connecting to the host". I have found the solution in the Cisco and tried all the suggestion, still not w

  • Camera RAW 7 and Elements 9

    I'm using the Beta version of CS6 and there is a CAMERA RAW 7 program that I would like to use in my Elements program. The RAW editor in Elements (current) always has the sliders in a pre-set configuration, not at zero. Using CS6 Beta, the Camera RAW

  • Spy TCP/IP with Labview

    I'm intensively using Labview as a test platform for communication interfaces Currently I've a serial spy decoding HDLC which works quite well I need also to perform some traces on TCP/IP WhichVI should I use ? How do I have to configure it ? Many Th

  • ACH formatting issues

    I copied ACH format 005 and made some changes to comply with the new guidelines. I am having trouble uploading the file into the Bank because of a field in the segment portion of the format. The field I am referring to is the "Customer payment number