Giter Club home page Giter Club logo

sxlock's Introduction

sxlock - simple X screen locker

Simple screen locker utility for X, fork of sflock, which is based on slock. Main difference is that sxlock uses PAM authentication, so no suid is needed.

Features

  • provides basic user feedback
  • uses PAM
  • sets DPMS timeout to 10 seconds, before exit restores original settings
  • basic RandR support (drawing centered on the primary output)

Requirements

  • libX11 (Xlib headers)
  • libXext (X11 extensions library, for DPMS)
  • libXrandr (RandR support)
  • libXft
  • PAM

Installation

Arch Linux users can install this package from the AUR.

For manual installation just install dependencies, checkout and make:

git clone https://github.com/lahwaacz/sxlock.git
cd ./sxlock
make
./sxlock

Hooking into systemd events

When using systemd, you can use the following service (create /etc/systemd/system/sxlock.service) to let the system lock your X session on hibernation or suspend:

[Unit]
Description=Lock X session using sxlock
Before=sleep.target

[Service]
User=<username>
Environment=DISPLAY=:0
ExecStart=/usr/bin/sxlock

[Install]
WantedBy=sleep.target

However, this approach is useful only for single-user systems, because there is no way to know which user is currently logged in. Use xss-lock as an alternative for multi-user systems.

sxlock's People

Contributors

lahwaacz avatar limitedatonement avatar ondrejslamecka avatar qmenoret avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

sxlock's Issues

FPrint PAM module doesn't work

Adding auth sufficient pam_fprintd.so to the sxlock pam file doesn't allow me to use my fingerprint scanner to unlock my computer, while sudo and login do.

Locking fails with "unclutter -grab"

If unclutter is run with the -grab option, then sxlock will fail with

sxlock: Cannot grab pointer/keyboard

when the cursor is hidden.

I'm not sure if this is a bug, but apparently it was relevant enough for slock to include the -nomousegrab option.

-f parameter explanation

Hi,
maybe you could write a bit more about the -f parameter and possible values.
This sxlock -f "Droid Sans Mono" did not work for me, it returns sxlock: error: could not find font. Try using a full description.
But, it is installed:

fc-list | grep "Droid Sans Mono"
/usr/share/fonts/TTF/DroidSansMono.ttf: Droid Sans Mono:style=Regular

sxlock crashes betimes

