diff --git a/.gitignore b/.gitignore index 295c11b..a5609d7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ twilio.* imgur.* +slock +slock.o diff --git a/config.mk b/config.mk index e566abe..46d2f74 100644 --- a/config.mk +++ b/config.mk @@ -14,7 +14,7 @@ INCS = -I. -I/usr/include -I${X11INC} LIBS = -L/usr/lib -lc -lcrypt -L${X11LIB} -lX11 -lXext # flags -CPPFLAGS = -DVERSION=\"${VERSION}\" -DHAVE_SHADOW_H -DCOLOR1=\"black\" -DCOLOR2=\"\#005577\" +CPPFLAGS = -DVERSION=\"${VERSION}\" -DHAVE_SHADOW_H -DCOLOR1=\"black\" -DCOLOR2=\"\#555555\" CFLAGS = -std=c99 -pedantic -Wall -Os ${INCS} ${CPPFLAGS} LDFLAGS = -s ${LIBS} diff --git a/slock.c b/slock.c index a25c592..f335b88 100644 --- a/slock.c +++ b/slock.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #if HAVE_BSD_AUTH @@ -28,15 +29,19 @@ #define CMD_LENGTH (500 * sizeof(char)) -#define POWEROFF 1 -#define TWILIO_SEND 1 -#define WEBCAM_SHOT 1 +#define POWEROFF 0 +#define TWILIO_SEND 0 +#define WEBCAM_SHOT 0 #define IMGUR_UPLOAD 0 -#define PLAY_AUDIO 1 -#define TRANSPARENT 1 +#define PLAY_AUDIO 0 +#define TRANSPARENT 0 +#if IMGUR_UPLOAD #include "imgur.h" +#endif +#if TWILIO_SEND #include "twilio.h" +#endif typedef struct { char *link; @@ -172,10 +177,8 @@ poweroff(void) { // Needs sudo privileges - alter your /etc/sudoers file: // systemd: [username] [hostname] =NOPASSWD: /usr/bin/systemctl poweroff // sysvinit: [username] [hostname] =NOPASSWD: /usr/bin/shutdown -h now - char *args[] = { "sudo", "systemctl", "poweroff", NULL }; - char *args_legacy[] = { "sudo", "shutdown", "-h", "now", NULL }; + char *args[] = { "sudo", "shutdown", "-h", "now", NULL }; execvp(args[0], args); - execvp(args_legacy[0], args_legacy); fprintf(stderr, "Error: cannot shutdown. Check your /etc/sudoers file.\n"); // Needs sudo privileges - alter your /etc/sudoers file: // [username] [hostname] =NOPASSWD: /usr/bin/tee /proc/sys/kernel/sysrq,/usr/bin/tee /proc/sysrq-trigger @@ -418,6 +421,10 @@ readpw(Display *dpy, const char *pws) * utility. This way the user can easily set a customized DPMS * timeout. */ while(running && !XNextEvent(dpy, &ev)) { + if(len == 0 && DPMSCapable(dpy)) { + DPMSEnable(dpy); + DPMSForceLevel(dpy, DPMSModeOff); + } if(ev.type == KeyPress) { buf[0] = 0; num = XLookupString(&ev.xkey, buf, sizeof buf, &ksym, 0);