Import upstream version 2.13.c.2
Kali Janitor
2 years ago
23 | 23 | ## Environment |
24 | 24 | Output of `i3lock --version`: |
25 | 25 | <pre> |
26 | i3lock version: | |
26 | i3lock version: | |
27 | 27 | </pre> |
28 | 28 | |
29 | 29 | Where'd you get i3lock-color from? |
20 | 20 | |
21 | 21 | strategy: |
22 | 22 | fail-fast: false |
23 | matrix: | |
23 | # matrix: | |
24 | 24 | # Override automatic language detection by changing the below list |
25 | 25 | # Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python'] |
26 | language: ['cpp'] | |
26 | # language: ['cpp'] | |
27 | 27 | # Learn more... |
28 | 28 | # https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection |
29 | 29 | |
37 | 37 | |
38 | 38 | # If this run was triggered by a pull request event, then checkout |
39 | 39 | # the head of the pull request instead of the merge commit. |
40 | - run: git checkout HEAD^2 | |
41 | if: ${{ github.event_name == 'pull_request' }} | |
40 | # CodeQL apparently deprecated this feature and now warns on running this command | |
41 | # - run: git checkout HEAD^2 | |
42 | # if: ${{ github.event_name == 'pull_request' }} | |
42 | 43 | |
43 | 44 | # Initializes the CodeQL tools for scanning. |
44 | 45 | - name: Initialize CodeQL |
46 | 47 | with: |
47 | 48 | languages: ${{ matrix.language }} |
48 | 49 | # If you wish to specify custom queries, you can do so here or in a config file. |
49 | # By default, queries listed here will override any specified in a config file. | |
50 | # By default, queries listed here will override any specified in a config file. | |
50 | 51 | # Prefix the list here with "+" to use these queries and those in the config file. |
51 | 52 | # queries: ./path/to/local/query, your-org/your-repo/queries@main |
52 | 53 |
2 | 2 | tags |
3 | 3 | *.swp |
4 | 4 | *.gz |
5 | /pam/i3lock | |
5 | *~ | |
6 | 6 | |
7 | 7 | ################################################################################ |
8 | 8 | # https://raw.githubusercontent.com/github/gitignore/master/Autotools.gitignore |
30 | 30 | /install-sh |
31 | 31 | /missing |
32 | 32 | /stamp-h1 |
33 | *.in~ | |
34 | pam/i3lock |
0 | 0 | # i3lock-color |
1 | 1 | |
2 | 2 | ![Language count](https://img.shields.io/github/languages/count/Raymo111/i3lock-color) |
3 | ![Top language](https://img.shields.io/github/languages/top/Raymo111/i3lock-color) | |
3 | [![Top language](https://img.shields.io/github/languages/top/Raymo111/i3lock-color)](https://github.com/Raymo111/i3lock-color/search?l=c) | |
4 | 4 | ![Repo size](https://img.shields.io/github/repo-size/Raymo111/i3lock-color) |
5 | ![Open issues](https://img.shields.io/github/issues-raw/Raymo111/i3lock-color) | |
6 | ![Closed issues](https://img.shields.io/github/issues-closed-raw/Raymo111/i3lock-color?color=brightgreen) | |
7 | ![Open PRs](https://img.shields.io/github/issues-pr-raw/Raymo111/i3lock-color?label=open%20PRs) | |
8 | ![Closed PRs](https://img.shields.io/github/issues-pr-closed-raw/Raymo111/i3lock-color?color=brightgreen&label=closed%20PRs) | |
9 | ![Contributor count](https://img.shields.io/github/contributors/Raymo111/i3lock-color) | |
10 | ![GitHub Release Date](https://img.shields.io/github/release-date/Raymo111/i3lock-color?label=latest%20release) | |
11 | ![Commits](https://img.shields.io/github/commits-since/Raymo111/i3lock-color/latest?include_prereleases&sort=semver) | |
5 | [![Open issues](https://img.shields.io/github/issues-raw/Raymo111/i3lock-color)](https://github.com/Raymo111/i3lock-color/issues?q=is%3Aopen+is%3Aissue) | |
6 | [![Closed issues](https://img.shields.io/github/issues-closed-raw/Raymo111/i3lock-color?color=brightgreen)](https://github.com/Raymo111/i3lock-color/issues?q=is%3Aissue+is%3Aclosed) | |
7 | [![Open PRs](https://img.shields.io/github/issues-pr-raw/Raymo111/i3lock-color?label=open%20PRs)](https://github.com/Raymo111/i3lock-color/pulls?q=is%3Aopen+is%3Apr) | |
8 | [![Closed PRs](https://img.shields.io/github/issues-pr-closed-raw/Raymo111/i3lock-color?color=brightgreen&label=closed%20PRs)](https://github.com/Raymo111/i3lock-color/pulls?q=is%3Apr+is%3Aclosed) | |
9 | [![Contributors](https://img.shields.io/github/contributors/Raymo111/i3lock-color)](https://github.com/Raymo111/i3lock-color/graphs/contributors) | |
10 | [![Latest release](https://img.shields.io/github/release-date/Raymo111/i3lock-color?label=latest%20release)](https://github.com/Raymo111/i3lock-color/releases/latest) | |
11 | [![Commits](https://img.shields.io/github/commits-since/Raymo111/i3lock-color/latest?include_prereleases&sort=semver)](https://github.com/Raymo111/i3lock-color/commits/master) | |
12 | 12 | ![Latest commit](https://img.shields.io/github/last-commit/Raymo111/i3lock-color) |
13 | ![Arch Linux package](https://img.shields.io/archlinux/v/community/x86_64/i3lock-color?logo=arch%20linux&label=Community%20version) | |
14 | ![AUR git ver](https://img.shields.io/aur/version/i3lock-color-git?label=AUR%20git%20ver) | |
13 | <!--![Arch Linux package](https://img.shields.io/archlinux/v/community/x86_64/i3lock-color?logo=arch%20linux&label=Community%20version)--> | |
14 | [![AUR release ver](https://img.shields.io/aur/version/i3lock-color?label=AUR%20release%20ver)](https://aur.archlinux.org/packages/i3lock-color/) | |
15 | [![AUR git ver](https://img.shields.io/aur/version/i3lock-color-git?label=AUR%20git%20ver)](https://aur.archlinux.org/packages/i3lock-color-git/) | |
15 | 16 | ![AUR votes](https://img.shields.io/aur/votes/i3lock-color-git) |
16 | ![GitHub forks](https://img.shields.io/github/forks/Raymo111/i3lock-color) | |
17 | ![GitHub stars](https://img.shields.io/github/stars/Raymo111/i3lock-color) | |
18 | ![GitHub watchers](https://img.shields.io/github/watchers/Raymo111/i3lock-color) | |
19 | ![Maintenance](https://img.shields.io/maintenance/yes/2020) | |
17 | [![GitHub forks](https://img.shields.io/github/forks/Raymo111/i3lock-color)](https://github.com/Raymo111/i3lock-color/network/members) | |
18 | [![GitHub stars](https://img.shields.io/github/stars/Raymo111/i3lock-color)](https://github.com/Raymo111/i3lock-color/stargazers) | |
19 | [![GitHub watchers](https://img.shields.io/github/watchers/Raymo111/i3lock-color)](https://github.com/Raymo111/i3lock-color/watchers) | |
20 | ![Maintained](https://img.shields.io/maintenance/yes/2021) | |
20 | 21 | |
21 | 22 | ### The world's most popular non-default computer lockscreen. |
22 | 23 | **A modern version of i3lock with color functionality and other features.** |
23 | 24 | |
24 | ![i3lock-color in action](screenshot.png "Screenshot sample") | |
25 | ![i3lock-color in action](examples/screenshot.png "Screenshot sample") | |
25 | 26 | |
26 | 27 | i3lock is a simple screen locker like slock. After starting it, you will see a white screen (you can configure the color/an image). You can return to your screen by entering your password. |
27 | 28 | |
45 | 46 | - Key highlight color |
46 | 47 | - Backspace highlight color |
47 | 48 | - Text colors for most/all strings |
49 | - Outline colors | |
48 | 50 | - Changing all of the above depending on PAM's authentication status |
49 | 51 | - Blurring the current screen and using that as the lock background |
50 | 52 | - Showing a clock in the indicator |
51 | 53 | - Refreshing on a timer, instead of on each keypress |
52 | 54 | - Positioning the various UI elements |
53 | 55 | - Changing the ring radius and thickness, as well as text size |
54 | - Passthrough media keys | |
56 | - Options for passwordless auth, removing modkey indicator | |
57 | - Passing through media keys | |
55 | 58 | - A new bar indicator, which replaces the ring indicator with its own set of options |
56 | 59 | - An experimental thread for driving the redraw ticks, so that things like the bar/clock still update when PAM is blocking |
60 | - Any other feature you want (add it yourself through a PR or make a feature request issue!) | |
57 | 61 | |
58 | 62 | ## Dependencies |
59 | 63 | The following dependencies will need to be installed for a successful build, depending on your OS/distro. |
60 | ||
61 | ### Ubuntu 18/20.04 LTS | |
62 | Run this command to install all dependencies: | |
63 | ``` | |
64 | 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 | |
65 | ``` | |
66 | ||
67 | ### Debian | |
68 | Replace `libxcb-util-dev` with `libxcb-util0-dev` in the Ubuntu installation command: | |
69 | ``` | |
70 | 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-util0-dev libxcb-xrm-dev libxkbcommon-dev libxkbcommon-x11-dev libjpeg-dev | |
71 | ``` | |
72 | 64 | |
73 | 65 | ### Arch Linux |
74 | 66 | - autoconf |
85 | 77 | - xcb-util-image |
86 | 78 | - xcb-util-xrm |
87 | 79 | |
80 | ### Debian | |
81 | Run this command to install all dependencies: | |
82 | ``` | |
83 | 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-util0-dev libxcb-xrm-dev libxkbcommon-dev libxkbcommon-x11-dev libjpeg-dev | |
84 | ``` | |
85 | ||
88 | 86 | ### Fedora |
89 | 87 | Run this command to install all dependencies: |
90 | 88 | |
92 | 90 | sudo dnf install -y autoconf automake cairo-devel fontconfig gcc libev-devel libjpeg-turbo-devel libXinerama libxkbcommon-devel libxkbcommon-x11-devel libXrandr pam-devel pkgconf xcb-util-image-devel xcb-util-xrm-devel |
93 | 91 | ``` |
94 | 92 | |
93 | ### Ubuntu 18/20.04 LTS | |
94 | Run this command to install all dependencies: | |
95 | ``` | |
96 | 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 | |
97 | ``` | |
98 | ||
95 | 99 | ## Building i3lock-color |
96 | 100 | Before you build - check and see if there's a packaged version available for your distro (there usually is, either in a community repo/PPA). |
97 | 101 | |
98 | If there's no packaged version available - think carefully, since you're using a forked screen locker at your own risk. | |
102 | **If you want to build a non-debug version, you should tag your build before configuring.** | |
99 | 103 | |
100 | **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. | |
104 | 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. | |
101 | 105 | |
102 | To use i3lock-color, first install the dependencies listed above, then clone the repo: | |
106 | i3lock-color uses GNU autotools for building. | |
107 | ||
108 | To build/install i3lock-color, first install the dependencies listed above, then clone the repo: | |
103 | 109 | ``` |
104 | 110 | git clone https://github.com/Raymo111/i3lock-color.git |
105 | 111 | cd i3lock-color |
109 | 115 | chmod +x build.sh |
110 | 116 | ./build.sh |
111 | 117 | ``` |
112 | To install after building, run: | |
118 | To build AND install, run: | |
113 | 119 | ``` |
114 | 120 | chmod +x install-i3lock-color.sh |
115 | 121 | ./install-i3lock-color.sh |
117 | 123 | You may choose to modify the script based on your needs/OS/distro. |
118 | 124 | |
119 | 125 | ## Arch Linux Packages |
120 | [Stable version in Community](https://www.archlinux.org/packages/community/x86_64/i3lock-color/) | |
126 | ~~[Stable version in Community](https://www.archlinux.org/packages/community/x86_64/i3lock-color/)~~ | |
121 | 127 | |
122 | [Git Version on AUR](https://aur.archlinux.org/packages/i3lock-color-git/) | |
128 | Unfortunately the previous maintainer left, and the package got dumped back into the AUR where I'm now maintaining it. I'm looking for a TU to sponsor it back into Community, but for now, get it on AUR: | |
129 | - [Release Version on AUR](https://aur.archlinux.org/packages/i3lock-color/) | |
130 | - [Git Version on AUR](https://aur.archlinux.org/packages/i3lock-color-git/) | |
131 | ||
132 | ## Gentoo Package | |
133 | i3lock-color is available on **GURU**, under [`x11-misc/i3lock-color`](https://github.com/gentoo/guru/tree/master/x11-misc/i3lock-color). | |
123 | 134 | |
124 | 135 | ## FreeBSD port |
125 | [i3lock-color-port](https://github.com/rkashapov/i3lock-color-port/) | |
136 | ~~[i3lock-color-port](https://github.com/rkashapov/i3lock-color-port/)~~ (severely out of date). | |
126 | 137 | |
127 | 138 | ## Running i3lock-color |
128 | 139 | Simply invoke the 'i3lock' command. To get out of it, enter your password and press enter. |
129 | 140 | |
130 | A [sample script](lock.sh) is included in this repository. [See the script in action](https://streamable.com/fpl46) | |
141 | A [sample script](examples/lock.sh) is included in this repository. [See the script in action](https://streamable.com/fpl46) | |
131 | 142 | |
132 | 143 | On OpenBSD the `i3lock` binary needs to be setgid `auth` to call the authentication helpers, e.g. `/usr/libexec/auth/login_passwd`. |
133 | 144 | |
135 | 146 | This project was started by [eBrnd](https://github.com/eBrnd/i3lock-color), maintained for a few years by [PandorasFox](https://github.com/PandorasFox) and now maintained and being developed by [Raymo111](https://github.com/Raymo111). The full list of contributors can be found [here](https://github.com/Raymo111/i3lock-color/graphs/contributors). |
136 | 147 | |
137 | 148 | ## Upstream |
138 | Please submit pull requests for i3lock things to https://github.com/i3/i3lock and pull requests for additional features on top of regular i3lock at https://github.com/Raymo111/i3lock-color. | |
149 | Please submit pull requests for i3lock things to [https://github.com/i3/i3lock](https://github.com/i3/i3lock) and pull requests for additional features on top of regular i3lock at [https://github.com/Raymo111/i3lock-color](https://github.com/Raymo111/i3lock-color). |
13 | 13 | #endif |
14 | 14 | void blur_impl_horizontal_pass_generic(uint32_t *src, uint32_t *dst, int width, int height); |
15 | 15 | #endif |
16 | ||
17 |
1 | 1 | # Run autoreconf -fi to generate a configure script from this file. |
2 | 2 | |
3 | 3 | AC_PREREQ([2.69]) |
4 | AC_INIT([i3lock-color], [m4_esyscmd_s([cat I3LOCK_VERSION])], [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]) | |
5 | 5 | # For AX_EXTEND_SRCDIR |
6 | 6 | AX_ENABLE_BUILDDIR |
7 | 7 | AM_INIT_AUTOMAKE([foreign subdir-objects -Wall no-dist-gzip dist-bzip2]) |
49 | 49 | dnl on its fourth argument. |
50 | 50 | AX_CHECK_ENABLE_DEBUG([yes], , [UNUSED_NDEBUG], [$is_release]) |
51 | 51 | |
52 | AC_PROG_CC_C99 | |
52 | AC_PROG_CC | |
53 | 53 | |
54 | 54 | # For strnlen() and vasprintf(). |
55 | 55 | AC_USE_SYSTEM_EXTENSIONS |
67 | 67 | 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 | 68 | AC_CHECK_FUNCS([explicit_bzero]) |
69 | 69 | |
70 | # Checks for libraries. | |
71 | ||
70 | # Check for libraries | |
72 | 71 | AC_SEARCH_LIBS([floor], [m], , [AC_MSG_FAILURE([cannot find the required floor() function despite trying to link with -lm])]) |
73 | 72 | |
74 | 73 | # libev does not ship with a pkg-config file :(. |
76 | 75 | |
77 | 76 | AC_SEARCH_LIBS([shm_open], [rt]) |
78 | 77 | |
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 | |
78 | # Use system-local-login instead of login on Arch and Gentoo | |
79 | if [[ -f /etc/arch-release ]] || [[ -f /etc/gentoo-release ]]; then | |
80 | echo "Using PAM for Arch/Gentoo" | |
81 | sed -i "s/^#auth include system-local-login/auth include system-local-login/g" ../pam/i3lock | |
83 | 82 | sed -i "s/^auth include login/#auth include login/g" ../pam/i3lock |
84 | 83 | fi |
85 | 84 |
0 | #!/bin/sh | |
1 | ||
2 | B='#00000000' # blank | |
3 | C='#ffffff22' # clear ish | |
4 | D='#ff00ffcc' # default | |
5 | T='#ee00eeee' # text | |
6 | W='#880000bb' # wrong | |
7 | V='#bb00bbbb' # verifying | |
8 | ||
9 | i3lock \ | |
10 | --insidevercolor=$C \ | |
11 | --ringvercolor=$V \ | |
12 | \ | |
13 | --insidewrongcolor=$C \ | |
14 | --ringwrongcolor=$W \ | |
15 | \ | |
16 | --insidecolor=$B \ | |
17 | --ringcolor=$D \ | |
18 | --linecolor=$B \ | |
19 | --separatorcolor=$D \ | |
20 | \ | |
21 | --verifcolor=$T \ | |
22 | --wrongcolor=$T \ | |
23 | --timecolor=$T \ | |
24 | --datecolor=$T \ | |
25 | --layoutcolor=$T \ | |
26 | --keyhlcolor=$W \ | |
27 | --bshlcolor=$W \ | |
28 | \ | |
29 | --screen 1 \ | |
30 | --blur 5 \ | |
31 | --clock \ | |
32 | --indicator \ | |
33 | --timestr="%H:%M:%S" \ | |
34 | --datestr="%A, %m %Y" \ | |
35 | --keylayout 1 \ |
0 | #!/bin/sh | |
1 | ||
2 | B='#00000000' # blank | |
3 | C='#ffffff22' # clear ish | |
4 | D='#ff00ffcc' # default | |
5 | T='#ee00eeee' # text | |
6 | W='#880000bb' # wrong | |
7 | V='#bb00bbbb' # verifying | |
8 | ||
9 | i3lock \ | |
10 | --blur 5 \ | |
11 | --bar-indicator \ | |
12 | --bar-position y+h \ | |
13 | --bar-direction 1 \ | |
14 | --bar-max-height 50 \ | |
15 | --bar-base-width 50 \ | |
16 | --bar-color 000000cc \ | |
17 | --keyhlcolor 880088cc \ | |
18 | --bar-periodic-step 50 \ | |
19 | --bar-step 50 \ | |
20 | --redraw-thread \ | |
21 | \ | |
22 | --clock \ | |
23 | --force-clock \ | |
24 | --timepos x+5:y+h-80 \ | |
25 | --timecolor 880088ff \ | |
26 | --datepos tx:ty+15 \ | |
27 | --datecolor 990099ff \ | |
28 | --date-align 1 \ | |
29 | --time-align 1 \ | |
30 | --ringvercolor 8800ff88 \ | |
31 | --ringwrongcolor ff008888 \ | |
32 | --statuspos x+5:y+h-16 \ | |
33 | --verif-align 1 \ | |
34 | --wrong-align 1 \ | |
35 | --verifcolor ffffffff \ | |
36 | --wrongcolor ffffffff \ | |
37 | --modifpos -50:-50 |
Binary diff not shown
18 | 18 | |
19 | 19 | char str[512]; |
20 | 20 | double size; |
21 | double outline_width; | |
21 | 22 | |
22 | 23 | cairo_font_face_t *font; |
23 | 24 | |
24 | 25 | rgba_t color; |
26 | rgba_t outline_color; | |
25 | 27 | double x, y; |
26 | 28 | |
27 | 29 | int align; |
7 | 7 | .fi |
8 | 8 | .. |
9 | 9 | |
10 | .TH i3lock-color 1 "JULY 2020" Linux "User Manuals" | |
10 | .TH i3lock-color 1 "FEBRUARY 2021" Linux "User Manuals" | |
11 | 11 | |
12 | 12 | .SH NAME |
13 | 13 | i3lock-color \- improved screen locker |
322 | 322 | Sets the font size used to render various strings. |
323 | 323 | |
324 | 324 | .TP |
325 | .B \-\-{time, date, layout, verif, wrong, greeter}outlinecolor=rrggbbaa | |
326 | Sets the color of the outline. | |
327 | ||
328 | .TP | |
329 | .B \-\-{time, date, layout, verif, wrong, greeter, modifier}outlinewidth=number | |
330 | Sets the width of the outline. | |
331 | ||
332 | .TP | |
325 | 333 | .B \-\-datepos="x position:y position" |
326 | 334 | Sets the position for the date string. All the variables from \-\-indpos and \-\-timepos may be used, in addition to: |
327 | 335 | .RS |
369 | 377 | Sets the string to be shown after failing to acquire pointer and keyboard focus. Defaults to "lock failed!". |
370 | 378 | |
371 | 379 | .TP |
380 | .B \-\-no-modkeytext | |
381 | Hides the modkey indicator (Num, Caps Lock ...) | |
382 | ||
383 | .TP | |
372 | 384 | .B \-\-radius |
373 | 385 | The radius of the circle. Defaults to 90. |
374 | 386 | |
391 | 403 | |
392 | 404 | .TP |
393 | 405 | .B \-\-bar\-width=15 |
406 | Deprecated, use \-\-bar\-count instead. | |
407 | ||
394 | 408 | Sets the width of the minibars in the bar. |
395 | 409 | |
396 | 410 | .TP |
424 | 438 | .B \-\-bar\-position |
425 | 439 | Works similarly to the time/date/indicator expressions. If the bar is horizontal, this sets the vertical offset from the top edge. |
426 | 440 | If it's vertically oriented, this sets the horizontal offset from the left edge. |
441 | ||
442 | .TP | |
443 | .B \-\-bar\-count=10 | |
444 | Sets the number of minibars to draw on each screen. | |
427 | 445 | |
428 | 446 | .TP |
429 | 447 | .B \-\-no\-verify |
89 | 89 | char separatorcolor[9] = "000000ff"; |
90 | 90 | char greetercolor[9] = "000000ff"; |
91 | 91 | |
92 | char verifoutlinecolor[9] = "00000000"; | |
93 | char wrongoutlinecolor[9] = "00000000"; | |
94 | char layoutoutlinecolor[9] = "00000000"; | |
95 | char timeoutlinecolor[9] = "00000000"; | |
96 | char dateoutlinecolor[9] = "00000000"; | |
97 | char greeteroutlinecolor[9] = "00000000"; | |
98 | ||
92 | 99 | /* int defining which display the lock indicator should be shown on. If -1, then show on all displays.*/ |
93 | 100 | int screen_number = 0; |
101 | ||
94 | 102 | /* default is to use the supplied line color, 1 will be ring color, 2 will be to use the inside color for ver/wrong/etc */ |
95 | 103 | int internal_line_source = 0; |
96 | /* bool for showing the clock; why am I commenting this? */ | |
104 | ||
105 | /* refresh rate in seconds, default to 1s */ | |
106 | float refresh_rate = 1.0; | |
107 | ||
97 | 108 | bool show_clock = false; |
98 | 109 | bool slideshow_enabled = false; |
99 | 110 | bool always_show_clock = false; |
100 | 111 | bool show_indicator = false; |
101 | float refresh_rate = 1.0; | |
112 | bool show_modkey_text = true; | |
102 | 113 | |
103 | 114 | /* there's some issues with compositing - upstream removed support for this, but we'll allow people to supply an arg to enable it */ |
104 | 115 | bool composite = false; |
166 | 177 | double circle_radius = 90.0; |
167 | 178 | double ring_width = 7.0; |
168 | 179 | double greeter_size = 32.0; |
180 | ||
181 | double timeoutlinewidth = 0; | |
182 | double dateoutlinewidth = 0; | |
183 | double verifoutlinewidth = 0; | |
184 | double wrongoutlinewidth = 0; | |
185 | double modifieroutlinewidth = 0; | |
186 | double layoutoutlinewidth = 0; | |
187 | double greeteroutlinewidth = 0; | |
169 | 188 | |
170 | 189 | char* verif_text = "verifying…"; |
171 | 190 | char* wrong_text = "wrong!"; |
242 | 261 | // allow you to disable. handy if you use bar with lots of crap. |
243 | 262 | bool redraw_thread = false; |
244 | 263 | |
264 | // experimental bar stuff | |
245 | 265 | #define BAR_VERT 0 |
246 | 266 | #define BAR_FLAT 1 |
247 | 267 | #define BAR_DEFAULT 0 |
248 | 268 | #define BAR_REVERSED 1 |
249 | 269 | #define BAR_BIDIRECTIONAL 2 |
250 | // experimental bar stuff | |
270 | #define MAX_BAR_COUNT 65535 | |
271 | #define MIN_BAR_COUNT 1 | |
272 | ||
251 | 273 | bool bar_enabled = false; |
252 | 274 | double *bar_heights = NULL; |
253 | 275 | double bar_step = 15; |
254 | 276 | double bar_base_height = 25; |
255 | 277 | double bar_periodic_step = 15; |
256 | 278 | double max_bar_height = 25; |
257 | int num_bars = 0; | |
258 | int bar_width = 150; | |
279 | int bar_count = 0; | |
280 | int bar_width = 0; | |
259 | 281 | int bar_orientation = BAR_FLAT; |
260 | 282 | |
261 | 283 | char bar_base_color[9] = "000000ff"; |
575 | 597 | else if (strcmp(mod_name, XKB_MOD_NAME_LOGO) == 0) |
576 | 598 | mod_name = "Super"; |
577 | 599 | |
578 | char *tmp; | |
579 | if (modifier_string == NULL) { | |
580 | if (asprintf(&tmp, "%s", mod_name) != -1) | |
600 | if (show_modkey_text) { | |
601 | char *tmp; | |
602 | if (modifier_string == NULL) { | |
603 | if (asprintf(&tmp, "%s", mod_name) != -1) | |
604 | modifier_string = tmp; | |
605 | } else if (asprintf(&tmp, "%s, %s", modifier_string, mod_name) != -1) { | |
606 | free(modifier_string); | |
581 | 607 | modifier_string = tmp; |
582 | } else if (asprintf(&tmp, "%s, %s", modifier_string, mod_name) != -1) { | |
583 | free(modifier_string); | |
584 | modifier_string = tmp; | |
608 | } | |
585 | 609 | } |
586 | 610 | } |
587 | 611 | |
1428 | 1452 | {"separatorcolor", required_argument, NULL, 314}, |
1429 | 1453 | {"greetercolor", required_argument, NULL, 315}, |
1430 | 1454 | |
1455 | // text outline colors | |
1456 | {"verifoutlinecolor", required_argument, NULL, 316}, | |
1457 | {"wrongoutlinecolor", required_argument, NULL, 317}, | |
1458 | {"layoutoutlinecolor", required_argument, NULL, 318}, | |
1459 | {"timeoutlinecolor", required_argument, NULL, 319}, | |
1460 | {"dateoutlinecolor", required_argument, NULL, 320}, | |
1461 | {"greeteroutlinecolor", required_argument, NULL, 321}, | |
1462 | ||
1431 | 1463 | {"line-uses-ring", no_argument, NULL, 'r'}, |
1432 | 1464 | {"line-uses-inside", no_argument, NULL, 's'}, |
1433 | 1465 | |
1458 | 1490 | {"locktext", required_argument, NULL, 516}, |
1459 | 1491 | {"lockfailedtext", required_argument, NULL, 517}, |
1460 | 1492 | {"greetertext", required_argument, NULL, 518}, |
1493 | {"no-modkeytext", no_argument, NULL, 519}, | |
1461 | 1494 | |
1462 | 1495 | // fonts |
1463 | 1496 | {"time-font", required_argument, NULL, 520}, |
1486 | 1519 | {"modifpos", required_argument, NULL, 546}, |
1487 | 1520 | {"indpos", required_argument, NULL, 547}, |
1488 | 1521 | {"greeterpos", required_argument, NULL, 548}, |
1522 | ||
1523 | // text outline width | |
1524 | {"timeoutlinewidth", required_argument, NULL, 560}, | |
1525 | {"dateoutlinewidth", required_argument, NULL, 561}, | |
1526 | {"verifoutlinewidth", required_argument, NULL, 562}, | |
1527 | {"wrongoutlinewidth", required_argument, NULL, 563}, | |
1528 | {"modifieroutlinewidth", required_argument, NULL, 564}, | |
1529 | {"layoutoutlinewidth", required_argument, NULL, 565}, | |
1530 | {"greeteroutlinewidth", required_argument, NULL, 566}, | |
1489 | 1531 | |
1490 | 1532 | // pass keys |
1491 | 1533 | {"pass-media-keys", no_argument, NULL, 601}, |
1504 | 1546 | {"bar-color", required_argument, NULL, 707}, |
1505 | 1547 | {"bar-periodic-step", required_argument, NULL, 708}, |
1506 | 1548 | {"bar-position", required_argument, NULL, 709}, |
1549 | {"bar-count", required_argument, NULL, 710}, | |
1507 | 1550 | |
1508 | 1551 | // misc. |
1509 | 1552 | {"redraw-thread", no_argument, NULL, 900}, |
1540 | 1583 | if (strlen(arg) != 8 || sscanf(arg, "%08[0-9a-fA-F]", acolor) != 1)\ |
1541 | 1584 | errx(1, #acolor " is invalid, color must be given in 3 or 4-byte format: rrggbb[aa]\n"); |
1542 | 1585 | |
1586 | #define parse_outline_width(awidth)\ | |
1587 | arg = optarg;\ | |
1588 | if (sscanf(arg, "%lf", &awidth) != 1)\ | |
1589 | errx(1, #awidth " must be a number\n");\ | |
1590 | if (awidth < 0) {\ | |
1591 | fprintf(stderr, #awidth " must be a positive double; ignoring...\n");\ | |
1592 | awidth = 0;\ | |
1593 | } | |
1594 | ||
1543 | 1595 | while ((o = getopt_long(argc, argv, optstring, longopts, &longoptind)) != -1) { |
1544 | 1596 | switch (o) { |
1545 | 1597 | case 'v': |
1666 | 1718 | case 315: |
1667 | 1719 | parse_color(greetercolor); |
1668 | 1720 | break; |
1721 | case 316: | |
1722 | parse_color(verifoutlinecolor); | |
1723 | break; | |
1724 | case 317: | |
1725 | parse_color(wrongoutlinecolor); | |
1726 | break; | |
1727 | case 318: | |
1728 | parse_color(layoutoutlinecolor); | |
1729 | break; | |
1730 | case 319: | |
1731 | parse_color(timeoutlinecolor); | |
1732 | break; | |
1733 | case 320: | |
1734 | parse_color(dateoutlinecolor); | |
1735 | break; | |
1736 | case 321: | |
1737 | parse_color(greeteroutlinecolor); | |
1738 | break; | |
1739 | ||
1669 | 1740 | |
1670 | 1741 | // General indicator opts |
1671 | 1742 | case 400: |
1768 | 1839 | case 518: |
1769 | 1840 | greeter_text = optarg; |
1770 | 1841 | break; |
1842 | case 519: | |
1843 | show_modkey_text = false; | |
1844 | break; | |
1771 | 1845 | |
1772 | 1846 | // Font stuff |
1773 | 1847 | case 520: |
1959 | 2033 | errx(1, "indpos must be of the form x:y\n"); |
1960 | 2034 | } |
1961 | 2035 | break; |
2036 | ||
2037 | // text outline width | |
2038 | case 560: | |
2039 | parse_outline_width(timeoutlinewidth); | |
2040 | break; | |
2041 | case 561: | |
2042 | parse_outline_width(dateoutlinewidth); | |
2043 | break; | |
2044 | case 562: | |
2045 | parse_outline_width(verifoutlinewidth); | |
2046 | break; | |
2047 | case 563: | |
2048 | parse_outline_width(wrongoutlinewidth); | |
2049 | break; | |
2050 | case 564: | |
2051 | parse_outline_width(modifieroutlinewidth); | |
2052 | break; | |
2053 | case 565: | |
2054 | parse_outline_width(layoutoutlinewidth); | |
2055 | break; | |
2056 | case 566: | |
2057 | parse_outline_width(greeteroutlinewidth); | |
2058 | break; | |
2059 | ||
1962 | 2060 | |
1963 | 2061 | // Pass keys |
1964 | 2062 | case 601: |
1995 | 2093 | case 702: |
1996 | 2094 | bar_width = atoi(optarg); |
1997 | 2095 | if (bar_width < 1) bar_width = 150; |
1998 | // num_bars and bar_heights* initialized later when we grab display info | |
1999 | 2096 | break; |
2000 | 2097 | case 703: |
2001 | 2098 | arg = optarg; |
2035 | 2132 | arg = optarg; |
2036 | 2133 | if (sscanf(arg, "%31s", bar_expr) != 1) { |
2037 | 2134 | errx(1, "bar-position must be of the form [pos] with a max length of 31\n"); |
2135 | } | |
2136 | break; | |
2137 | case 710: | |
2138 | bar_count = atoi(optarg); | |
2139 | if (bar_count > MAX_BAR_COUNT || bar_count < MIN_BAR_COUNT) { | |
2140 | errx(1, "bar-count must be between %d and %d\n", MIN_BAR_COUNT, MAX_BAR_COUNT); | |
2038 | 2141 | } |
2039 | 2142 | break; |
2040 | 2143 | |
2183 | 2286 | last_resolution[0] = screen->width_in_pixels; |
2184 | 2287 | last_resolution[1] = screen->height_in_pixels; |
2185 | 2288 | |
2186 | if (bar_enabled && bar_width > 0) { | |
2187 | int tmp = screen->width_in_pixels; | |
2188 | if (bar_orientation == BAR_VERT) tmp = screen->height_in_pixels; | |
2189 | num_bars = tmp / bar_width; | |
2190 | if (tmp % bar_width != 0) ++num_bars; | |
2191 | ||
2192 | bar_heights = (double*) calloc(num_bars, sizeof(double)); | |
2289 | if (bar_enabled) { | |
2290 | if (bar_count == 0) { | |
2291 | if (bar_width != 0) { | |
2292 | fprintf(stderr, "Warning: bar-width is deprecated, use bar-count instead\n"); | |
2293 | int tmp = screen->width_in_pixels; | |
2294 | if (bar_orientation == BAR_VERT) tmp = screen->height_in_pixels; | |
2295 | bar_count = tmp / bar_width; | |
2296 | if (tmp % bar_width != 0) { | |
2297 | ++bar_count; | |
2298 | } | |
2299 | } else { | |
2300 | bar_count = 10; | |
2301 | } | |
2302 | } else if (bar_width != 0) { | |
2303 | errx(EXIT_FAILURE, "bar-width and bar-count cannot be used at the same time"); | |
2304 | } | |
2305 | ||
2306 | if (bar_count >= MIN_BAR_COUNT && bar_count <= MAX_BAR_COUNT) { | |
2307 | bar_heights = (double*) calloc(bar_count, sizeof(double)); | |
2308 | } else { | |
2309 | bar_enabled = false; | |
2310 | } | |
2193 | 2311 | } |
2194 | 2312 | |
2195 | 2313 | xcb_change_window_attributes(conn, screen->root, XCB_CW_EVENT_MASK, |
0 | #!/bin/sh | |
1 | ||
2 | B='#00000000' # blank | |
3 | C='#ffffff22' # clear ish | |
4 | D='#ff00ffcc' # default | |
5 | T='#ee00eeee' # text | |
6 | W='#880000bb' # wrong | |
7 | V='#bb00bbbb' # verifying | |
8 | ||
9 | ./x86_64-pc-linux-gnu/i3lock \ | |
10 | --insidevercolor=$C \ | |
11 | --ringvercolor=$V \ | |
12 | \ | |
13 | --insidewrongcolor=$C \ | |
14 | --ringwrongcolor=$W \ | |
15 | \ | |
16 | --insidecolor=$B \ | |
17 | --ringcolor=$D \ | |
18 | --linecolor=$B \ | |
19 | --separatorcolor=$D \ | |
20 | \ | |
21 | --verifcolor=$T \ | |
22 | --wrongcolor=$T \ | |
23 | --timecolor=$T \ | |
24 | --datecolor=$T \ | |
25 | --layoutcolor=$T \ | |
26 | --keyhlcolor=$W \ | |
27 | --bshlcolor=$W \ | |
28 | \ | |
29 | --screen 1 \ | |
30 | --blur 5 \ | |
31 | --clock \ | |
32 | --indicator \ | |
33 | --timestr="%H:%M:%S" \ | |
34 | --datestr="%A, %m %Y" \ | |
35 | --keylayout 1 \ | |
36 | ||
37 | # --veriftext="Drinking verification can..." | |
38 | # --wrongtext="Nope!" | |
39 | # --textsize=20 | |
40 | # --modsize=10 | |
41 | # --timefont=comic-sans | |
42 | # --datefont=monofur | |
43 | # etc |
0 | #!/bin/sh | |
1 | ||
2 | B='#00000000' # blank | |
3 | C='#ffffff22' # clear ish | |
4 | D='#ff00ffcc' # default | |
5 | T='#ee00eeee' # text | |
6 | W='#880000bb' # wrong | |
7 | V='#bb00bbbb' # verifying | |
8 | ||
9 | ./x86_64-pc-linux-gnu/i3lock \ | |
10 | --blur 5 \ | |
11 | --bar-indicator \ | |
12 | --bar-position h \ | |
13 | --bar-direction 1 \ | |
14 | --bar-max-height 50 \ | |
15 | --bar-base-width 50 \ | |
16 | --bar-color 000000cc \ | |
17 | --keyhlcolor 880088cc \ | |
18 | --bar-periodic-step 50 \ | |
19 | --bar-step 50 \ | |
20 | --bar-width 250 \ | |
21 | --redraw-thread \ | |
22 | \ | |
23 | --clock \ | |
24 | --force-clock \ | |
25 | --timepos 5:h-80 \ | |
26 | --timecolor 880088ff \ | |
27 | --datepos tx:ty+15 \ | |
28 | --datecolor 990099ff \ | |
29 | --date-align 1 \ | |
30 | --time-align 1 \ | |
31 | --ringvercolor 8800ff88 \ | |
32 | --ringwrongcolor ff008888 \ | |
33 | --statuspos 5:h-16 \ | |
34 | --verif-align 1 \ | |
35 | --wrong-align 1 \ | |
36 | --verifcolor ffffffff \ | |
37 | --wrongcolor ffffffff \ | |
38 | --modifpos -50:-50 \ | |
39 | \ | |
40 | --screen 1 |
0 | 0 | # |
1 | 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. | |
2 | # the 'system-local-login' configuration file (see /etc/pam.d/system-local-login) | |
3 | # for Arch and Gentoo and 'login' for Debian. Note that upstream uses only 'login', | |
4 | # which doesn't work on Arch and Gentoo. | |
4 | 5 | # |
5 | 6 | |
6 | #auth include system-auth # For Arch/Gentoo | |
7 | #auth include system-local-login # For Arch/Gentoo | |
7 | 8 | auth include login # For Debian |
92 | 92 | extern char separatorcolor[9]; |
93 | 93 | extern char greetercolor[9]; |
94 | 94 | extern int internal_line_source; |
95 | ||
96 | extern char verifoutlinecolor[9]; | |
97 | extern char wrongoutlinecolor[9]; | |
98 | extern char layoutoutlinecolor[9]; | |
99 | extern char timeoutlinecolor[9]; | |
100 | extern char dateoutlinecolor[9]; | |
101 | extern char greeteroutlinecolor[9]; | |
95 | 102 | |
96 | 103 | extern int screen_number; |
97 | 104 | extern float refresh_rate; |
136 | 143 | extern double layout_size; |
137 | 144 | extern double greeter_size; |
138 | 145 | |
146 | extern double timeoutlinewidth; | |
147 | extern double dateoutlinewidth; | |
148 | extern double verifoutlinewidth; | |
149 | extern double wrongoutlinewidth; | |
150 | extern double modifieroutlinewidth; | |
151 | extern double layoutoutlinewidth; | |
152 | extern double greeteroutlinewidth; | |
153 | ||
139 | 154 | extern char *verif_text; |
140 | 155 | extern char *wrong_text; |
141 | 156 | extern char *noinput_text; |
193 | 208 | rgba_t greeter16; |
194 | 209 | rgba_t background; |
195 | 210 | |
211 | rgba_t verifoutline16; | |
212 | rgba_t wrongoutline16; | |
213 | rgba_t layoutoutline16; | |
214 | rgba_t timeoutline16; | |
215 | rgba_t dateoutline16; | |
216 | rgba_t greeteroutline16; | |
217 | ||
196 | 218 | // experimental bar stuff |
197 | 219 | |
198 | 220 | #define BAR_VERT 0 |
205 | 227 | extern double bar_periodic_step; |
206 | 228 | extern double max_bar_height; |
207 | 229 | extern double bar_position; |
208 | extern int num_bars; | |
209 | extern int bar_width; | |
230 | extern int bar_count; | |
210 | 231 | extern int bar_orientation; |
211 | 232 | |
212 | 233 | extern char bar_base_color[9]; |
310 | 331 | |
311 | 332 | cairo_set_source_rgba(ctx, text.color.red, text.color.green, text.color.blue, text.color.alpha); |
312 | 333 | cairo_move_to(ctx, x, text.y); |
313 | cairo_show_text(ctx, text.str); | |
314 | ||
334 | ||
335 | cairo_text_path(ctx, text.str); | |
336 | cairo_fill_preserve(ctx); | |
337 | ||
338 | cairo_set_source_rgba(ctx, text.outline_color.red, text.outline_color.green, text.outline_color.blue, text.outline_color.alpha); | |
339 | cairo_set_line_width(ctx, text.outline_width); | |
315 | 340 | cairo_stroke(ctx); |
316 | 341 | } |
317 | 342 | |
318 | static void draw_bar(cairo_t *ctx, double x, double y, double bar_offset) { | |
319 | // oh boy, here we go! | |
320 | // TODO: get this to play nicely with multiple monitors | |
321 | // ideally it'd intelligently span both monitors | |
322 | double width, height; | |
323 | double back_x = 0, back_y = 0, back_x2 = 0, back_y2 = 0, back_width = 0, back_height = 0; | |
324 | for (int i = 0; i < num_bars; ++i) { | |
325 | double cur_bar_height = bar_heights[i]; | |
326 | ||
327 | if (cur_bar_height > 0) { | |
328 | if (unlock_state == STATE_BACKSPACE_ACTIVE) { | |
329 | cairo_set_source_rgba(ctx, bshl16.red, bshl16.green, bshl16.blue, bshl16.alpha); | |
330 | } else { | |
331 | cairo_set_source_rgba(ctx, keyhl16.red, keyhl16.green, keyhl16.blue, keyhl16.alpha); | |
332 | } | |
333 | } else { | |
334 | switch (auth_state) { | |
335 | case STATE_AUTH_VERIFY: | |
336 | case STATE_AUTH_LOCK: | |
337 | cairo_set_source_rgba(ctx, ringver16.red, ringver16.green, ringver16.blue, ringver16.alpha); | |
338 | break; | |
339 | case STATE_AUTH_WRONG: | |
340 | case STATE_I3LOCK_LOCK_FAILED: | |
341 | cairo_set_source_rgba(ctx, ringwrong16.red, ringwrong16.green, ringwrong16.blue, ringwrong16.alpha); | |
342 | break; | |
343 | default: | |
344 | cairo_set_source_rgba(ctx, bar16.red, bar16.green, bar16.blue, bar16.alpha); | |
345 | break; | |
346 | } | |
347 | } | |
348 | ||
349 | if (bar_orientation == BAR_VERT) { | |
350 | width = (cur_bar_height <= 0 ? bar_base_height : cur_bar_height); | |
351 | height = bar_width; | |
352 | x = bar_offset; | |
353 | y = i * bar_width; | |
354 | if (bar_reversed) { | |
355 | x -= width; | |
356 | } else if (bar_bidirectional) { | |
357 | width = (cur_bar_height <= 0 ? bar_base_height : cur_bar_height * 2); | |
358 | x = bar_offset - (width / 2) + (bar_base_height / 2); | |
359 | } | |
360 | } else { | |
361 | width = bar_width; | |
362 | height = (cur_bar_height <= 0 ? bar_base_height : cur_bar_height); | |
363 | x = i * bar_width; | |
364 | y = bar_offset; | |
365 | if (bar_reversed) { | |
366 | y -= height; | |
367 | } else if (bar_bidirectional) { | |
368 | height = (cur_bar_height <= 0 ? bar_base_height : cur_bar_height * 2); | |
369 | y = bar_offset - (height / 2) + (bar_base_height / 2); | |
370 | } | |
371 | } | |
372 | ||
373 | if (cur_bar_height < bar_base_height && cur_bar_height > 0) { | |
374 | if (bar_orientation == BAR_VERT) { | |
375 | back_x = bar_offset + cur_bar_height; | |
376 | back_y = y; | |
377 | back_width = bar_base_height - cur_bar_height; | |
378 | back_height = height; | |
379 | if (bar_reversed) { | |
380 | back_x = bar_offset - bar_base_height; | |
381 | } else if (bar_bidirectional) { | |
382 | back_x = bar_offset; | |
383 | back_y2 = y; | |
384 | back_width = (bar_base_height - (cur_bar_height * 2)) / 2; | |
385 | back_x2 = bar_offset + (cur_bar_height * 2) + back_width; | |
386 | } | |
387 | } else { | |
388 | back_x = x; | |
389 | back_y = bar_offset + cur_bar_height; | |
390 | back_width = width; | |
391 | back_height = bar_base_height - cur_bar_height; | |
392 | if (bar_reversed) { | |
393 | back_y = bar_offset - bar_base_height; | |
394 | } else if (bar_bidirectional) { | |
395 | back_x2 = x; | |
396 | back_y = bar_offset; | |
397 | back_height = (bar_base_height - (cur_bar_height * 2)) / 2; | |
398 | back_y2 = bar_offset + (cur_bar_height * 2) + back_height; | |
399 | } | |
400 | } | |
401 | } | |
402 | cairo_rectangle(ctx, x, y, width, height); | |
403 | cairo_fill(ctx); | |
404 | switch (auth_state) { | |
405 | case STATE_AUTH_VERIFY: | |
406 | case STATE_AUTH_LOCK: | |
407 | cairo_set_source_rgba(ctx, ringver16.red, ringver16.green, ringver16.blue, ringver16.alpha); | |
408 | break; | |
409 | case STATE_AUTH_WRONG: | |
410 | case STATE_I3LOCK_LOCK_FAILED: | |
411 | cairo_set_source_rgba(ctx, ringwrong16.red, ringwrong16.green, ringwrong16.blue, ringwrong16.alpha); | |
412 | break; | |
413 | default: | |
414 | cairo_set_source_rgba(ctx, bar16.red, bar16.green, bar16.blue, bar16.alpha); | |
415 | break; | |
416 | } | |
417 | ||
418 | if (cur_bar_height > 0 && cur_bar_height < bar_base_height && ((bar_bidirectional && ((cur_bar_height * 2) < bar_base_height)) || (!bar_bidirectional && (cur_bar_height < bar_base_height)))) { | |
419 | cairo_rectangle(ctx, back_x, back_y, back_width, back_height); | |
420 | cairo_fill(ctx); | |
421 | if (bar_bidirectional) { | |
422 | cairo_rectangle(ctx, back_x2, back_y2, back_width, back_height); | |
423 | cairo_fill(ctx); | |
424 | } | |
425 | } | |
426 | } | |
427 | for (int i = 0; i < num_bars; ++i) { | |
428 | if (bar_heights[i] > 0) | |
343 | static void draw_single_bar(cairo_t *ctx, double pos, double offset, double width, double height) { | |
344 | if (bar_reversed) { | |
345 | offset -= height; | |
346 | } else if (bar_bidirectional) { | |
347 | offset -= height / 2; | |
348 | } | |
349 | ||
350 | if (bar_orientation == BAR_VERT) | |
351 | cairo_rectangle(ctx, offset, pos, height, width); | |
352 | else | |
353 | cairo_rectangle(ctx, pos, offset, width, height); | |
354 | cairo_fill(ctx); | |
355 | } | |
356 | ||
357 | static void draw_bar(cairo_t *ctx, double bar_offset, double screen_x, double screen_y, double screen_w, double screen_h) { | |
358 | ||
359 | cairo_save(ctx); | |
360 | ||
361 | switch (auth_state) { | |
362 | case STATE_AUTH_VERIFY: | |
363 | case STATE_AUTH_LOCK: | |
364 | cairo_set_source_rgba(ctx, ringver16.red, ringver16.green, ringver16.blue, ringver16.alpha); | |
365 | break; | |
366 | case STATE_AUTH_WRONG: | |
367 | case STATE_I3LOCK_LOCK_FAILED: | |
368 | cairo_set_source_rgba(ctx, ringwrong16.red, ringwrong16.green, ringwrong16.blue, ringwrong16.alpha); | |
369 | break; | |
370 | default: | |
371 | cairo_set_source_rgba(ctx, bar16.red, bar16.green, bar16.blue, bar16.alpha); | |
372 | break; | |
373 | } | |
374 | ||
375 | if (bar_orientation == BAR_VERT) | |
376 | draw_single_bar(ctx, screen_y, bar_offset, screen_h, bar_base_height); | |
377 | else | |
378 | draw_single_bar(ctx, screen_x, bar_offset, screen_w, bar_base_height); | |
379 | ||
380 | if (unlock_state == STATE_BACKSPACE_ACTIVE) | |
381 | cairo_set_source_rgba(ctx, bshl16.red, bshl16.green, bshl16.blue, bshl16.alpha); | |
382 | else | |
383 | cairo_set_source_rgba(ctx, keyhl16.red, keyhl16.green, keyhl16.blue, keyhl16.alpha); | |
384 | ||
385 | cairo_set_operator(ctx, CAIRO_OPERATOR_SOURCE); | |
386 | ||
387 | double bar_width, screen_pos; | |
388 | if (bar_orientation == BAR_VERT) { | |
389 | bar_width = screen_h / bar_count; | |
390 | screen_pos = screen_y; | |
391 | } else { | |
392 | bar_width = screen_w / bar_count; | |
393 | screen_pos = screen_x; | |
394 | } | |
395 | ||
396 | for (int i = 0; i < bar_count; ++i) { | |
397 | double bar_height = bar_heights[i]; | |
398 | if (bar_bidirectional) bar_height *= 2; | |
399 | if (bar_height > 0) { | |
400 | draw_single_bar(ctx, screen_pos + i * bar_width, bar_offset, bar_width, bar_height); | |
401 | } | |
402 | } | |
403 | ||
404 | for (int i = 0; i < bar_count; ++i) { | |
405 | if (bar_heights[i] > 0) { | |
429 | 406 | bar_heights[i] -= bar_periodic_step; |
430 | } | |
407 | } | |
408 | } | |
409 | ||
410 | cairo_restore(ctx); | |
431 | 411 | } |
432 | 412 | |
433 | 413 | static void draw_indic(cairo_t *ctx, double ind_x, double ind_y) { |
602 | 582 | colorgen(&tmp, bar_base_color, &bar16); |
603 | 583 | colorgen(&tmp, greetercolor, &greeter16); |
604 | 584 | colorgen(&tmp, color, &background); |
585 | ||
586 | colorgen(&tmp, verifoutlinecolor, &verifoutline16); | |
587 | colorgen(&tmp, wrongoutlinecolor, &wrongoutline16); | |
588 | colorgen(&tmp, layoutoutlinecolor, &layoutoutline16); | |
589 | colorgen(&tmp, timeoutlinecolor, &timeoutline16); | |
590 | colorgen(&tmp, dateoutlinecolor, &dateoutline16); | |
591 | colorgen(&tmp, greeteroutlinecolor, &greeteroutline16); | |
605 | 592 | } |
606 | 593 | |
607 | 594 | static te_expr *compile_expression(const char *const from, const char *expression, const te_variable *variables, int var_count) { |
629 | 616 | if (unlock_state == STATE_KEY_ACTIVE || |
630 | 617 | unlock_state == STATE_BACKSPACE_ACTIVE) { |
631 | 618 | // note: might be biased to cause more hits on lower indices |
632 | // maybe see about doing ((double) rand() / RAND_MAX) * num_bars | |
633 | int index = rand() % num_bars; | |
619 | // maybe see about doing ((double) rand() / RAND_MAX) * bar_count | |
620 | int index = rand() % bar_count; | |
634 | 621 | bar_heights[index] = max_bar_height; |
635 | 622 | for (int i = 0; i < ((max_bar_height / bar_step) + 1); ++i) { |
636 | 623 | int low_ind = index - i; |
637 | 624 | while (low_ind < 0) { |
638 | low_ind += num_bars; | |
625 | low_ind += bar_count; | |
639 | 626 | } |
640 | int high_ind = (index + i) % num_bars; | |
627 | int high_ind = (index + i) % bar_count; | |
641 | 628 | int tmp_height = max_bar_height - (bar_step * i); |
642 | 629 | if (tmp_height < 0) |
643 | 630 | tmp_height = 0; |
649 | 636 | break; |
650 | 637 | } |
651 | 638 | } |
652 | draw_bar(ctx, draw_data->bar_x, draw_data->bar_y, draw_data->bar_offset); | |
639 | draw_bar(ctx, draw_data->bar_offset, draw_data->screen_x, draw_data->screen_y, draw_data->screen_w, draw_data->screen_h); | |
653 | 640 | } |
654 | 641 | |
655 | 642 | draw_text(ctx, draw_data->status_text); |
732 | 719 | strncpy(draw_data.status_text.str, verif_text, sizeof(draw_data.status_text.str) - 1); |
733 | 720 | draw_data.status_text.font = get_font_face(VERIF_FONT); |
734 | 721 | draw_data.status_text.color = verif16; |
722 | draw_data.status_text.outline_color = verifoutline16; | |
735 | 723 | draw_data.status_text.size = verif_size; |
724 | draw_data.status_text.outline_width = verifoutlinewidth; | |
736 | 725 | draw_data.status_text.align = verif_align; |
737 | 726 | break; |
738 | 727 | case STATE_AUTH_LOCK: |
740 | 729 | strncpy(draw_data.status_text.str, lock_text, sizeof(draw_data.status_text.str) - 1); |
741 | 730 | draw_data.status_text.font = get_font_face(VERIF_FONT); |
742 | 731 | draw_data.status_text.color = verif16; |
732 | draw_data.status_text.outline_color = verifoutline16; | |
743 | 733 | draw_data.status_text.size = verif_size; |
734 | draw_data.status_text.outline_width = verifoutlinewidth; | |
744 | 735 | draw_data.status_text.align = verif_align; |
745 | 736 | break; |
746 | 737 | case STATE_AUTH_WRONG: |
748 | 739 | strncpy(draw_data.status_text.str, wrong_text, sizeof(draw_data.status_text.str) - 1); |
749 | 740 | draw_data.status_text.font = get_font_face(WRONG_FONT); |
750 | 741 | draw_data.status_text.color = wrong16; |
742 | draw_data.status_text.outline_color = wrongoutline16; | |
751 | 743 | draw_data.status_text.size = wrong_size; |
744 | draw_data.status_text.outline_width = wrongoutlinewidth; | |
752 | 745 | draw_data.status_text.align = wrong_align; |
753 | 746 | break; |
754 | 747 | case STATE_I3LOCK_LOCK_FAILED: |
756 | 749 | strncpy(draw_data.status_text.str, lock_failed_text, sizeof(draw_data.status_text.str) - 1); |
757 | 750 | draw_data.status_text.font = get_font_face(WRONG_FONT); |
758 | 751 | draw_data.status_text.color = wrong16; |
752 | draw_data.status_text.outline_color = wrongoutline16; | |
759 | 753 | draw_data.status_text.size = wrong_size; |
754 | draw_data.status_text.outline_width = wrongoutlinewidth; | |
760 | 755 | draw_data.status_text.align = wrong_align; |
761 | 756 | break; |
762 | 757 | default: |
765 | 760 | strncpy(draw_data.status_text.str, noinput_text, sizeof(draw_data.status_text.str) - 1); |
766 | 761 | draw_data.status_text.font = get_font_face(WRONG_FONT); |
767 | 762 | draw_data.status_text.color = wrong16; |
763 | draw_data.status_text.outline_color = wrongoutline16; | |
768 | 764 | draw_data.status_text.size = wrong_size; |
765 | draw_data.status_text.outline_width = wrongoutlinewidth; | |
769 | 766 | draw_data.status_text.align = wrong_align; |
770 | 767 | break; |
771 | 768 | } |
773 | 770 | draw_data.status_text.show = true; |
774 | 771 | draw_data.status_text.font = get_font_face(WRONG_FONT); |
775 | 772 | draw_data.status_text.color = wrong16; |
773 | draw_data.status_text.outline_color = wrongoutline16; | |
776 | 774 | draw_data.status_text.size = wrong_size; |
775 | draw_data.status_text.outline_width = wrongoutlinewidth; | |
777 | 776 | draw_data.status_text.align = wrong_align; |
778 | 777 | // TODO: variable for this |
779 | 778 | draw_data.status_text.size = 32.0; |
791 | 790 | draw_data.mod_text.show = true; |
792 | 791 | strncpy(draw_data.mod_text.str, modifier_string, sizeof(draw_data.mod_text.str) - 1); |
793 | 792 | draw_data.mod_text.size = modifier_size; |
793 | draw_data.mod_text.outline_width = modifieroutlinewidth; | |
794 | 794 | draw_data.mod_text.font = get_font_face(WRONG_FONT); |
795 | 795 | draw_data.mod_text.align = modif_align; |
796 | 796 | draw_data.mod_text.color = wrong16; |
797 | draw_data.mod_text.outline_color = wrongoutline16; | |
797 | 798 | } |
798 | 799 | |
799 | 800 | if (layout_text) { |
800 | 801 | draw_data.keylayout_text.show = true; |
801 | 802 | strncpy(draw_data.keylayout_text.str, layout_text, sizeof(draw_data.keylayout_text.str) - 1); |
802 | 803 | draw_data.keylayout_text.size = layout_size; |
804 | draw_data.keylayout_text.outline_width = layoutoutlinewidth; | |
803 | 805 | draw_data.keylayout_text.font = get_font_face(LAYOUT_FONT); |
804 | 806 | draw_data.keylayout_text.color = layout16; |
807 | draw_data.keylayout_text.outline_color = layoutoutline16; | |
805 | 808 | draw_data.keylayout_text.align = layout_align; |
806 | 809 | } |
807 | 810 | |
809 | 812 | draw_data.greeter_text.show = true; |
810 | 813 | strncpy(draw_data.greeter_text.str, greeter_text, sizeof(draw_data.greeter_text.str) - 1); |
811 | 814 | draw_data.greeter_text.size = greeter_size; |
815 | draw_data.greeter_text.outline_width = greeteroutlinewidth; | |
812 | 816 | draw_data.greeter_text.font = get_font_face(GREETER_FONT); |
813 | 817 | draw_data.greeter_text.color = greeter16; |
818 | draw_data.greeter_text.outline_color = greeteroutline16; | |
814 | 819 | draw_data.greeter_text.align = greeter_align; |
815 | 820 | } |
816 | 821 | |
824 | 829 | if (*draw_data.time_text.str) { |
825 | 830 | draw_data.time_text.show = true; |
826 | 831 | draw_data.time_text.size = time_size; |
832 | draw_data.time_text.outline_width = timeoutlinewidth; | |
827 | 833 | draw_data.time_text.color = time16; |
834 | draw_data.time_text.outline_color = timeoutline16; | |
828 | 835 | draw_data.time_text.font = get_font_face(TIME_FONT); |
829 | 836 | draw_data.time_text.align = time_align; |
830 | 837 | } |
832 | 839 | if (*draw_data.date_text.str) { |
833 | 840 | draw_data.date_text.show = true; |
834 | 841 | draw_data.date_text.size = date_size; |
842 | draw_data.date_text.outline_width = dateoutlinewidth; | |
835 | 843 | draw_data.date_text.color = date16; |
844 | draw_data.date_text.outline_color = dateoutline16; | |
836 | 845 | draw_data.date_text.font = get_font_face(DATE_FONT); |
837 | 846 | draw_data.date_text.align = date_align; |
838 | 847 | } |
840 | 849 | if (*draw_data.greeter_text.str) { |
841 | 850 | draw_data.greeter_text.show = true; |
842 | 851 | draw_data.greeter_text.size = greeter_size; |
852 | draw_data.greeter_text.outline_width = greeteroutlinewidth; | |
843 | 853 | draw_data.greeter_text.color = greeter16; |
854 | draw_data.greeter_text.outline_color = greeteroutline16; | |
844 | 855 | draw_data.greeter_text.font = get_font_face(GREETER_FONT); |
845 | 856 | draw_data.greeter_text.align = greeter_align; |
846 | 857 | } |
913 | 924 | height = xr_resolutions[current_screen].height / scaling_factor; |
914 | 925 | screen_x = xr_resolutions[current_screen].x / scaling_factor; |
915 | 926 | screen_y = xr_resolutions[current_screen].y / scaling_factor; |
927 | draw_data.screen_w = width; | |
928 | draw_data.screen_h = height; | |
929 | draw_data.screen_x = screen_x; | |
930 | draw_data.screen_y = screen_y; | |
916 | 931 | if (te_ind_x_expr && te_ind_y_expr) { |
917 | 932 | draw_data.indicator_x = te_eval(te_ind_x_expr); |
918 | 933 | draw_data.indicator_y = te_eval(te_ind_y_expr); |
920 | 935 | draw_data.indicator_x = screen_x + width / 2; |
921 | 936 | draw_data.indicator_y = screen_y + height / 2; |
922 | 937 | } |
923 | draw_data.bar_x = draw_data.indicator_x - (button_diameter_physical / 2); | |
924 | draw_data.bar_y = draw_data.indicator_y - (button_diameter_physical / 2); | |
925 | 938 | draw_data.bar_offset = te_eval(te_bar_expr); |
926 | 939 | draw_data.time_text.x = te_eval(te_time_x_expr); |
927 | 940 | draw_data.time_text.y = te_eval(te_time_y_expr); |
953 | 966 | draw_data.mod_text.y = te_eval(te_modif_y_expr); |
954 | 967 | |
955 | 968 | DEBUG("Indicator at %fx%f on screen %d\n", draw_data.indicator_x, draw_data.indicator_y, current_screen + 1); |
956 | DEBUG("Bar at %fx%f on screen %d\n", draw_data.bar_x, draw_data.bar_y, current_screen + 1); | |
969 | DEBUG("Bar at %f on screen %d\n", draw_data.bar_offset, current_screen + 1); | |
957 | 970 | DEBUG("Time at %fx%f on screen %d\n", draw_data.time_text.x, draw_data.time_text.y, current_screen + 1); |
958 | 971 | DEBUG("Date at %fx%f on screen %d\n", draw_data.date_text.x, draw_data.date_text.y, current_screen + 1); |
959 | 972 | DEBUG("Layout at %fx%f on screen %d\n", draw_data.keylayout_text.x, draw_data.keylayout_text.y, current_screen + 1); |
968 | 981 | * hope for the best. */ |
969 | 982 | width = last_resolution[0] / scaling_factor; |
970 | 983 | height = last_resolution[1] / scaling_factor; |
984 | draw_data.screen_w = width; | |
985 | draw_data.screen_h = height; | |
986 | draw_data.screen_x = 0; | |
987 | draw_data.screen_y = 0; | |
971 | 988 | draw_data.indicator_x = width / 2; |
972 | 989 | draw_data.indicator_y = height / 2; |
973 | draw_data.bar_x = draw_data.indicator_x - (button_diameter_physical / 2); | |
974 | draw_data.bar_y = draw_data.indicator_y - (button_diameter_physical / 2); | |
975 | 990 | |
976 | 991 | draw_data.time_text.x = te_eval(te_time_x_expr); |
977 | 992 | draw_data.time_text.y = te_eval(te_time_y_expr); |
1001 | 1016 | draw_data.mod_text.y = te_eval(te_modif_y_expr); |
1002 | 1017 | |
1003 | 1018 | DEBUG("Indicator at %fx%f\n", draw_data.indicator_x, draw_data.indicator_y); |
1004 | DEBUG("Bar at %fx%f\n", draw_data.bar_x, draw_data.bar_y); | |
1019 | DEBUG("Bar at %f\n", draw_data.bar_offset); | |
1005 | 1020 | DEBUG("Time at %fx%f\n", draw_data.time_text.x, draw_data.time_text.y); |
1006 | 1021 | DEBUG("Date at %fx%f\n", draw_data.date_text.x, draw_data.date_text.y); |
1007 | 1022 | DEBUG("Layout at %fx%f\n", draw_data.keylayout_text.x, draw_data.keylayout_text.y); |