Codebase list i3lock-color / 06a5bee
Import upstream version 2.12.c.5 Kali Janitor 3 years ago
20 changed file(s) with 124 addition(s) and 59 deletion(s). Raw diff Collapse all Expand all
77 PointerBindsToType: false
88 ColumnLimit: 0
99 SpaceBeforeParens: ControlStatements
10 SortIncludes: false
00 name: Build Test
11
2 on:
3 push:
4 branches: [ master ]
5 pull_request:
6 branches: [ master ]
7
2 on: [push, pull_request]
83 jobs:
94 build:
10
115 runs-on: ubuntu-latest
12
136 steps:
147 - uses: actions/checkout@v2
15 - name: Install dependencies
8 - name: Install deps
169 run: sudo apt install pkg-config libpam0g-dev libcairo2-dev libfontconfig1-dev libxcb-composite0-dev libev-dev libx11-xcb-dev libxcb-xkb-dev libxcb-xinerama0-dev libxcb-randr0-dev libxcb-image0-dev libxcb-util-dev libxcb-xrm-dev libxkbcommon-dev libxkbcommon-x11-dev libjpeg-dev
17 - name: autoreconf
18 run: autoreconf -fiv
19 - name: configure
20 run: ./configure --prefix=/usr --sysconfdir=/etc
21 - name: make
22 run: make
23 - name: make check
24 run: make check
25 - name: make distcheck
26 run: make distcheck
10 - run: chmod +x build.sh
11 - run: ./build.sh
12 - run: cd build && make check
13 - run: cd build && make distcheck
14 - name: Upload binary artifact
15 uses: actions/upload-artifact@v2
16 with:
17 name: i3lock
18 path: /home/runner/work/i3lock-color/i3lock-color/build/i3lock
22 tags
33 *.swp
44 *.gz
5 /pam/i3lock
56
67 ################################################################################
78 # https://raw.githubusercontent.com/github/gitignore/master/Autotools.gitignore
2930 /install-sh
3031 /missing
3132 /stamp-h1
33 *.in~
34 pam/i3lock
66 compiler:
77 - gcc
88 - clang
9 addons:
10 apt:
11 packages:
12 - clang-format-3.5
139 script:
14 - clang-format-3.5 -i *.[ch] && git diff --exit-code || (echo 'Code was not formatted using clang-format!'; false)
1510 - docker build --pull --no-cache --rm -t=i3lock -f travis/Dockerfile .
11 - docker run -e CC=$CC -v $PWD:/usr/src:rw i3lock /bin/sh -c 'clang-format-9 -i *.[ch] && git diff --exit-code || (echo "Code was not formatted using clang-format!"; false)'
1612 - docker run -e CC=$CC -v $PWD:/usr/src:rw i3lock /bin/sh -c 'autoreconf -fi && mkdir -p build && cd build && (../configure || (cat config.log; false)) && make -j V=1 CFLAGS="-Wformat -Wformat-security -Wextra -Wno-unused-parameter -Werror"'
0 2.12.c.1-non-git
0 2.12.c.5
00 Copyright © 2010-2011, Michael Stapelberg
11 Copyright © 2015, Cassandra Fox
2 Copyright © 2015, Raymond Li
2 Copyright © 2020, Raymond Li
33 All rights reserved.
44
55 Redistribution and use in source and binary forms, with or without
6060 ### Ubuntu 18.04 LTS
6161 Run this command to install all dependencies:
6262 ```
63 sudo apt install pkg-config libpam0g-dev libcairo2-dev libfontconfig1-dev libxcb-composite0-dev libev-dev libx11-xcb-dev libxcb-xkb-dev libxcb-xinerama0-dev libxcb-randr0-dev libxcb-image0-dev libxcb-util-dev libxcb-xrm-dev libxkbcommon-dev libxkbcommon-x11-dev libjpeg-dev
63 sudo apt install autoconf gcc make pkg-config libpam0g-dev libcairo2-dev libfontconfig1-dev libxcb-composite0-dev libev-dev libx11-xcb-dev libxcb-xkb-dev libxcb-xinerama0-dev libxcb-randr0-dev libxcb-image0-dev libxcb-util-dev libxcb-xrm-dev libxkbcommon-dev libxkbcommon-x11-dev libjpeg-dev
6464 ```
6565
6666 ## Arch Linux
6767 - autoconf
6868 - cairo
6969 - fontconfig
70 - gcc
7071 - libev
7172 - libjpeg-turbo
7273 - libxinerama
8485
8586 **If you want to build a non-debug version, you should tag your build before configuring.** For example: `git tag -f "git-$(git rev-parse --short HEAD)"` will add a tag with the short commit ID, which will be used for the version info. Issues asking about ASAN/complaints about i3lock-color being slow / etc will likely be closed. i3lock-color uses GNU autotools for building.
8687
87 To build i3lock-color, first install the dependencies listed above, then run:
88 To use i3lock-color, first install the dependencies listed above, then clone the repo:
8889 ```
89 chmod +x make.sh
90 ./make.sh
90 git clone https://github.com/Raymo111/i3lock-color.git
91 cd i3lock-color
92 ```
93 To build without installing, run:
94 ```
95 chmod +x build.sh
96 ./build.sh
97 ```
98 To install after building, run:
99 ```
100 chmod +x install-i3lock-color.sh
101 ./install-i3lock-color.sh
91102 ```
92103 You may choose to modify the script based on your needs/OS/distro.
93104
00 #!/bin/bash
11 autoreconf -fiv
22
3 rm -rf build/
4 mkdir -p build && cd build/
3 BUILD_DIR=build/
4 rm -rf $BUILD_DIR
5 mkdir -vp $BUILD_DIR
6 cd $BUILD_DIR || { echo "cd $BUILD_DIR"; exit 127; }
57
6 ../configure --prefix=/usr --sysconfdir=/etc --disable-sanitizers
8 ../configure --prefix=/usr --sysconfdir=/etc
79
810 make
11 # Run autoreconf -fi to generate a configure script from this file.
22
33 AC_PREREQ([2.69])
4 AC_INIT([i3lock-color], [2.12.c.1], [https://github.com/Raymo11/i3lock-color/issues])
4 AC_INIT([i3lock-color], [m4_esyscmd_s([cat I3LOCK_VERSION])], [https://github.com/Raymo11/i3lock-color/issues])
55 # For AX_EXTEND_SRCDIR
66 AX_ENABLE_BUILDDIR
77 AM_INIT_AUTOMAKE([foreign subdir-objects -Wall no-dist-gzip dist-bzip2])
6565 AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
6666 AC_FUNC_STRNLEN
6767 AC_CHECK_FUNCS([atexit dup2 ftruncate getcwd gettimeofday localtime_r memchr memset mkdir rmdir setlocale socket strcasecmp strchr strdup strerror strncasecmp strndup strrchr strspn strstr strtol strtoul], , [AC_MSG_FAILURE([cannot find the $ac_func function, which i3lock requires])])
68 AC_CHECK_FUNCS([explicit_bzero])
6869
6970 # Checks for libraries.
7071
7475 AC_SEARCH_LIBS([ev_run], [ev], , [AC_MSG_FAILURE([cannot find the required ev_run() function despite trying to link with -lev])])
7576
7677 AC_SEARCH_LIBS([shm_open], [rt])
78
79 # Use system-auth instead of login on Arch (TODO: Implement Gentoo as well)
80 if [[ -f /etc/arch-release ]]; then
81 echo "Using PAM for Arch"
82 sed -i "s/^#auth include system-auth/auth include system-auth/g" ../pam/i3lock
83 sed -i "s/^auth include login/#auth include login/g" ../pam/i3lock
84 fi
7785
7886 # Only disable PAM on OpenBSD where i3lock uses BSD Auth instead
7987 case "$host" in
77 .fi
88 ..
99
10 .TH i3lock-color 1 "JANUARY 2012" Linux "User Manuals"
10 .TH i3lock-color 1 "JULY 2020" Linux "User Manuals"
1111
1212 .SH NAME
1313 i3lock-color \- improved screen locker
106106 .BI \-c\ rrggbbaa \fR,\ \fB\-\-color= rrggbbaa
107107 Turn the screen into the given color instead of white. Color must be given in 4-byte
108108 format: rrggbbaa (i.e. ff0000ff is opaque red).
109 Use the last byte for alpha. Setting this below FF (i.e. ff000088) will allow your screen to be shown translucently if you use a compositor (e.g. compton, xcompmgr).
109 Use the last byte for alpha. Setting this below FF (i.e. ff000088) will allow your screen to be shown translucently if you use a compositor (e.g. compton, xcompmgr).
110110
111111 .TP
112112 .B \-t, \-\-tiling
147147
148148 .SH i3lock-color options
149149 .TP
150 .B \-S=number, \-\-screen=number
150 .B \-S number, \-\-screen=number
151151 Specifies which display to draw the unlock indicator and clock on. By default, they'll be placed on every screen.
152152 Note that this number is zero indexed. The ordering is dependent on libxinerama.
153153
154154 .TP
155 .B \-B=sigma, \-\-blur=sigma
155 .B \-B sigma, \-\-blur=sigma
156156 Captures the screen and blurs it using the given sigma (radius).
157157 Images may still be overlaid over the blurred screenshot.
158158 As an alternative to this option, you could specify a translucent background color
197197 .B \-\-pass\-power\-keys
198198 Allow the following keys to be used while the screen is locked by passing them through:
199199 XF86PowerDown, XF86PowerOff, XF86Sleep.
200
201 .TP
202 .B \-\-pass\-volume\-keys
203 Allow the following keys to be used while the screen is locked by passing them through:
204 XF86AudioMute, XF86AudioLowerVolume, XF86AudioRaiseVolume.
200205
201206 .TP
202207 .B \-\-insidevercolor=rrggbbaa
336341
337342 .TP
338343 .B \-\-greeterpos="x position:y position"
339 Sets the position for the date string. All the variables from \-\-indpos and \-\-timepos may be used.
344 Sets the position for the greeter string. All the variables from \-\-indpos and \-\-timepos may be used.
340345
341346 .TP
342347 .B \-\-refresh\-rate=seconds\-as\-double
458463
459464 Pandora <pandora at techfo dot xyz>
460465
461 Raymond Li <hi at raymond.li>
466 Raymond Li <i3lock-color at raymond.li>
22 *
33 * © 2010 Michael Stapelberg
44 * © 2015 Cassandra Fox
5 * © 2020 Raymond Li
56 *
67 * See LICENSE for licensing information
78 *
1617 #include <stdlib.h>
1718 #include <pwd.h>
1819 #include <sys/types.h>
19 #include <string.h>
2020 #include <dirent.h>
2121 #include <unistd.h>
2222 #include <stdbool.h>
4343 #include <xkbcommon/xkbcommon-x11.h>
4444 #include <cairo.h>
4545 #include <cairo/cairo-xcb.h>
46 #ifdef __OpenBSD__
46 #ifdef HAVE_EXPLICIT_BZERO
4747 #include <strings.h> /* explicit_bzero(3) */
4848 #endif
4949 #include <xcb/xcb_aux.h>
234234 bool pass_media_keys = false;
235235 bool pass_screen_keys = false;
236236 bool pass_power_keys = false;
237 bool pass_volume_keys = false;
237238
238239 // for the rendering thread, so we can clean it up
239240 pthread_t draw_thread;
402403 *
403404 */
404405 static void clear_password_memory(void) {
405 #ifdef __OpenBSD__
406 #ifdef HAVE_EXPLICIT_BZERO
406407 /* Use explicit_bzero(3) which was explicitly designed not to be
407408 * optimized out by the compiler. */
408409 explicit_bzero(password, strlen(password));
693694 case XKB_KEY_XF86PowerDown:
694695 case XKB_KEY_XF86PowerOff:
695696 case XKB_KEY_XF86Sleep:
697 xcb_send_event(conn, true, screen->root, XCB_EVENT_MASK_BUTTON_PRESS, (char *)event);
698 return;
699 }
700 }
701
702 // volume keys
703 if (pass_volume_keys) {
704 switch(ksym) {
705 case XKB_KEY_XF86AudioMute:
706 case XKB_KEY_XF86AudioLowerVolume:
707 case XKB_KEY_XF86AudioRaiseVolume:
696708 xcb_send_event(conn, true, screen->root, XCB_EVENT_MASK_BUTTON_PRESS, (char *)event);
697709 return;
698710 }
880892 event->state_notify.baseGroup,
881893 event->state_notify.latchedGroup,
882894 event->state_notify.lockedGroup);
895 layout_text = get_keylayoutname(keylayout_mode, conn);
896 redraw_screen();
883897 break;
884898 }
885899 }
890904 * and also redraw the image, if any.
891905 *
892906 */
893 void handle_screen_resize(void) {
907 static void handle_screen_resize(void) {
894908 xcb_get_geometry_cookie_t geomc;
895909 xcb_get_geometry_reply_t *geom;
896910 geomc = xcb_get_geometry(conn, screen->root);
14651479 {"pass-media-keys", no_argument, NULL, 601},
14661480 {"pass-screen-keys", no_argument, NULL, 602},
14671481 {"pass-power-keys", no_argument, NULL, 603},
1482 {"pass-volume-keys", no_argument, NULL, 604},
14681483
14691484 // bar indicator stuff
14701485 {"bar-indicator", no_argument, NULL, 700},
14981513 char *optstring = "hvnbdc:p:ui:tCeI:frsS:kB:m";
14991514 char *arg = NULL;
15001515 int opt = 0;
1516 char padded[9] = "ffffffff"; \
15011517
15021518 #define parse_color(acolor)\
15031519 arg = optarg;\
15041520 if (arg[0] == '#') arg++;\
15051521 if (strlen(arg) == 6) {\
15061522 /* If 6 digits given, assume RGB and pad 0xff for alpha */\
1507 char padded[9] = "ffffffff"; \
15081523 strncpy( padded, arg, 6 );\
15091524 arg = padded;\
15101525 }\
15141529 while ((o = getopt_long(argc, argv, optstring, longopts, &longoptind)) != -1) {
15151530 switch (o) {
15161531 case 'v':
1517 errx(EXIT_SUCCESS, "version " I3LOCK_VERSION " © 2010 Michael Stapelberg, © 2015 Cassandra Fox");
1532 errx(EXIT_SUCCESS, "version " I3LOCK_VERSION " © 2010 Michael Stapelberg, © 2015 Cassandra Fox, © 2020 Raymond Li");
15181533 case 'n':
15191534 dont_fork = true;
15201535 break;
15871602
15881603 // Begin colors
15891604 case 'c':
1590 parse_color(color);
1605 parse_color(color);
15911606 break;
15921607 case 300:
15931608 parse_color(insidevercolor);
19401955 break;
19411956 case 603:
19421957 pass_power_keys = true;
1958 break;
1959 case 604:
1960 pass_volume_keys = true;
19431961 break;
19441962
19451963 // Bar indicator
77 * This is important because xautolock (for example) closes stdout/stderr by
88 * default, so just printing something to stdout will lead to the data ending
99 * up on the X11 socket (!). */
10 #define DEBUG(fmt, ...) \
11 do { \
12 if (debug_mode) \
13 printf("[i3lock-debug] " fmt, ##__VA_ARGS__); \
10 #define DEBUG(fmt, ...) \
11 do { \
12 if (debug_mode) { \
13 fprintf(stderr, "[i3lock-debug] " fmt, ##__VA_ARGS__); \
14 } \
1415 } while (0)
1516
1617 #endif
0 #!/bin/bash
1 ./build.sh
2
3 sudo make install
4
5 sudo install -Dm644 ../LICENSE "/usr/share/licenses/i3lock-color/LICENSE"
6262 # LICENSE
6363 #
6464 # Copyright (c) 2016 Michael Stapelberg <[email protected]>
65 # Copyright (c) 2020 Raymond Li <[email protected]>
6566 #
6667 # Copying and distribution of this file, with or without modification, are
6768 # permitted in any medium without royalty provided the copyright notice
6868 # LICENSE
6969 #
7070 # Copyright (c) 2016 Michael Stapelberg <[email protected]>
71 # Copyright (c) 2020 Raymond Li <[email protected]>
7172 #
7273 # Copying and distribution of this file, with or without modification,
7374 # are permitted in any medium without royalty provided the copyright
00 #
1 # PAM configuration file for the i3lock screen locker. By default, it includes
2 # the 'login' configuration file (see /etc/pam.d/login)
1 # PAM configuration file for the i3lock-color screen locker. By default, it includes
2 # the 'system-auth' configuration file (see /etc/pam.d/system-auth) for Arch and Gentoo
3 # and 'login' for Debian. Note that vanilla i3lock upstream uses 'login' instead.
34 #
45
5 auth include login
6 #auth include system-auth # For Arch/Gentoo
7 auth include login # For Debian
11 * vim:ts=4:sw=4:expandtab
22 *
33 * © 2010 Michael Stapelberg
4 * © 2020 Raymond Li
45 *
56 * See LICENSE for licensing information
67 *
1010 # (3608 kB/s)). Hence, let’s stick with httpredir.debian.org (default) for now.
1111
1212 # Install mk-build-deps (for installing the i3 build dependencies),
13 # clang and clang-format-3.8 (for checking formatting and building with clang),
13 # clang and clang-format-9 (for checking formatting and building with clang),
1414 # lintian (for checking spelling errors),
1515 # test suite dependencies (for running tests)
1616 RUN apt-get update && \
1818 build-essential clang git autoconf automake libxcb-randr0-dev pkg-config libpam0g-dev \
1919 libcairo2-dev libxcb1-dev libxcb-dpms0-dev libxcb-image0-dev libxcb-util0-dev \
2020 libxcb-xrm-dev libev-dev libxcb-xinerama0-dev libxcb-xkb-dev libxkbcommon-dev \
21 libxkbcommon-x11-dev && \
21 libxkbcommon-x11-dev clang-format-9 && \
2222 rm -rf /var/lib/apt/lists/*
2323
2424 WORKDIR /usr/src
11 * vim:ts=4:sw=4:expandtab
22 *
33 * © 2010 Michael Stapelberg
4 * © 2010 Cassandra Fox
4 * © 2015 Cassandra Fox
5 * © 2020 Raymond Li
56 *
67 * See LICENSE for licensing information
78 *
895896 screen_number = 0;
896897 }
897898
899 DEBUG("Drawing indicator on %d screens\n", screen_number);
900
898901 int current_screen = screen_number == 0 ? 0 : screen_number - 1;
899902 const int end_screen = screen_number == 0 ? xr_screens : screen_number;
900903 for (; current_screen < end_screen; current_screen++) {
00 /*
11 * vim:ts=4:sw=4:expandtab
22 *
3 * © 2010 Michael Stapelberg
3 * © 2010 Michael
4 * @ © 2020 Raymond Li
45 *
56 * xcb.c: contains all functions which use XCB to talk to X11. Mostly wrappers
67 * around the rather complicated/ugly parts of the XCB API.
535536 }
536537
537538
539 uint8_t xcb_get_key_group_index(xcb_connection_t *conn) {
540 xcb_xkb_get_state_cookie_t cookie;
541 xcb_xkb_get_state_reply_t* reply = NULL;
542 cookie = xcb_xkb_get_state(conn, XCB_XKB_ID_USE_CORE_KBD);
543 reply = xcb_xkb_get_state_reply(conn, cookie, NULL);
544 uint8_t ans = reply->group;
545 free(reply);
546 return ans;
547 }
548
549
538550 char* xcb_get_key_group_names(xcb_connection_t *conn) {
539551 uint8_t xkb_base_event;
540552 uint8_t xkb_base_error;
583595
584596 int length;
585597 xcb_atom_t *iter;
598 uint8_t index;
586599 char* answer = NULL;
587600 length = xcb_xkb_get_names_value_list_groups_length(reply, &list);
588601 iter = xcb_xkb_get_names_value_list_groups(&list);
602 index = xcb_get_key_group_index(conn);
589603
590604 for (int i = 0; i < length; i++) {
591605 xcb_atom_t group_name = *iter;
592606 char* name = get_atom_name(conn, group_name);
593607 DEBUG("group_name %d: %s\n", i, name);
594 if (i == 0) {
608 if (i == index) {
595609 answer = name;
596610 } else {
597611 free(name);