mirror of
https://github.com/mintycube/slock.git
synced 2024-10-22 14:05:51 +02:00
Adding keypress_feedback patch
This commit is contained in:
parent
4b280b29ef
commit
c07648d3f9
@ -15,6 +15,8 @@ Refer to [https://tools.suckless.org/slock/](https://tools.suckless.org/slock/)
|
|||||||
|
|
||||||
### Changelog:
|
### Changelog:
|
||||||
|
|
||||||
|
2020-08-03 - Added keypress_feedback patch
|
||||||
|
|
||||||
2019-11-27 - Added xresources patch
|
2019-11-27 - Added xresources patch
|
||||||
|
|
||||||
2019-10-17 - Added capscolor, control clear, dpms, mediakeys, message, pam auth, quickcancel patches
|
2019-10-17 - Added capscolor, control clear, dpms, mediakeys, message, pam auth, quickcancel patches
|
||||||
@ -34,6 +36,9 @@ Refer to [https://tools.suckless.org/slock/](https://tools.suckless.org/slock/)
|
|||||||
- interacts with the Display Power Signaling and automatically shuts down the monitor after a configurable amount of seconds
|
- 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
|
- the monitor will automatically be activated by pressing a key or moving the mouse and the password can be entered then
|
||||||
|
|
||||||
|
- [keypress_feedback](https://tools.suckless.org/slock/patches/keypress-feedback/)
|
||||||
|
- draws random blocks on the screen to display keypress feedback
|
||||||
|
|
||||||
- [mediakeys](https://tools.suckless.org/slock/patches/mediakeys/)
|
- [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
|
- 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
|
||||||
|
|
||||||
|
16
config.def.h
16
config.def.h
@ -12,6 +12,9 @@ static const char *colorname[NUMCOLS] = {
|
|||||||
#if PAMAUTH_PATCH
|
#if PAMAUTH_PATCH
|
||||||
[PAM] = "#9400D3", /* waiting for PAM */
|
[PAM] = "#9400D3", /* waiting for PAM */
|
||||||
#endif // PAMAUTH_PATCH
|
#endif // PAMAUTH_PATCH
|
||||||
|
#if KEYPRESS_FEEDBACK_PATCH
|
||||||
|
[BLOCKS] = "#ffffff", /* key feedback block */
|
||||||
|
#endif // KEYPRESS_FEEDBACK_PATCH
|
||||||
};
|
};
|
||||||
|
|
||||||
#if XRESOURCES_PATCH
|
#if XRESOURCES_PATCH
|
||||||
@ -44,6 +47,19 @@ static const int controlkeyclear = 0;
|
|||||||
static const int monitortime = 5;
|
static const int monitortime = 5;
|
||||||
#endif // DPMS_PATCH
|
#endif // DPMS_PATCH
|
||||||
|
|
||||||
|
#if KEYPRESS_FEEDBACK_PATCH
|
||||||
|
static short int blocks_enabled = 1; // 0 = don't show blocks
|
||||||
|
static const int blocks_width = 0; // 0 = full width
|
||||||
|
static const int blocks_height = 16;
|
||||||
|
|
||||||
|
// position
|
||||||
|
static const int blocks_x = 0;
|
||||||
|
static const int blocks_y = 0;
|
||||||
|
|
||||||
|
// Number of blocks
|
||||||
|
static const int blocks_count = 10;
|
||||||
|
#endif // KEYPRESS_FEEDBACK_PATCH
|
||||||
|
|
||||||
#if MESSAGE_PATCH
|
#if MESSAGE_PATCH
|
||||||
/* default message */
|
/* default message */
|
||||||
static const char * message = "Suckless: Software that sucks less.";
|
static const char * message = "Suckless: Software that sucks less.";
|
||||||
|
@ -3,6 +3,10 @@
|
|||||||
#include "message.c"
|
#include "message.c"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if KEYPRESS_FEEDBACK_PATCH
|
||||||
|
#include "keypress_feedback.c"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if PAMAUTH_PATCH
|
#if PAMAUTH_PATCH
|
||||||
#include "pamauth.c"
|
#include "pamauth.c"
|
||||||
#endif
|
#endif
|
||||||
|
@ -3,6 +3,10 @@
|
|||||||
#include "pamauth.h"
|
#include "pamauth.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if KEYPRESS_FEEDBACK_PATCH
|
||||||
|
#include "keypress_feedback.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if XRESOURCES_PATCH
|
#if XRESOURCES_PATCH
|
||||||
#include "xresources.h"
|
#include "xresources.h"
|
||||||
#endif
|
#endif
|
28
patch/keypress_feedback.c
Normal file
28
patch/keypress_feedback.c
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
static void
|
||||||
|
draw_key_feedback(Display *dpy, struct lock **locks, int screen)
|
||||||
|
{
|
||||||
|
XGCValues gr_values;
|
||||||
|
|
||||||
|
Window win = locks[screen]->win;
|
||||||
|
Window root_win;
|
||||||
|
|
||||||
|
gr_values.foreground = locks[screen]->colors[BLOCKS];
|
||||||
|
GC gc = XCreateGC(dpy, win, GCForeground, &gr_values);
|
||||||
|
|
||||||
|
int width = blocks_width, height = blocks_height;
|
||||||
|
if (blocks_height == 0 || blocks_width == 0) {
|
||||||
|
int _x, _y;
|
||||||
|
unsigned int screen_width, screen_height, _b, _d;
|
||||||
|
XGetGeometry(dpy, win, &root_win, &_x, &_y, &screen_width, &screen_height, &_b, &_d);
|
||||||
|
width = blocks_width ? blocks_width : screen_width;
|
||||||
|
height = blocks_height ? blocks_height : screen_height;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int block_width = width / blocks_count;
|
||||||
|
unsigned int position = rand() % blocks_count;
|
||||||
|
|
||||||
|
XClearWindow(dpy, win);
|
||||||
|
XFillRectangle(dpy, win, gc, blocks_x + position*block_width, blocks_y, width, height);
|
||||||
|
|
||||||
|
XFreeGC(dpy, gc);
|
||||||
|
}
|
1
patch/keypress_feedback.h
Normal file
1
patch/keypress_feedback.h
Normal file
@ -0,0 +1 @@
|
|||||||
|
static void draw_key_feedback(Display *dpy, struct lock **locks, int screen);
|
@ -30,6 +30,12 @@
|
|||||||
*/
|
*/
|
||||||
#define DPMS_PATCH 0
|
#define DPMS_PATCH 0
|
||||||
|
|
||||||
|
/* Draws random blocks on the screen to display keypress feedback.
|
||||||
|
* https://tools.suckless.org/slock/patches/keypress-feedback/
|
||||||
|
* https://patch-diff.githubusercontent.com/raw/phenax/bslock/pull/2.diff
|
||||||
|
*/
|
||||||
|
#define KEYPRESS_FEEDBACK_PATCH 0
|
||||||
|
|
||||||
/* This patch allows media keys to be used while the screen is locked. Allows for volume
|
/* 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.
|
* to be adjusted or to skip to the next song without having to unlock the screen first.
|
||||||
* https://tools.suckless.org/slock/patches/mediakeys/
|
* https://tools.suckless.org/slock/patches/mediakeys/
|
||||||
|
16
slock.c
16
slock.c
@ -20,6 +20,9 @@
|
|||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
|
|
||||||
#include "patches.h"
|
#include "patches.h"
|
||||||
|
#if KEYPRESS_FEEDBACK_PATCH
|
||||||
|
#include <time.h>
|
||||||
|
#endif // KEYPRESS_FEEDBACK_PATCH
|
||||||
#if CAPSCOLOR_PATCH
|
#if CAPSCOLOR_PATCH
|
||||||
#include <X11/XKBlib.h>
|
#include <X11/XKBlib.h>
|
||||||
#endif // CAPSCOLOR_PATCH
|
#endif // CAPSCOLOR_PATCH
|
||||||
@ -52,6 +55,9 @@ enum {
|
|||||||
#if PAMAUTH_PATCH
|
#if PAMAUTH_PATCH
|
||||||
PAM,
|
PAM,
|
||||||
#endif // PAMAUTH_PATCH
|
#endif // PAMAUTH_PATCH
|
||||||
|
#if KEYPRESS_FEEDBACK_PATCH
|
||||||
|
BLOCKS,
|
||||||
|
#endif // KEYPRESS_FEEDBACK_PATCH
|
||||||
NUMCOLS
|
NUMCOLS
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -301,6 +307,11 @@ readpw(Display *dpy, struct xrandr *rr, struct lock **locks, int nscreens,
|
|||||||
memcpy(passwd + len, buf, num);
|
memcpy(passwd + len, buf, num);
|
||||||
len += num;
|
len += num;
|
||||||
}
|
}
|
||||||
|
#if KEYPRESS_FEEDBACK_PATCH
|
||||||
|
if (blocks_enabled)
|
||||||
|
for (screen = 0; screen < nscreens; screen++)
|
||||||
|
draw_key_feedback(dpy, locks, screen);
|
||||||
|
#endif // KEYPRESS_FEEDBACK_PATCH
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#if CAPSCOLOR_PATCH
|
#if CAPSCOLOR_PATCH
|
||||||
@ -521,6 +532,11 @@ main(int argc, char **argv) {
|
|||||||
config_init(dpy);
|
config_init(dpy);
|
||||||
#endif // XRESOURCES_PATCH
|
#endif // XRESOURCES_PATCH
|
||||||
|
|
||||||
|
#if KEYPRESS_FEEDBACK_PATCH
|
||||||
|
time_t t;
|
||||||
|
srand((unsigned) time(&t));
|
||||||
|
#endif // KEYPRESS_FEEDBACK_PATCH
|
||||||
|
|
||||||
/* check for Xrandr support */
|
/* check for Xrandr support */
|
||||||
rr.active = XRRQueryExtension(dpy, &rr.evbase, &rr.errbase);
|
rr.active = XRRQueryExtension(dpy, &rr.evbase, &rr.errbase);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user