From cb044449c6c24231d58883359a5d36a857125d67 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Thu, 17 Jul 2014 14:03:00 -0700 Subject: [PATCH] custom passwords. sounds. --- slock.c | 14 +++++++++++++- slocked | 21 +++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100755 slocked diff --git a/slock.c b/slock.c index 729e39f..dc1e473 100644 --- a/slock.c +++ b/slock.c @@ -10,6 +10,7 @@ #include #include #include +#define _GNU_SOURCE #include #include #include @@ -152,8 +153,19 @@ readpw(Display *dpy, const char *pws) XBell(dpy, 100); if(++lock_tries > 2) { // http://soundbible.com/1819-Police.html - system("aplay /home/chjj/police.wav"); + char snd[255] = {0}; + snprintf(snd, sizeof(snd), "aplay %s/slock/police.wav", getenv("HOME")); + system(snd); + } else { + char snd[255] = {0}; + snprintf(snd, sizeof(snd), "aplay %s/slock/beep.wav", getenv("HOME")); + system(snd); } + } else { + // http://soundbible.com/1815-A-Tone.html + char snd[255] = {0}; + snprintf(snd, sizeof(snd), "aplay %s/slock/beep.wav &", getenv("HOME")); + system(snd); } len = 0; break; diff --git a/slocked b/slocked new file mode 100755 index 0000000..26f1049 --- /dev/null +++ b/slocked @@ -0,0 +1,21 @@ +#!/bin/bash + +ps=$(ps ux \ + | sed 1d \ + | grep -v tty1 \ + | grep -v pts \ + | grep -v '?' \ + | awk '{ print $2 }') + +if test -n "$ps"; then + echo "Killing: $ps" + kill $ps 2> /dev/null + kill -9 $ps 2> /dev/null +fi + +exec 2> /dev/null +pw=$1 +if test -z "$pw"; then + pw=$(cat ~/.slock_passwd) +fi +exec slock -p "$pw"