Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 31 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,47 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.

LDLIBS=-lX11 -lcrypt
CDEFS=-DSHADOW_PWD
LDLIBS=-lX11 -lcrypt $(shell pkg-config --libs libnotify)
CDEFS=-DSHADOW_PWD $(RESPATH)
CC=gcc
CFLAGS=-Wall ${CDEFS}
CFLAGS=-Wall ${CDEFS} $(shell pkg-config --cflags libnotify)
INSTALL=install
RM=rm
CONFIGPATH=/usr/share/xtrlock/
RESPATH=-D'LOCK_IMG_PATH="$(CONFIGPATH)lock.png"' -D'UNLOCK_IMG_PATH="$(CONFIGPATH)unlock.png"'
#RESPATH=-D'LOCK_IMG_PATH="$(shell readlink -f lock.png)"' -D'UNLOCK_IMG_PATH="$(shell readlink -f unlock.png)"'
LID_CMD:=xtrlock -l

xtrlock: xtrlock.o

xtrlock.o: xtrlock.c

debug:
$(CC) xtrlock.c $(LDLIBS) $(CFLAGS) -DDEBUG -g -o xtrlock

clean:
-rm -f xtrlock.o xtrlock

install: xtrlock
$(INSTALL) -c -m 2755 -o root -g shadow xtrlock /usr/bin
$(INSTALL) -c -m 2755 -o root -g shadow xtrlock /usr/bin
if [ ! -d "$(CONFIGPATH)" ]; then mkdir $(CONFIGPATH); fi
$(INSTALL) -c -m 644 resources/lock.png $(CONFIGPATH)
$(INSTALL) -c -m 644 resources/unlock.png $(CONFIGPATH)

install.man:
$(INSTALL) -c -m 644 xtrlock.man /usr/man/man1/xtrlock.1x
$(INSTALL) -c -m 644 xtrlock.man /usr/share/man/man1/xtrlock.1x

remove:
$(RM) /usr/bin/xtrlock
install.bash_completion:
$(INSTALL) -c -m 754 xtrlock-completion.sh /usr/share/bash-completion/completions/xtrlock

install.on_lid:
cp ./on-lid-close.sh on-lid-close.sh.tmp
sed 's/xtrlock -l/$(LID_CMD)/g' on-lid-close.sh.tmp > tmp && mv tmp on-lid-close.sh.tmp
$(INSTALL) -c -m 744 -o root xtrlock-lid-down /etc/acpi/events/xtrlock-lid-down
$(INSTALL) -c -m 744 -o root ./on-lid-close.sh.tmp /etc/acpi/on-lid-close.sh
rm -f on-lid-close.sh.tmp
remove:
$(RM) /usr/bin/xtrlock
$(RM) -rf $(CONFIGPATH)
$(RM) -f /usr/share/bash-completion/completions/xtrlock
$(RM) -f /etc/acpi/on-lid-close.sh /etc/acpi/events/xtrlock-lid-down
33 changes: 32 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,41 @@
DO NOT USE!
USE OR NOT? DEPENDS ON YOU!
===========

#### From last author:

Since working on this project, I have come to the conclusion that using anything but xscreensaver is a very unwise decision ([details](http://www.jwz.org/xscreensaver/toolkits.html)). I am no longer updating this project and strongly advise against its use (or the use of the upstream branch). Since this program puts you in peril of disclosing sensitive information, I do think its general concept is a Bad Idea™. Imagine your friend bob writes an OTR-encrypted message to you via Jabber, which causes Pidgin to open a new window display the decrypted message.

If you just want to confuse/annoy people, I would suggest having xscreensaver take a screenshot when the screen is locked, which is then displayed by feh, xv or any other program capable of displaying images on X root windows. Another IMHO very nice (though seriously hacky) method is the one I described [in this gist](https://gist.github.com/jaseg/3487142): Have xscreensaver spawn an actual Windows XP VM that curious people can interact with, including automatic reset on screen unlocking.

Thanks for checking out anyway!

jaseg


#### From this author:

I am modifing this project into a simple screen lock that have more of the conviniency rather than security. It will be modified to deal with laptop lids that always touch the keyboard or someone trying to mess around with your screen when your are in the toliet. However, please carefully read the note from the last author and deside if a professional screen lock like Xscreensaver is necessary for you! Nevertheless, IMHO this program should be able to deal with routine cases secure enough.

Please check out the releases to grab a finished version! Any contribution would be appreciated!
2017/7/13

d0048

#### Installation Guide:
##### On linux:
1. Install required libiary and tools to build the project:
Debian series: `sudo apt-get install bash-completion libnotify-dev libx11-dev build-essential cmake cmake-data pkg-config`
Redhat series: `sudo dnf install bash-completion libnotify-dev libx11-dev build-essential cmake cmake-data pkg-config`
2. Download the correct version of source code you want and unzip it.(Probably from releases if stability is required)
3. `cd Better-XTrLock`
4. `make && sudo make install` to install the main binaries.
5. To install the manual for xtrlock, `sudo make install.man`. Then use `man xtrlock` to read the manual.
6. To install the auto completion support for bash 'sudo make install.bash_completion`
7. To trigger xtrlock on lid close, `sudo make install.on_lid LID_CMD='lock_command_with_args'`.(e.g: `LID_CMD='xtrlock -l -n'`). If no command specified, `xtrlock -l` will be used.
8. `xtrlock -h` to view usage

#### Removal Guide:
##### On linux:
1. Download the correct version of source code you want and unzip it.(Probably from releases if stability is required)
2. `cd Better-XTrLock`
3. `sudo make remove`
11 changes: 11 additions & 0 deletions on-lid-close.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
target='xtrlock -l';
who | awk '{print $1, $NF}' | tr -d "()" |
while read u d; do
id=$(id -u $u)
. /run/user/$id/dbus-session
export DBUS_SESSION_BUS_ADDRESS
export DISPLAY=$d
sudo su $u -c "$target"

done
Binary file added resources/Lock_Unlock.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/lock.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/unlock.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions xtrlock-completion.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# xtrlock(1) completion -*- shell-script -*-

_xtrlock(){
local cur="${COMP_WORDS[COMP_CWORD]}";
local xtr_opts="-h --help -l --lock-user-password -p --password -e --encrypted-password -c --calculate -b --block-screen -d --delay-of-blink -n --notify"
#local prevcur="${COMP_WORDS[COMP_CWORD]}";
#local prev="${COMP_WORDS[COMP_CWORD-1]}";

COMPREPLY=();
if [[ ${cur} == -* ]] ; then
COMPREPLY=($(compgen -W "${xtr_opts}" \'"$cur"\'))
return 0;
fi
}
complete -F _xtrlock xtrlock;
2 changes: 2 additions & 0 deletions xtrlock-lid-down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
event=button/lid LID close
action=/etc/acpi/on-lid-close.sh
Loading