mirror of
https://github.com/Raymo111/i3lock-color.git
synced 2024-11-03 04:23:38 -05:00
index on master: 4f95adb
merge upstream
This commit is contained in:
parent
4f95adb238
commit
9d065441ca
2 changed files with 46 additions and 2 deletions
4
Makefile
4
Makefile
|
@ -20,8 +20,8 @@ SIMD_CFLAGS += -funroll-loops
|
|||
SIMD_CFLAGS += -msse2
|
||||
CPPFLAGS += -D_GNU_SOURCE
|
||||
CPPFLAGS += -DXKBCOMPOSE=$(shell if test -e /usr/include/xkbcommon/xkbcommon-compose.h ; then echo 1 ; else echo 0 ; fi )
|
||||
CFLAGS += $(shell $(PKG_CONFIG) --cflags cairo xcb-composite xcb-xinerama xcb-randr xcb-atom xcb-image xcb-xkb xkbcommon xkbcommon-x11)
|
||||
LIBS += $(shell $(PKG_CONFIG) --libs cairo xcb-composite xcb-xinerama xcb-randr xcb-atom xcb-image xcb-xkb xkbcommon xkbcommon-x11)
|
||||
CFLAGS += $(shell $(PKG_CONFIG) --cflags cairo xcb-composite xcb-xinerama xcb-randr xcb-atom xcb-image xcb-xkb xkbcommon xkbcommon-x11 x11)
|
||||
LIBS += $(shell $(PKG_CONFIG) --libs cairo xcb-composite xcb-xinerama xcb-randr xcb-atom xcb-image xcb-xkb xkbcommon xkbcommon-x11 x11)
|
||||
LIBS += -lev
|
||||
LIBS += -lm
|
||||
|
||||
|
|
44
i3lock.c
44
i3lock.c
|
@ -40,6 +40,7 @@
|
|||
#endif
|
||||
#include <xcb/xcb_aux.h>
|
||||
#include <xcb/randr.h>
|
||||
#include <X11/XKBlib.h>
|
||||
|
||||
#include "i3lock.h"
|
||||
#include "xcb.h"
|
||||
|
@ -174,6 +175,47 @@ void u8_dec(char *s, int *i) {
|
|||
* translate keypresses to utf-8.
|
||||
*
|
||||
*/
|
||||
|
||||
char* get_keylayoutname(void) {
|
||||
Display *display;
|
||||
XkbDescPtr keyboard;
|
||||
XkbStateRec state;
|
||||
int result;
|
||||
|
||||
display = XkbOpenDisplay( getenv("DISPLAY") , NULL, NULL, NULL, NULL, &result );
|
||||
if( !display ) {
|
||||
errx(1, "X server unreachable");
|
||||
}
|
||||
|
||||
keyboard = XkbAllocKeyboard();
|
||||
|
||||
if ( XkbGetNames(display, XkbGroupNamesMask, keyboard) != Success ) {
|
||||
errx(1, "Error obtaining symbolic names");
|
||||
}
|
||||
|
||||
if( XkbGetState(display, XkbUseCoreKbd, &state) != Success ) {
|
||||
errx(1, "Error getting keyboard state");
|
||||
}
|
||||
|
||||
printf( "aaa: %s\n", XGetAtomName(display, keyboard->names->groups[state.group]) );
|
||||
|
||||
Atom current_group;
|
||||
int i = 0;
|
||||
for (; i < XkbNumKbdGroups; i++) {
|
||||
if ( (current_group = keyboard->names->groups[i]) != 0 ) {
|
||||
char* group_name = XGetAtomName(display, current_group);
|
||||
if (group_name != NULL) {
|
||||
printf( "bbb: %d. %s\n", i, group_name );
|
||||
}
|
||||
XFree(group_name);
|
||||
}
|
||||
}
|
||||
|
||||
// Free symbolic names structures
|
||||
XkbFreeNames(keyboard, XkbGroupNamesMask, True);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static bool load_keymap(void) {
|
||||
if (xkb_context == NULL) {
|
||||
if ((xkb_context = xkb_context_new(0)) == NULL) {
|
||||
|
@ -963,6 +1005,8 @@ int main(int argc, char *argv[]) {
|
|||
if ((username = pw->pw_name) == NULL)
|
||||
errx(EXIT_FAILURE, "pw->pw_name is NULL.\n");
|
||||
|
||||
(void) get_keylayoutname();
|
||||
|
||||
char *optstring = "hvnbdc:p:ui:teI:frsS:kB:";
|
||||
while ((o = getopt_long(argc, argv, optstring, longopts, &longoptind)) != -1) {
|
||||
switch (o) {
|
||||
|
|
Loading…
Reference in a new issue