forked from bakkeby/slock-flexipatch
-
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.
Added capscolor, control clear, dpms, mediakeys, message, pam auth, q…
…uickcancel patches
- Loading branch information
Showing
12 changed files
with
518 additions
and
6 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,3 @@ | ||
*.o | ||
dwm | ||
config.h |
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,54 @@ | ||
Similar to [dwm-flexipatch](https://github.com/bakkeby/dwm-flexipatch) this slock 1.4 project has a different take on patching. It uses preprocessor directives to decide whether or not to include a patch during build time. Essentially this means that this build, for better or worse, contains both the patched _and_ the original code. The aim being that you can select which patches to include and the build will contain that code and nothing more. | ||
|
||
For example to include the `capscolor` patch then you would only need to flip this setting from 0 to 1 in [patches.h](https://github.com/bakkeby/slock-flexipatch/blob/master/patches.h): | ||
```c | ||
#define CAPSCOLOR_PATCH 1 | ||
``` | ||
Once you have found out what works for you and what doesn't then you should be in a better position to choose patches should you want to start patching from scratch. | ||
Alternatively if you have found the patches you want, but don't want the rest of the flexipatch entanglement on your plate then you may want to have a look at [flexipatch-finalizer](https://github.com/bakkeby/flexipatch-finalizer); a custom pre-processor tool that removes all the unused flexipatch code leaving you with a build that contains the patches you selected. | ||
Refer to [https://tools.suckless.org/slock/](https://tools.suckless.org/slock/) for details on the slock tool, how to install it and how it works. | ||
--- | ||
### Changelog: | ||
2019-10-17 - Added capscolor, control clear, dpms, mediakeys, message, pam auth, quickcancel patches | ||
2019-10-16 - Introduced [flexipatch-finalizer](https://github.com/bakkeby/flexipatch-finalizer) | ||
### Patches included: | ||
- [capscolor](https://tools.suckless.org/slock/patches/capscolor/) | ||
- adds an additional color to indicate the state of Caps Lock | ||
- [control-clear](https://tools.suckless.org/slock/patches/control-clear/) | ||
- with this patch slock will no longer change to the failure color if a control key is pressed while the buffer is empty | ||
- this may be useful if, for example, you wake your monitor up by pressing a control key and don't want to spoil the detection of failed unlocking attempts | ||
- [dpms](https://tools.suckless.org/slock/patches/dpms/) | ||
- interacts with the Display Power Signaling and automatically shuts down the monitor after a configurable amount of seconds | ||
- the monitor will automatically be activated by pressing a key or moving the mouse and the password can be entered then | ||
- [mediakeys](https://tools.suckless.org/slock/patches/mediakeys/) | ||
- allows media keys to be used while the screen is locked, e.g. adjust volume or skip to the next song without having to unlock the screen first | ||
- [message](https://tools.suckless.org/slock/patches/message/) | ||
- this patch lets you add a custom message to your lock screen | ||
- [pam-auth](https://tools.suckless.org/slock/patches/pam_auth/) | ||
- replaces shadow support with PAM authentication support | ||
- [quickcancel](https://tools.suckless.org/slock/patches/quickcancel/) | ||
- cancel slock by moving the mouse within a certain time-period after slock started | ||
- the time-period can be defined in seconds with the setting timetocancel in the config.h | ||
- this can be useful if you forgot to disable xautolock during an activity that requires no input (e.g. reading text, watching video, etc.) | ||
- [terminalkeys](https://tools.suckless.org/slock/patches/terminalkeys/) | ||
- adds key commands that are commonly used in terminal applications (in particular the login prompt) | ||
- [unlockscreen](https://tools.suckless.org/slock/patches/unlock_screen/) | ||
- this patch keeps the screen unlocked, but keeps the input locked | ||
- that is, the screen is not affected by slock, but users will not be able to interact with the X session unless they enter the correct password |
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
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
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,9 @@ | ||
#include <X11/extensions/dpms.h> | ||
|
||
static void | ||
monitorreset(Display* dpy, CARD16 standby, CARD16 suspend, CARD16 off) | ||
{ | ||
DPMSSetTimeouts(dpy, standby, suspend, off); | ||
DPMSForceLevel(dpy, DPMSModeOn); | ||
XFlush(dpy); | ||
} |
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,12 @@ | ||
/* Patches */ | ||
#if DPMS_PATCH | ||
#include "dpms.c" | ||
#endif | ||
|
||
#if MESSAGE_PATCH | ||
#include "message.c" | ||
#endif | ||
|
||
#if PAMAUTH_PATCH | ||
#include "pamauth.c" | ||
#endif |
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,4 @@ | ||
/* Patches */ | ||
#if PAMAUTH_PATCH | ||
#include "pamauth.h" | ||
#endif |
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,94 @@ | ||
#include <X11/extensions/Xinerama.h> | ||
|
||
/* global count to prevent repeated error messages */ | ||
int count_error = 0; | ||
|
||
static void | ||
writemessage(Display *dpy, Window win, int screen) | ||
{ | ||
int len, line_len, width, height, s_width, s_height, i, j, k, tab_replace, tab_size; | ||
XGCValues gr_values; | ||
XFontStruct *fontinfo; | ||
XColor color, dummy; | ||
XineramaScreenInfo *xsi; | ||
GC gc; | ||
fontinfo = XLoadQueryFont(dpy, font_name); | ||
|
||
if (fontinfo == NULL) { | ||
if (count_error == 0) { | ||
fprintf(stderr, "slock: Unable to load font \"%s\"\n", font_name); | ||
fprintf(stderr, "slock: Try listing fonts with 'slock -f'\n"); | ||
count_error++; | ||
} | ||
return; | ||
} | ||
|
||
tab_size = 8 * XTextWidth(fontinfo, " ", 1); | ||
|
||
XAllocNamedColor(dpy, DefaultColormap(dpy, screen), | ||
text_color, &color, &dummy); | ||
|
||
gr_values.font = fontinfo->fid; | ||
gr_values.foreground = color.pixel; | ||
gc=XCreateGC(dpy,win,GCFont+GCForeground, &gr_values); | ||
|
||
/* To prevent "Uninitialized" warnings. */ | ||
xsi = NULL; | ||
|
||
/* | ||
* Start formatting and drawing text | ||
*/ | ||
|
||
len = strlen(message); | ||
|
||
/* Max max line length (cut at '\n') */ | ||
line_len = 0; | ||
k = 0; | ||
for (i = j = 0; i < len; i++) { | ||
if (message[i] == '\n') { | ||
if (i - j > line_len) | ||
line_len = i - j; | ||
k++; | ||
i++; | ||
j = i; | ||
} | ||
} | ||
/* If there is only one line */ | ||
if (line_len == 0) | ||
line_len = len; | ||
|
||
if (XineramaIsActive(dpy)) { | ||
xsi = XineramaQueryScreens(dpy, &i); | ||
s_width = xsi[0].width; | ||
s_height = xsi[0].height; | ||
} else { | ||
s_width = DisplayWidth(dpy, screen); | ||
s_height = DisplayHeight(dpy, screen); | ||
} | ||
|
||
height = s_height*3/7 - (k*20)/3; | ||
width = (s_width - XTextWidth(fontinfo, message, line_len))/2; | ||
|
||
/* Look for '\n' and print the text between them. */ | ||
for (i = j = k = 0; i <= len; i++) { | ||
/* i == len is the special case for the last line */ | ||
if (i == len || message[i] == '\n') { | ||
tab_replace = 0; | ||
while (message[j] == '\t' && j < i) { | ||
tab_replace++; | ||
j++; | ||
} | ||
|
||
XDrawString(dpy, win, gc, width + tab_size*tab_replace, height + 20*k, message + j, i - j); | ||
while (i < len && message[i] == '\n') { | ||
i++; | ||
j = i; | ||
k++; | ||
} | ||
} | ||
} | ||
|
||
/* xsi should not be NULL anyway if Xinerama is active, but to be safe */ | ||
if (XineramaIsActive(dpy) && xsi != NULL) | ||
XFree(xsi); | ||
} |
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,27 @@ | ||
char passwd[256]; | ||
|
||
static int | ||
pam_conv(int num_msg, const struct pam_message **msg, | ||
struct pam_response **resp, void *appdata_ptr) | ||
{ | ||
int retval = PAM_CONV_ERR; | ||
for (int i=0; i<num_msg; i++) { | ||
if (msg[i]->msg_style == PAM_PROMPT_ECHO_OFF && | ||
strncmp(msg[i]->msg, "Password: ", 10) == 0) { | ||
struct pam_response *resp_msg = malloc(sizeof(struct pam_response)); | ||
if (!resp_msg) | ||
die("malloc failed\n"); | ||
char *password = malloc(strlen(passwd) + 1); | ||
if (!password) | ||
die("malloc failed\n"); | ||
memset(password, 0, strlen(passwd) + 1); | ||
strcpy(password, passwd); | ||
resp_msg->resp_retcode = 0; | ||
resp_msg->resp = password; | ||
resp[i] = resp_msg; | ||
retval = PAM_SUCCESS; | ||
} | ||
} | ||
return retval; | ||
} | ||
|
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,5 @@ | ||
#include <security/pam_appl.h> | ||
#include <security/pam_misc.h> | ||
|
||
static int pam_conv(int num_msg, const struct pam_message **msg, struct pam_response **resp, void *appdata_ptr); | ||
struct pam_conv pamc = {pam_conv, NULL}; |
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,75 @@ | ||
/* | ||
* This file contains patch control flags. | ||
* | ||
* In principle you should be able to mix and match any patches | ||
* you may want. In cases where patches are logically incompatible | ||
* one patch may take precedence over the other as noted in the | ||
* relevant descriptions. | ||
*/ | ||
|
||
/* Patches */ | ||
|
||
/* This patch introduces an additional color to indicate the state of Caps Lock. | ||
* https://tools.suckless.org/slock/patches/capscolor/ | ||
*/ | ||
#define CAPSCOLOR_PATCH 0 | ||
|
||
/* Adds an additional configuration parameter, controlkeyclear. When set to 1, slock will no | ||
* longer change to the failure color if a control key is pressed while the buffer is empty. | ||
* This may be useful if, for example, you wake your monitor up by pressing a control key | ||
* and don't want to spoil the detection of failed unlocking attempts. | ||
* https://tools.suckless.org/slock/patches/control-clear/ | ||
*/ | ||
#define CONTROLCLEAR_PATCH 0 | ||
|
||
/* This patch interacts with the Display Power Signaling and automatically shuts down | ||
* the monitor after a configurable amount of seconds. | ||
* The monitor will automatically be activated by pressing a key or moving the mouse | ||
* and the password can be entered then. | ||
* https://tools.suckless.org/slock/patches/dpms/ | ||
*/ | ||
#define DPMS_PATCH 0 | ||
|
||
/* This patch allows media keys to be used while the screen is locked. Allows for volume | ||
* to be adjusted or to skip to the next song without having to unlock the screen first. | ||
* https://tools.suckless.org/slock/patches/mediakeys/ | ||
*/ | ||
#define MEDIAKEYS_PATCH 0 | ||
|
||
/* This patch lets you add a message to your lock screen. You can place a default message | ||
* in config.h and you can also pass a message with the -m command line option. | ||
* If you enable this then you also need to add the -lXinerama library to the LIBS | ||
* configuration in config.mk. Look for and uncomment the XINERAMA placeholder. | ||
* https://tools.suckless.org/slock/patches/message/ | ||
*/ | ||
#define MESSAGE_PATCH 0 | ||
|
||
/* Replaces shadow support with PAM authentication support. | ||
* Change variable pam_service in config.def.h to the corresponding PAM service. | ||
* The default configuration is for ArchLinux's login service. | ||
* If you enable this then you also need to add the -lpam library to the LIBS configuration | ||
* in config.mk. Look for and uncomment the PAM placeholder. | ||
* https://tools.suckless.org/slock/patches/pam_auth/ | ||
*/ | ||
#define PAMAUTH_PATCH 0 | ||
|
||
/* Cancel slock by moving the mouse within a certain time-period after slock started. | ||
* The time-period can be defined in seconds with the setting timetocancel in the config.h. | ||
* This can be useful if you forgot to disable xautolock during an activity that requires | ||
* no input (e.g. reading text, watching video, etc.). | ||
* https://tools.suckless.org/slock/patches/quickcancel/ | ||
*/ | ||
#define QUICKCANCEL_PATCH 0 | ||
|
||
/* Adds key commands that are commonly used in terminal applications (in particular the | ||
* login prompt) to slock. | ||
* https://tools.suckless.org/slock/patches/terminalkeys/ | ||
*/ | ||
#define TERMINALKEYS_PATCH 0 | ||
|
||
/* This patch keeps the screen unlocked but keeps the input locked. That is, the screen | ||
* is not affected by slock, but users will not be able to interact with the X session | ||
* unless they enter the correct password. | ||
* https://tools.suckless.org/slock/patches/unlock_screen/ | ||
*/ | ||
#define UNLOCKSCREEN_PATCH 0 |
Oops, something went wrong.