forked from jessfraz/dockerfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
buttslock will lock your screen when your machine goes to sleep
- Loading branch information
Showing
4 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# | ||
# This container will listen to DBus events to be notified when your | ||
# computer goes to sleep. When such events happen, it will lock the | ||
# screen with a fancy lock. | ||
# | ||
# It needs to be started with a few bind-mounts: | ||
# - /etc/passwd, /etc/shadow (read-only) | ||
# - /var/run/dbus, the X11 socket (typically /tmp/.X11-unix) | ||
# And it also requires the USER and DISPLAY environment variables to be set. | ||
# | ||
FROM alpine | ||
RUN apk update | ||
RUN apk add i3lock imagemagick py-dbus py-gobject scrot ttf-liberation xkeyboard-config | ||
ADD buttslock.py buttslock.sh lock.png / | ||
CMD /buttslock.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env python | ||
|
||
# Shamelessly pasted from: | ||
# http://serverfault.com/questions/573379/system-suspend-dbus-upower-signals-are-not-seen | ||
|
||
from datetime import datetime | ||
import dbus | ||
import gobject | ||
from dbus.mainloop.glib import DBusGMainLoop | ||
import os | ||
|
||
def handle_sleep(*args): | ||
print "%s PrepareForSleep%s" % (datetime.now().ctime(), args) | ||
if len(args)>0 and args[0]: | ||
os.system("/buttslock.sh") | ||
|
||
DBusGMainLoop(set_as_default=True) # integrate into gobject main loop | ||
bus = dbus.SystemBus() # connect to system wide dbus | ||
bus.add_signal_receiver( # define the signal to listen to | ||
handle_sleep, # callback function | ||
'PrepareForSleep', # signal name | ||
'org.freedesktop.login1.Manager', # interface | ||
'org.freedesktop.login1' # bus name | ||
) | ||
|
||
loop = gobject.MainLoop() | ||
loop.run() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/sh | ||
|
||
# Shamelessly copied from: | ||
# https://github.com/meskarune/i3lock-fancy | ||
|
||
# All options are here: http://www.imagemagick.org/Usage/blur/#blur_args | ||
#BLURTYPE="0x5" # 7.52s | ||
#BLURTYPE="0x2" # 4.39s | ||
#BLURTYPE="5x3" # 3.80s | ||
BLURTYPE="2x8" # 2.90s | ||
#BLURTYPE="2x3" # 2.92s | ||
|
||
# I still have to figure out how to get imagemagick fonts to work in Alpine | ||
#FONT="-font Liberation-Sans" | ||
FONT= | ||
|
||
scrot /tmp/scrot.png | ||
convert /tmp/scrot.png \ | ||
-level 0%,100%,0.6 -blur $BLURTYPE $FONT \ | ||
-pointsize 26 -fill white -gravity center \ | ||
-annotate +0+200 'Type password to unlock' \ | ||
/tmp/conv.png | ||
composite -gravity center /lock.png /tmp/conv.png /tmp/lock.png | ||
#i3lock --textcolor=ffffff00 --insidecolor=ffffff1c --ringcolor=ffffff3e --linecolor=ffffff00 --keyhlcolor=00000080 --ringvercolor=00000000 --insidevercolor=0000001c --ringwrongcolor=00000055 --insidewrongcolor=0000001c -i $IMAGE | ||
i3lock -i /tmp/lock.png --ignore-empty-password | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.