I'm not positive what happens, but my kids crash the program while it is sleeping. My hunch is that they type too many characters. I can recover by getting another computer, SSH to the frozen machine, and kill the lock programs. I haven't studied the code, but is there opportunity for buffer overflow or something if too many characters are entered? Beware, my kids are capable of typing a lot of characters...they have nothing better to do sometimes. (Homeschooling is great in many ways, but it's sort of bad for my computers.)

support for background image

I love the simplicity of sxlock.

I would like to be able to set a background image. This would allow more customization.

Unfortunately I am not able to write C.
So I can only offer this feature request.

No knowledge of multiple monitors.

Currently, sxlock has no knowledge of monitor geometry. This causes the prompt to be centered across monitors when using two monitors, which is rather ugly. I believe this could be solved in two ways:

  1. Allow the user to specify the width/height in which the text is centered. I have implemented this solution in my fork of sxlock, and can issue a pull request if you'd like. Code-wise, this is the simpler solution, but requires user interaction to get right (rather than just "doing the right thing")

  2. Use a call to XGetGeometry() to get the width and height of Monitor #0 and center in that.

dpms state not correctly restored when killed

Despite the signal handler, dpms state is not restored correctly.

How to reproduce: open two terminals, start the commands on terminal B quickly after running the ones on terminal A.
On terminal A:

$ xset q | grep -A 4 DPMS ; sleep 20 ; killall sxlock
DPMS (Energy Star):
  Standby: 600    Suspend: 600    Off: 600
  DPMS is Enabled
  Monitor is On

On terminal B:

$ sxlock ; sleep 2 ; xset q | grep -A 4 DPMS
sxlock: Caught signal 15; dying
DPMS (Energy Star):
  Standby: 10    Suspend: 10    Off: 10
  DPMS is Enabled
  Monitor is Off

Pass through some keys

Would it be possible to pass through some keys, e.g. to control the audio (mute, lower and raise)?

Password prompt does not appear when used with xautolock

I use xautolock to start sxlock after 10 minutes of inactivity. When I use the mouse or keyboard to wake the screen up after 10 minutes has passed, everything looks as I left it. I see my desktop and windows, but everything is frozen until I put in the password. No password prompt ever appears.

I use a systemd service to run xautolock -locknow when the system wakes up from sleep. When that happens, the screen is black and a password prompt does appear.

Delayed screenlock on wake up

I'm using a Lenovo Thinkpad X200 w/ Arch. I installed this via AUR and started and enabled the service you suggested in you README to run sxlock when the pc goes in sleep/hibernation mode and it worked but there is a sensible delay when I wake up the pc. You can literally see the unlocked screen for like 2 seconds and only then the black screen of sxlock appears running as usual thanks to the previously set service. Is this a problem on my end?

sxlock is circumventable

I created #23 a couple years ago about my kids crashing sxlock. The child is now seven years old and has figured out how to circumvent sxlock.

After my dell precision m4700 is restored from suspend, the child rails on the keyboard. Right when the desktop comes up (there seems to be a 700ms-or-so pause before sxlock is put on top of the desktop), his typing goes to whatever application was up when the machine was suspended. This prevents sxlock and hinders it from coming to the front to lock the screen.

I can simply not suspend the machines before locking them, but how long will it take before my child will realize he can unplug the power supply until the power gets low and the machine will put itself in suspend?

Error opening /var/log/faillog for update

I just noticed that sxlock tries to write to /var/log/faillog but fails:

~ journalctl -b _PID=5509 
-- Logs begin at Mi 2013-12-04 22:23:53 CET, end at Mi 2014-03-19 12:37:35 CET. --
Mär 19 10:28:03 thinkpad sxlock[5509]: Warning: no primary output detected, falling back to LVDS1.
Mär 19 12:11:28 thinkpad sxlock[5509]: pam_tally(login:auth): Error opening /var/log/faillog for update
Mär 19 12:11:28 thinkpad sxlock[5509]: pam_tally(login:auth): Error opening /var/log/faillog for read

Is this because I am running it as normal user? Any workaround for this or can it be safely ignored?

Doesn't work on lid closure, otherwise ok

Must say this is my favorite screen locker, after testing many others, very elegant.
But I have this problem:

  • Locks as expected with xfce menu action button
  • Locks as expected after wake-up from suspend initiated by menu action button
  • Does not lock after wake-up if suspend was initiated by lid closure; desktop shows up without lock.

For comparison, slock works as expected on all previous situations but I don't like it.
To make the comparison correct, I just edited xflock4, which is called by xfce4-session and xfce4-power-manager, and added an 'x' to turn the call to slock into sxlock.
I'm using Xfce 4.12 on Gentoo and, of course xfce4-session /general/LockCommand is empty, lid opening is set not to be handled by logind, it's handled by xfce4-power-manager. All other setting on the xsettings ui are correctly made; after all, slock works correctly.
I'm going to switch to slock now, but I really would like to be able to use sxlock, thank you for letting me use it.

Screen Doesn't Turn Off

When the screen is locked and prompting for a password, I can press ESC to turn the screen off. Sometimes the screen turns back on after several minutes; I can't tell why.

This should happen automatically after perhaps 15 seconds and stay off until some user event turns the screen back on.

sxlock is Circumventable

#23 speaks about sxlock crashing, and this may be a duplicate. #27 has the same title as this, but they are different issues.

If I unplug the power supply from my laptop, I can press escape and unlock the screen without entering a password. Standard out or standard error outputs the following when that happens:

X Error of failed request:  BadMatch (invalid parameter attributes)
  Major opcode of failed request:  147 (DPMS)
  Minor opcode of failed request:  6 (DPMSForceLevel)
  Serial number of failed request:  56
  Current serial number in output stream:  60

I spent some time debugging and it looks like the call: XNextEvent(dpy, &event) fails. Nothing runs after that point, the program exits like it received sigkill or something.

BadRRCrtc (invalid Crtc parameter)

If I try to start the application I get the following error:

X Error of failed request:  BadRRCrtc (invalid Crtc parameter)
  Major opcode of failed request:  140 (RANDR)
  Minor opcode of failed request:  20 (RRGetCrtcInfo)
  Crtc id in failed request: 0x0
  Serial number of failed request:  16
  Current serial number in output stream:  16

Some information about my system:

Linux endymion 3.12.9-2-ARCH #1 SMP PREEMPT Fri Jan 31 10:22:54 CET 2014 x86_64 GNU/Linux
01:00.0 VGA compatible controller: NVIDIA Corporation G94 [GeForce 9600 GT] (rev a1)
nvidia 331.38-2

Any ideas?

Crashes sometimes on screen off

When hitting esc to blank the screen, sometimes instead of blanking, sxlock crashes with this:

  Major opcode of failed request:  147 (DPMS)
  Minor opcode of failed request:  6 (DPMSForceLevel)
  Serial number of failed request:  215
  Current serial number in output stream:  218

Running antegos on x86_64

uname details:

Linux pikatop 4.11.9-1-ARCH #1 SMP PREEMPT Wed Jul 5 18:23:08 CEST 2017 x86_64 GNU/Linux

Xorg details:

Release Date: 2017-03-15
X Protocol Version 11, Revision 0
Build Operating System: Linux 4.9.11-1-ARCH x86_64 
Current Operating System: Linux pikatop 4.11.9-1-ARCH #1 SMP PREEMPT Wed Jul 5 18:23:08 CEST 2017 x86_64
Kernel command line: initrd=\intel-ucode.img initrd=\initramfs-linux.img cryptdevice=UUID=c08f94cc-6ff0-4064-a79b-d7467a29bca1:root  root=UUID=a73f1e78-1871-4bb2-91d2-fc1499b70688 rw quiet
Build Date: 07 April 2017  05:42:48PM
 
Current version of pixman: 0.34.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.