Update upstream source from tag 'upstream/2.13.c.4'
Update to upstream version '2.13.c.4'
with Debian dir 8d71eb9ac1d73c098319dc64edf408c43f3d14d2
Arnaud Rebillout
1 year, 9 months 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? |
6 | 6 | steps: |
7 | 7 | - uses: actions/checkout@v2 |
8 | 8 | - name: Install deps |
9 | 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 | |
10 | - run: chmod +x build.sh | |
11 | - run: ./build.sh | |
12 | - run: cd build && make check | |
13 | - run: cd build && make distcheck | |
9 | run: | | |
10 | sudo apt update | |
11 | 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 | |
12 | - name: Build | |
13 | run: ./build.sh | |
14 | - name: Check and distcheck | |
15 | run: | | |
16 | cd build | |
17 | make check | |
18 | make distcheck | |
14 | 19 | - name: Upload binary artifact |
15 | 20 | uses: actions/upload-artifact@v2 |
16 | 21 | with: |
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 | |
63 | 64 | # uses a compiled language |
64 | 65 | |
65 | 66 | - run: | |
67 | sudo apt-get update | |
66 | 68 | 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 |
67 | 69 | ./build.sh |
68 | 70 |
2 | 2 | tags |
3 | 3 | *.swp |
4 | 4 | *.gz |
5 | /pam/i3lock | |
5 | *~ | |
6 | x86_64-pc-linux-gnu | |
6 | 7 | |
7 | 8 | ################################################################################ |
8 | 9 | # https://raw.githubusercontent.com/github/gitignore/master/Autotools.gitignore |
30 | 31 | /install-sh |
31 | 32 | /missing |
32 | 33 | /stamp-h1 |
33 | *.in~ | |
34 | pam/i3lock |
0 | 0 | Copyright © 2010-2011, Michael Stapelberg |
1 | 1 | Copyright © 2015, Cassandra Fox |
2 | Copyright © 2020, Raymond Li | |
2 | Copyright © 2021, Raymond Li | |
3 | 3 | All rights reserved. |
4 | 4 | |
5 | 5 | Redistribution and use in source and binary forms, with or without |
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 | If you still see missing packages during build after installing all of these dependencies, try following the steps [here](https://github.com/Raymo111/i3lock-color/issues/211#issuecomment-809891727). | |
86 | ||
88 | 87 | ### Fedora |
89 | 88 | Run this command to install all dependencies: |
90 | 89 | |
92 | 91 | 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 | 92 | ``` |
94 | 93 | |
94 | ### Ubuntu 18/20.04 LTS | |
95 | Run this command to install all dependencies: | |
96 | ``` | |
97 | 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 | |
98 | ``` | |
99 | ||
95 | 100 | ## Building i3lock-color |
96 | 101 | 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 | 102 | |
98 | If there's no packaged version available - think carefully, since you're using a forked screen locker at your own risk. | |
103 | **If you want to build a non-debug version, you should tag your build before configuring.** | |
99 | 104 | |
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. | |
105 | 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 | 106 | |
102 | To use i3lock-color, first install the dependencies listed above, then clone the repo: | |
107 | i3lock-color uses GNU autotools for building. | |
108 | ||
109 | To build/install i3lock-color, first install the dependencies listed above, then clone the repo: | |
103 | 110 | ``` |
104 | 111 | git clone https://github.com/Raymo111/i3lock-color.git |
105 | 112 | cd i3lock-color |
106 | 113 | ``` |
107 | 114 | To build without installing, run: |
108 | 115 | ``` |
109 | 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 | chmod +x install-i3lock-color.sh | |
115 | 120 | ./install-i3lock-color.sh |
116 | 121 | ``` |
117 | 122 | You may choose to modify the script based on your needs/OS/distro. |
118 | 123 | |
119 | 124 | ## Arch Linux Packages |
120 | [Stable version in Community](https://www.archlinux.org/packages/community/x86_64/i3lock-color/) | |
125 | ~~[Stable version in Community](https://www.archlinux.org/packages/community/x86_64/i3lock-color/)~~ | |
121 | 126 | |
122 | [Git Version on AUR](https://aur.archlinux.org/packages/i3lock-color-git/) | |
127 | 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: | |
128 | - [Release Version on AUR](https://aur.archlinux.org/packages/i3lock-color/) | |
129 | - [Git Version on AUR](https://aur.archlinux.org/packages/i3lock-color-git/) | |
130 | ||
131 | ## Gentoo Package | |
132 | i3lock-color is available on **GURU**, under [`x11-misc/i3lock-color`](https://github.com/gentoo/guru/tree/master/x11-misc/i3lock-color). | |
123 | 133 | |
124 | 134 | ## FreeBSD port |
125 | [i3lock-color-port](https://github.com/rkashapov/i3lock-color-port/) | |
135 | ~~[i3lock-color-port](https://github.com/rkashapov/i3lock-color-port/)~~ (severely out of date). | |
126 | 136 | |
127 | 137 | ## Running i3lock-color |
128 | 138 | Simply invoke the 'i3lock' command. To get out of it, enter your password and press enter. |
129 | 139 | |
130 | A [sample script](lock.sh) is included in this repository. [See the script in action](https://streamable.com/fpl46) | |
140 | A [sample script](examples/lock.sh) is included in this repository. [See the script in action](https://streamable.com/fpl46) | |
131 | 141 | |
132 | 142 | On OpenBSD the `i3lock` binary needs to be setgid `auth` to call the authentication helpers, e.g. `/usr/libexec/auth/login_passwd`. |
133 | 143 | |
135 | 145 | 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 | 146 | |
137 | 147 | ## 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. | |
148 | 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). |
11 | 11 | |
12 | 12 | ## Reporting a Vulnerability |
13 | 13 | |
14 | If there's a severe security vulnerability in the latest version of i3lock-color, don't post a public issue. Either email me directly at [[email protected]](mailto:[email protected]?subject=i3lock-color%20security%20vulnerability), or encrypt the issue text with my PGP public key: | |
14 | If there's a severe security vulnerability in the latest version of i3lock-color, don't post a public issue. Either email me directly at [[email protected]](mailto:[email protected]?subject=i3lock-color%20security%20vulnerability), or encrypt the issue text with my PGP public key: | |
15 | 15 | ``` |
16 | 16 | -----BEGIN PGP PUBLIC KEY BLOCK----- |
17 | 17 |
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 |
0 | #!/bin/bash | |
0 | #!/bin/sh -x | |
1 | ||
2 | configureOpts="--disable-sanitizers" | |
3 | ||
4 | while getopts ":hd" opt; do | |
5 | case ${opt} in | |
6 | h ) echo "Use -d to turn on sanitizers (for debugging only)" | |
7 | exit;; | |
8 | d ) configureOpts="" | |
9 | ;; | |
10 | \? ) echo "Usage: $0 [-h] [-d]" | |
11 | exit;; | |
12 | esac | |
13 | done | |
14 | ||
15 | configureOpts="${configureOpts} --prefix=/usr --sysconfdir=/etc" | |
16 | ||
1 | 17 | autoreconf -fiv |
2 | 18 | |
3 | 19 | BUILD_DIR=build/ |
5 | 21 | mkdir -vp $BUILD_DIR |
6 | 22 | cd $BUILD_DIR || { echo "cd $BUILD_DIR"; exit 127; } |
7 | 23 | |
8 | ../configure --prefix=/usr --sysconfdir=/etc | |
24 | ../configure ${configureOpts} | |
9 | 25 | |
10 | 26 | make |
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 | |
159 | 158 | |
160 | 159 | AS_HELP_STRING([enable debug flags:], [${ax_enable_debug}]) |
161 | 160 | AS_HELP_STRING([code coverage:], [${CODE_COVERAGE_ENABLED}]) |
162 | AS_HELP_STRING([enabled sanitizers:], [${ax_enabled_sanitizers}]) | |
161 | AS_HELP_STRING([enabled sanitizers:], [${ax_enabled_sanitizers}])" | |
163 | 162 | |
164 | To compile, run: | |
165 | ||
166 | cd `pwd` && make | |
167 | --------------------------------------------------------------------------------" | |
163 | #To compile, run: | |
164 | # | |
165 | # cd `pwd` && make | |
166 | echo \ | |
167 | "--------------------------------------------------------------------------------" |
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 | --insidever-color=$C \ | |
11 | --ringver-color=$V \ | |
12 | \ | |
13 | --insidewrong-color=$C \ | |
14 | --ringwrong-color=$W \ | |
15 | \ | |
16 | --inside-color=$B \ | |
17 | --ring-color=$D \ | |
18 | --line-color=$B \ | |
19 | --separator-color=$D \ | |
20 | \ | |
21 | --verif-color=$T \ | |
22 | --wrong-color=$T \ | |
23 | --time-color=$T \ | |
24 | --date-color=$T \ | |
25 | --layout-color=$T \ | |
26 | --keyhl-color=$W \ | |
27 | --bshl-color=$W \ | |
28 | \ | |
29 | --screen 1 \ | |
30 | --blur 5 \ | |
31 | --clock \ | |
32 | --indicator \ | |
33 | --time-str="%H:%M:%S" \ | |
34 | --date-str="%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-pos y+h \ | |
13 | --bar-direction 1 \ | |
14 | --bar-max-height 50 \ | |
15 | --bar-base-width 50 \ | |
16 | --bar-color 000000cc \ | |
17 | --keyhl-color 880088cc \ | |
18 | --bar-periodic-step 50 \ | |
19 | --bar-step 50 \ | |
20 | --redraw-thread \ | |
21 | \ | |
22 | --clock \ | |
23 | --force-clock \ | |
24 | --time-pos x+5:y+h-80 \ | |
25 | --time-color 880088ff \ | |
26 | --date-pos tx:ty+15 \ | |
27 | --date-color 990099ff \ | |
28 | --date-align 1 \ | |
29 | --time-align 1 \ | |
30 | --ringver-color 8800ff88 \ | |
31 | --ringwrong-color ff008888 \ | |
32 | --status-pos x+5:y+h-16 \ | |
33 | --verif-align 1 \ | |
34 | --wrong-align 1 \ | |
35 | --verif-color ffffffff \ | |
36 | --wrong-color ffffffff \ | |
37 | --modif-pos -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 "JUN 2021" Linux "User Manuals" | |
11 | 11 | |
12 | 12 | .SH NAME |
13 | 13 | i3lock-color \- improved screen locker |
30 | 30 | .RB [\|\-m\|] |
31 | 31 | |
32 | 32 | .SH DESCRIPTION |
33 | .B i3lock-color | |
33 | .B i3lock\-color | |
34 | 34 | is a simple screen locker like slock. After starting it, you will see a white |
35 | 35 | screen (you can configure the color/an image). You can return to your screen by |
36 | 36 | entering your password. |
37 | 37 | |
38 | .SH IMPROVEMENTS | |
38 | .SH FEATURES | |
39 | 39 | .IP \[bu] 2 |
40 | 40 | i3lock forks, so you can combine it with an alias to suspend to RAM |
41 | (run "i3lock && echo mem > /sys/power/state" to get a locked screen after waking up your computer from suspend to RAM) | |
42 | .IP \[bu] | |
43 | You can specify either a background color or a PNG image which will be displayed while your screen is locked. | |
41 | (run "i3lock && echo mem > /sys/power/state" to get a locked screen after waking | |
42 | up your computer from suspend to RAM) | |
43 | .IP \[bu] | |
44 | You can specify either a background color or a PNG image which will be displayed | |
45 | while your screen is locked. | |
44 | 46 | .IP \[bu] |
45 | 47 | You can specify whether i3lock should bell upon a wrong password. |
46 | 48 | .IP \[bu] |
74 | 76 | |
75 | 77 | .TP |
76 | 78 | .BI \fB\-\-raw= format |
77 | Read the image given by \-\-image as a raw image instead of PNG. The argument is the image's format | |
78 | as <width>x<height>:<pixfmt>. The supported pixel formats are: | |
79 | Read the image given by \-\-image as a raw image instead of PNG. The argument is | |
80 | the image's format as <width>x<height>:<pixfmt>. | |
81 | The supported pixel formats are: | |
79 | 82 | \'native', 'rgb', 'xrgb', 'rgbx', 'bgr', 'xbgr', and 'bgrx'. |
80 | 83 | The "native" pixel format expects a pixel as a 32-bit (4-byte) integer in |
81 | the machine's native endianness, with the upper 8 bits unused. Red, green and blue are stored in | |
82 | the remaining bits, in that order. | |
84 | the machine's native endianness, with the upper 8 bits unused. | |
85 | Red, green and blue are stored in the remaining bits, in that order. | |
83 | 86 | |
84 | 87 | .BR Example: |
85 | 88 | .Vb 6 |
104 | 107 | |
105 | 108 | .TP |
106 | 109 | .BI \-c\ rrggbbaa \fR,\ \fB\-\-color= rrggbbaa |
107 | Turn the screen into the given color instead of white. Color must be given in 4-byte | |
108 | 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). | |
110 | Turn the screen into the given color instead of white. Color must be given in | |
111 | 4-byte format: rrggbbaa (i.e. ff0000ff is opaque red). | |
112 | Use the last byte for alpha. Setting this below FF (i.e. ff000088) will allow | |
113 | your screen to be shown translucently if you use a compositor (e.g. compton, | |
114 | xcompmgr). | |
110 | 115 | |
111 | 116 | .TP |
112 | 117 | .B \-t, \-\-tiling |
113 | If an image is specified (via \-i) it will display the image tiled all over the screen | |
114 | (with a multi-monitor setup, the image is visible on all screens). | |
118 | If an image is specified (via \-i) it will display the image tiled all over the | |
119 | screen. | |
120 | ||
121 | Note: For all image options, with a multi-monitor setup, the image is visible on | |
122 | all screens. | |
115 | 123 | |
116 | 124 | .TP |
117 | 125 | .B \-C, \-\-centered |
118 | If an image is specified (via \-i) it will display the image centered on the screen | |
119 | (with a multi-monitor setup, the image is visible on all screens). | |
126 | If an image is specified (via \-i) it will display the image centered on the | |
127 | screen. | |
128 | ||
129 | .TP | |
130 | .B \-F, \-\-fill | |
131 | If an image is specified (via \-i) it will scale the image until it fills the | |
132 | screen. A portion of the image will be cropped. | |
133 | ||
134 | .TP | |
135 | .B \-M, \-\-max | |
136 | If an image is specified (via \-i) it will scale the image until either the | |
137 | width or the height fits the screen without being cropped. The border color | |
138 | can be set via \-c. | |
139 | ||
140 | .TP | |
141 | .B \-L, \-\-scale | |
142 | If an image is specified (via \-i) it will stretch the image until both the | |
143 | width and the height fits the screen. | |
120 | 144 | |
121 | 145 | .TP |
122 | 146 | .BI \-p\ win|default \fR,\ \fB\-\-pointer= win|default |
129 | 153 | |
130 | 154 | .TP |
131 | 155 | .B \-e, \-\-ignore\-empty\-password |
132 | When an empty password is provided by the user, do not validate | |
133 | it. Without this option, the empty password will be provided to PAM | |
134 | and, if invalid, the user will have to wait a few seconds before | |
135 | another try. This can be useful if the XF86ScreenSaver key is used to | |
136 | put a laptop to sleep and bounce on resume or if you happen to wake up | |
137 | your computer with the enter key. | |
156 | When an empty password is provided by the user, do not validate it. Without this | |
157 | option, the empty password will be provided to PAM and, if invalid, the user | |
158 | will have to wait a few seconds before another try. This can be useful if the | |
159 | XF86ScreenSaver key is used to put a laptop to sleep and bounce on resume or if | |
160 | you happen to wake up your computer with the enter key. | |
138 | 161 | |
139 | 162 | .TP |
140 | 163 | .B \-f, \-\-show\-failed\-attempts |
145 | 168 | Enables debug logging. |
146 | 169 | Note, that this will log the password used for authentication to stdout. |
147 | 170 | |
148 | .SH i3lock-color options | |
171 | .SH i3lock-color OPTIONS | |
149 | 172 | .TP |
150 | 173 | .B \-S number, \-\-screen=number |
151 | Specifies which display to draw the unlock indicator and clock on. By default, they'll be placed on every screen. | |
174 | Specifies which display to draw the unlock indicator and clock on. By default, | |
175 | they'll be placed on every screen. | |
152 | 176 | Note that this number is zero indexed. The ordering is dependent on libxinerama. |
153 | 177 | |
154 | 178 | .TP |
155 | 179 | .B \-B sigma, \-\-blur=sigma |
156 | 180 | Captures the screen and blurs it using the given sigma (radius). |
157 | 181 | Images may still be overlaid over the blurred screenshot. |
158 | As an alternative to this option, you could specify a translucent background color | |
159 | (-c option) with a fully transparent or translucent color, and use a compositor to perform blurring (e.g. compton, picom). | |
182 | As an alternative to this option, you could specify a translucent background | |
183 | color (-c option) with a fully transparent or translucent color, and use a | |
184 | compositor to perform blurring (e.g. compton, picom). | |
185 | ||
186 | .TP | |
187 | .B \-k, \-\-clock, \-\-force\-clock | |
188 | Displays the clock. \-\-force\-clock also displays the clock when there's | |
189 | indicator text (useful for when the clock is not positioned with the indicator). | |
160 | 190 | |
161 | 191 | .TP |
162 | 192 | .B \-\-indicator |
163 | 193 | Forces the indicator to always be visible, instead of only showing on activity. |
164 | 194 | |
165 | 195 | .TP |
196 | .B \-\-radius | |
197 | The radius of the circle. Defaults to 90. | |
198 | ||
199 | .TP | |
200 | .B \-\-ring\-width | |
201 | The width of the ring unlock indicator. Defaults to 7.0. | |
202 | ||
203 | .TP | |
204 | .B \-\-{inside, ring}\-color=rrggbbaa | |
205 | Sets the idle color for the interior circle and ring. Note: use individual | |
206 | options per element unless the shell supports brace expansion (in which case | |
207 | remove the spaces inside the curly braces). | |
208 | ||
209 | .TP | |
210 | .B \-\-{inside, ring}ver\-color=rrggbbaa | |
211 | Sets the interior circle and ring color while the password is being verified. | |
212 | ||
213 | .TP | |
214 | .B \-\-{inside, ring}wrong\-color=rrggbbaa | |
215 | Sets the interior circle and ring color for during incorrect password flashes. | |
216 | ||
217 | .TP | |
218 | .B \-\-line\-color=rrggbbaa | |
219 | Sets the color for the line separating the inside circle and the outer ring. | |
220 | ||
221 | .TP | |
222 | .B \-\-line\-uses\-{inside, ring} | |
223 | Overrides \-\-line\-color. The line will match the {inside, ring} color. | |
224 | Note: these two options conflict with each other. | |
225 | ||
226 | .TP | |
227 | .B \-\-{key, bs}hl\-color=rrggbbaa | |
228 | Sets the color of highlight arcs on the ring upon keypress and backspace. | |
229 | ||
230 | .TP | |
231 | .B \-\-separator\-color=rrggbbaa | |
232 | Sets the color of the seperators at both ends of the highlight arcs on the ring. | |
233 | ||
234 | .TP | |
235 | .B \-\-{verif, wrong, modif}\-color=rrggbbaa | |
236 | Sets the color of the status text while verifying and when password is wrong. | |
237 | ||
238 | .TP | |
239 | .B \-\-{layout, time, date, greeter}\-color=rrggbbaa | |
240 | Sets text colors. | |
241 | ||
242 | .TP | |
243 | .B \-\-time\-str="%H:%M:%S" | |
244 | Sets the format used for generating the time string. | |
245 | See strftime(3) for a full list of format specifiers. | |
246 | ||
247 | .TP | |
248 | .B \-\-date\-str="%A, %m %Y" | |
249 | Sets the format used for generating the date string. | |
250 | ||
251 | .TP | |
252 | .B \-\-verif\-text="verifying…" | |
253 | Sets the string to be shown while verifying the password/input/key/etc. | |
254 | ||
255 | .TP | |
256 | .B \-\-wrong\-text="wrong!" | |
257 | Sets the string to be shown upon entering an incorrect password. | |
258 | ||
259 | .TP | |
166 | 260 | .B \-\-keylayout mode |
167 | Displays the keylayout. Positionable similar to date, time, and indicator. Modes are as follows: | |
168 | .RS | |
169 | .RS | |
261 | Displays the keylayout. Positionable similar to date, time, and indicator. | |
262 | Modes are as follows: | |
263 | .RS | |
264 | .IP \[bu] 2 | |
170 | 265 | 0 - Displays the full string returned by the query, i.e. "English (US)" |
266 | .IP \[bu] | |
171 | 267 | 1 - Displays up until the first parenthesis, i.e. "English" |
268 | .IP \[bu] | |
172 | 269 | 2 - Displays just the contents of the parenthesis, i.e. "US" |
173 | 270 | .RE |
174 | .RE | |
175 | ||
176 | .TP | |
177 | .B \-k, \-\-clock, \-\-force\-clock | |
178 | Displays the clock. \-\-force\-clock also displays the clock when there's indicator text | |
179 | (useful for when the clock is not positioned with the indicator). | |
180 | ||
181 | .TP | |
182 | .B \-\-composite | |
183 | Some compositors have problems with i3lock trying to render over them, so this argument is disabled by default. | |
184 | However, some will work properly with it, so it's been left enabled. | |
185 | ||
186 | .TP | |
187 | .B \-\-pass\-media\-keys | |
188 | Allow the following keys to be used while the screen is locked by passing them through: | |
189 | XF86AudioPlay, XF86AudioPause, XF86AudioStop, XF86AudioPrev, XF86AudioNext, XF86AudioMute, XF86AudioLowerVolume, XF86AudioRaiseVolume. | |
190 | ||
191 | .TP | |
192 | .B \-\-pass\-screen\-keys | |
193 | Allow the following keys to be used while the screen is locked by passing them through: | |
194 | XF86MonBrightnessUp, XF86MonBrightnessDown. | |
195 | ||
196 | .TP | |
197 | .B \-\-pass\-power\-keys | |
198 | Allow the following keys to be used while the screen is locked by passing them through: | |
199 | 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. | |
205 | ||
206 | .TP | |
207 | .B \-\-insidevercolor=rrggbbaa | |
208 | Sets the interior circle color while the password is being verified. | |
209 | ||
210 | .TP | |
211 | .B \-\-insidewrongcolor=rrggbbaa | |
212 | Sets the interior circle color for during flash for an incorrect password. | |
213 | ||
214 | .TP | |
215 | .B \-\-insidecolor=rrggbbaa | |
216 | Sets the default "resting" color for the interior circle. | |
217 | ||
218 | .TP | |
219 | .B \-\-ringvercolor=rrggbbaa | |
220 | Sets the ring color while the password is being verified. | |
221 | ||
222 | .TP | |
223 | .B \-\-ringwrongcolor=rrggbbaa | |
224 | Sets the ring color during the flash for an incorrect password. | |
225 | ||
226 | .TP | |
227 | .B \-\-ringcolor=rrggbbaa | |
228 | Sets the default ring color. | |
229 | ||
230 | .TP | |
231 | .B \-\-linecolor=rrggbbaa | |
232 | Sets the color for the line separating the inside circle, and the outer ring. | |
233 | ||
234 | .TP | |
235 | .B \-\-line\-uses\-ring | |
236 | Conflicts with \-\-line\-uses\-inside. Overrides \-\-linecolor. The line will match the ring color. | |
237 | ||
238 | .TP | |
239 | .B \-\-line\-uses\-inside | |
240 | Conflicts with \-\-line\-uses\-ring. Overrides \-\-linecolor; the line will match the inside color. | |
241 | ||
242 | .TP | |
243 | .B \-\-keyhlcolor=rrggbbaa | |
244 | Sets the color of the ring 'highlight' strokes that appear upon keypress. | |
245 | ||
246 | .TP | |
247 | .B \-\-bshlcolor=rrggbbaa | |
248 | Sets the color of the ring 'highlight' strokes that appear upon backspace. | |
249 | ||
250 | .TP | |
251 | .B \-\-separatorcolor=rrggbbaa | |
252 | Sets the color of the 'separtor', which is at both ends of the ring highlights. | |
253 | ||
254 | .TP | |
255 | .B \-\-verifcolor=rrggbbaa | |
256 | Sets the color of the status text while verifying. | |
257 | ||
258 | .TP | |
259 | .B \-\-wrongcolor=rrggbbaa | |
260 | Sets the color of the status text when "wrong". | |
261 | ||
262 | .TP | |
263 | .B \-\-layoutcolor=rrggbbaa | |
264 | Sets the color of the keyboard layout text. | |
265 | ||
266 | .TP | |
267 | .B \-\-indpos="x position:y position" | |
268 | Sets the position for the unlock indicator. Valid variables include: | |
269 | .RS | |
270 | .RS | |
271 | x - x position of the current display. Corresponds to the leftmost row of pixels on that display. | |
272 | y - y position of the current display. Corresponds to the topmost row of pixels on that display. | |
273 | w - width of the current display. | |
274 | h - height of the current display. | |
275 | r - the unlock indicator radius. | |
276 | .RE | |
277 | .RE | |
278 | ||
279 | .TP | |
280 | .B \-\-timecolor=rrggbbaa | |
281 | Sets the color of the time in the clock. | |
282 | ||
283 | .TP | |
284 | .B \-\-timestr="%H:%M:%S" | |
285 | Sets the format used for generating the time string. See strftime(3) for a full list of format specifiers. | |
286 | ||
287 | .TP | |
288 | .B \-\-timepos="x position:y position" | |
289 | Sets the position for the time string. All the variables from \-\-indpos may be used, in addition to: | |
290 | .RS | |
291 | .RS | |
292 | ix - the x value of the indicator on the current display. | |
293 | iy - the y value of the indicator on the current display. | |
294 | .RE | |
295 | .RE | |
296 | ||
297 | .TP | |
298 | .B \-\-time\-align, \-\-date\-align, \-\-layout\-align, \-\-verif\-align, \-\-wrong\-align, \-\-modif\-align, \-\-greeter\-align | |
299 | Sets the text alignment of the time, date, keylayout, verification text, wrong text, modifier text and greeter text. | |
300 | .RS | |
301 | .RS | |
271 | ||
272 | .TP | |
273 | .B \-\-noinput\-text="no input" | |
274 | Sets the string to be shown upon pressing backspace without anything to delete. | |
275 | ||
276 | .TP | |
277 | .B \-\-lock\-text="locking…" | |
278 | Sets the string to be shown while acquiring pointer and keyboard focus. | |
279 | ||
280 | .TP | |
281 | .B \-\-lockfailed\-text="lock failed!" | |
282 | Sets the string to be shown after failing to acquire pointer and keyboard focus. | |
283 | ||
284 | .TP | |
285 | .B \-\-greeter\-text="" | |
286 | Sets the greeter text. | |
287 | ||
288 | .TP | |
289 | .B \-\-no\-modkey\-text | |
290 | Hides the modkey indicator (Num, Caps Lock ...) | |
291 | ||
292 | .TP | |
293 | .B \-\-{time, date, layout, verif, wrong, modif, greeter}\-align | |
294 | Sets the text alignment of the time, date, keylayout, verification, wrong, | |
295 | modifier and greeter texts. | |
296 | .RS | |
297 | .IP \[bu] 2 | |
302 | 298 | 0 - centered (default) |
299 | .IP \[bu] | |
303 | 300 | 1 - left aligned |
301 | .IP \[bu] | |
304 | 302 | 2 - right aligned |
305 | 303 | .RE |
306 | .RE | |
307 | ||
308 | .TP | |
309 | .B \-\-datecolor=rrggbbaa | |
310 | Sets the color of the date in the clock. | |
311 | ||
312 | .TP | |
313 | .B \-\-datestr="%A, %m %Y" | |
314 | Sets the format used for generating the date string. See strftime(3) for a full list of format specifiers. | |
304 | ||
305 | .TP | |
306 | .B \-\-{time, date, layout, verif, wrong, greeter, modif}outline\-color=rrggbbaa | |
307 | Sets the color of the outlines. | |
315 | 308 | |
316 | 309 | .TP |
317 | 310 | .B \-\-{time, date, layout, verif, wrong, greeter}\-font=sans\-serif |
318 | 311 | Sets the font used to render various strings. |
319 | 312 | |
320 | 313 | .TP |
321 | .B \-\-{time, date, layout, verif, wrong, greeter}size=number | |
314 | .B \-\-{time, date, layout, verif, wrong, greeter}\-size=number | |
322 | 315 | Sets the font size used to render various strings. |
323 | 316 | |
324 | 317 | .TP |
325 | .B \-\-datepos="x position:y position" | |
326 | Sets the position for the date string. All the variables from \-\-indpos and \-\-timepos may be used, in addition to: | |
327 | .RS | |
328 | .RS | |
329 | tx - the computed x value of the timestring, for the current display. | |
330 | ty - the computed y value of the timestring, for the current display. | |
331 | .RE | |
332 | .RE | |
333 | ||
334 | .TP | |
335 | .B \-\-greetertext="text" | |
336 | Sets the greeter text. Defaults to "". | |
337 | ||
338 | .TP | |
339 | .B \-\-greetercolor=rrggbbaa | |
340 | Sets the color of the greeter text. | |
341 | ||
342 | .TP | |
343 | .B \-\-greeterpos="x position:y position" | |
344 | Sets the position for the greeter string. All the variables from \-\-indpos and \-\-timepos may be used. | |
345 | ||
346 | .TP | |
347 | .B \-\-refresh\-rate=seconds\-as\-double | |
348 | The refresh rate of the indicator, given in seconds. This should automatically align itself, but is somewhat buggy currently. | |
349 | Values less than one will work, but may result in poor system performance. | |
350 | ||
351 | .TP | |
352 | .B \-\-veriftext="text" | |
353 | Sets the string to be shown while verifying the password/input/key/etc. Defaults to "verifying…". | |
354 | ||
355 | .TP | |
356 | .B \-\-wrongtext="text" | |
357 | Sets the string to be shown upon entering an incorrect password. Defaults to "wrong!". | |
358 | ||
359 | .TP | |
360 | .B \-\-noinputtext="text" | |
361 | Sets the string to be shown upon pressing backspace without anything to delete. Defaults to "no input". | |
362 | ||
363 | .TP | |
364 | .B \-\-locktext="text" | |
365 | Sets the string to be shown while acquiring pointer and keyboard focus. Defaults to "locking…". | |
366 | ||
367 | .TP | |
368 | .B \-\-lockfailedtext="text" | |
369 | Sets the string to be shown after failing to acquire pointer and keyboard focus. Defaults to "lock failed!". | |
370 | ||
371 | .TP | |
372 | .B \-\-radius | |
373 | The radius of the circle. Defaults to 90. | |
374 | ||
375 | .TP | |
376 | .B \-\-ring\-width | |
377 | The width of the ring unlock indicator. Defaults to 7.0. | |
318 | .B \-\-{time, date, layout, verif, wrong, greeter, modifier}outline\-width=number | |
319 | Sets the width of the outline. | |
320 | ||
321 | .TP | |
322 | .B \-\-ind\-pos="x\-position:y\-position" | |
323 | Sets the position for the unlock indicator. Valid variables include: | |
324 | .RS | |
325 | .IP \[bu] 2 | |
326 | x - x position of the current display. | |
327 | Corresponds to the leftmost column of pixels on that display. | |
328 | .IP \[bu] | |
329 | y - y position of the current display. | |
330 | Corresponds to the topmost row of pixels on that display. | |
331 | .IP \[bu] | |
332 | w - width of the current display. | |
333 | .IP \[bu] | |
334 | h - height of the current display. | |
335 | .IP \[bu] | |
336 | r - unlock indicator radius. | |
337 | .RE | |
338 | ||
339 | .TP | |
340 | .B \-\-time\-pos="x\-position:y\-position" | |
341 | Sets the position for the time string. All the variables from \-\-ind\-pos may | |
342 | be used, in addition to: | |
343 | .RS | |
344 | .IP \[bu] 2 | |
345 | ix - x position of the indicator on the current display. | |
346 | .IP \[bu] | |
347 | iy - y position of the indicator on the current display. | |
348 | ||
349 | If the \-\-bar\-indicator option is used, the following variables may be used: | |
350 | .IP \[bu] 2 | |
351 | bw - width of the bar indicator. | |
352 | .IP \[bu] | |
353 | bx - x position of the bar indicator on the current display. | |
354 | .IP \[bu] | |
355 | by - y position of the bar indicator on the current display. | |
356 | .RE | |
357 | ||
358 | .TP | |
359 | .B \-\-date\-pos="x\-position:y\-position" | |
360 | Sets the position for the date string. All the variables from \-\-ind\-pos and | |
361 | \-\-time\-pos may be used, in addition to: | |
362 | .RS | |
363 | .IP \[bu] 2 | |
364 | tx - x position of the timestring on the current display. | |
365 | .IP \[bu] | |
366 | ty - y position of the timestring on the current display. | |
367 | .RE | |
368 | ||
369 | .TP | |
370 | .B \-\-greeter\-pos="x\-position:y\-position" | |
371 | Sets the position for the greeter string. All the variables from \-\-ind\-pos and | |
372 | \-\-time\-pos may be used. | |
373 | ||
374 | .TP | |
375 | .B \-\-pass\-{media, screen, power, volume}\-keys | |
376 | Allow the following keys to be used normally while the screen is locked by | |
377 | passing them through: | |
378 | .RS | |
379 | .IP \[bu] 2 | |
380 | media - XF86AudioPlay, XF86AudioPause, XF86AudioStop, XF86AudioPrev, | |
381 | XF86AudioNext, XF86AudioMute, XF86AudioLowerVolume, XF86AudioRaiseVolume | |
382 | .IP \[bu] | |
383 | screen - XF86MonBrightnessUp, XF86MonBrightnessDown | |
384 | .IP \[bu] | |
385 | power - XF86PowerDown, XF86PowerOff, XF86Sleep | |
386 | .IP \[bu] | |
387 | volume - XF86AudioMute, XF86AudioLowerVolume, XF86AudioRaiseVolume | |
388 | .RE | |
378 | 389 | |
379 | 390 | .TP |
380 | 391 | .B \-\-bar\-indicator |
381 | Replaces the usual ring indicator with a bar indicator, with a variety of options. | |
382 | ||
383 | .TP | |
384 | .B \-\-redraw\-thread | |
385 | Starts a separate thread for redrawing the screen. Potentially worse for security, but makes the bar indicator still do | |
386 | its usual periodic redraws when PAM is authenticating. | |
392 | Replaces the usual ring indicator with a bar indicator. Comes with perks. | |
387 | 393 | |
388 | 394 | .TP |
389 | 395 | .B \-\-bar\-direction={0, 1, 2} |
390 | Sets the direction the bars grow in. 0 is the default (downwards, or rightwards, depending on the bar orientation). 1 is the reverse, and 2 is both. | |
391 | ||
392 | .TP | |
393 | .B \-\-bar\-width=15 | |
394 | Sets the width of the minibars in the bar. | |
396 | Sets the direction the bars grow in. 0 is the default (downwards, or rightwards, | |
397 | depending on the bar orientation). 1 is the reverse, and 2 is both. | |
395 | 398 | |
396 | 399 | .TP |
397 | 400 | .B \-\-bar\-orientation={vertical,horizontal} |
398 | Sets whether the bar is vertically or horizontally oriented. Defaults to horizontal. | |
401 | Sets whether the bar is vertically or horizontally oriented. | |
402 | Defaults to horizontal. | |
399 | 403 | |
400 | 404 | .TP |
401 | 405 | .B \-\-bar\-step |
402 | Sets the step that each bar decreases by when a key is pressed. A random bar is set to its max height, | |
403 | and then each neighbor is set to (height - step*distance). | |
406 | Sets the step that each bar decreases by when a key is pressed. A random bar is | |
407 | set to its max height, then each neighbor is set to (height - step*distance). | |
404 | 408 | |
405 | 409 | .TP |
406 | 410 | .B \-\-bar\-max\-height |
407 | The maximum height a bar can get to. When a key is pressed, a random bar is set to this value, | |
408 | and then its neighbors are set to its height, minus the step value. | |
411 | The maximum height a bar can get to. When a key is pressed, a random bar is set | |
412 | to this value, then its neighbors are set to its height, minus the step value. | |
409 | 413 | |
410 | 414 | .TP |
411 | 415 | .B \-\-bar\-base\-width |
412 | 416 | The thickness of the "base" bar that all the bars originate from. |
413 | This bar also takes on the ring verif and wrong colors to give authentication feedback. | |
417 | This bar also takes on the ring verification and wrong colors to give | |
418 | authentication feedback. | |
414 | 419 | |
415 | 420 | .TP |
416 | 421 | .B \-\-bar\-color |
421 | 426 | The value by which the bars decrease each time the screen is redrawn. |
422 | 427 | |
423 | 428 | .TP |
424 | .B \-\-bar\-position | |
425 | Works similarly to the time/date/indicator expressions. If the bar is horizontal, this sets the vertical offset from the top edge. | |
426 | If it's vertically oriented, this sets the horizontal offset from the left edge. | |
429 | .B \-\-bar\-pos | |
430 | Works similarly to the time/date/indicator expressions. If only one number is | |
431 | provided, this sets the vertical offset from the top or left edge. If two | |
432 | numbers are provided in the form of x:y, sets the starting position of the bar. | |
433 | ||
434 | .TP | |
435 | .B \-\-bar\-count | |
436 | Sets the number of minibars to draw on each screen. | |
437 | ||
438 | .TP | |
439 | .B \-\-bar\-total\-width | |
440 | The total width of the bar. Can be an expression. | |
441 | ||
442 | .TP | |
443 | .B \-\-redraw\-thread | |
444 | Starts a separate thread for redrawing the screen. Potentially worse from a | |
445 | security standpoint, but makes the bar indicator still do its usual periodic | |
446 | redraws when PAM is authenticating. | |
447 | ||
448 | .TP | |
449 | .B \-\-refresh\-rate=seconds\-as\-double | |
450 | The refresh rate of the indicator, given in seconds. This should automatically | |
451 | align itself, but is somewhat buggy currently. | |
452 | Values less than one will work, but may result in poor system performance. | |
453 | ||
454 | .TP | |
455 | .B \-\-composite | |
456 | Some compositors have problems with i3lock trying to render over them, so this | |
457 | argument is disabled by default. However, some will work properly with it, so | |
458 | it's been left enabled. | |
427 | 459 | |
428 | 460 | .TP |
429 | 461 | .B \-\-no\-verify |
430 | 462 | Do not verify the password entered by the user and unlock immediately. |
431 | .B Use only for quickly testing new configurations and remember to remove to actually lock your screen! | |
432 | ||
433 | .SH DPMS | |
434 | The \-d (\-\-dpms) option was removed from i3lock in version 2.8. There were | |
435 | plenty of use-cases that were not properly addressed, and plenty of bugs | |
436 | surrounding that feature. While features are not normally removed from i3 and | |
437 | its tools, we felt the need to make an exception in this case. | |
438 | Users who wish to explicitly enable DPMS only when their screen is locked can | |
439 | use a wrapper script around i3lock like the following: | |
440 | .Vb 6 | |
441 | \& #!/bin/sh | |
442 | \& revert() { | |
443 | \& xset dpms 0 0 0 | |
444 | \& } | |
445 | \& trap revert HUP INT TERM | |
446 | \& xset +dpms dpms 5 5 5 | |
447 | \& i3lock -n | |
448 | \& revert | |
449 | .Ve | |
450 | The \-I (\-\-inactivity\-timeout=seconds) was removed because it only makes sense with DPMS. | |
463 | .B Use only for quickly testing new configurations and remember to remove to | |
464 | .B actually lock your screen! | |
465 | ||
466 | .TP | |
467 | .B \-\-slideshow\-interval | |
468 | The interval to wait until switching to the next image. | |
469 | ||
470 | .TP | |
471 | .B \-\-slideshow\-random\-selection | |
472 | Randomize the order of the images. | |
451 | 473 | |
452 | 474 | .SH SEE ALSO |
453 | 475 | .IR xautolock(1) |
2 | 2 | * |
3 | 3 | * © 2010 Michael Stapelberg |
4 | 4 | * © 2015 Cassandra Fox |
5 | * © 2020 Raymond Li | |
5 | * © 2021 Raymond Li | |
6 | 6 | * |
7 | 7 | * See LICENSE for licensing information |
8 | 8 | * |
69 | 69 | typedef void (*ev_callback_t)(EV_P_ ev_timer *w, int revents); |
70 | 70 | static void input_done(void); |
71 | 71 | |
72 | char color[9] = "ffffffff"; | |
72 | char color[9] = "a3a3a3ff"; | |
73 | 73 | |
74 | 74 | /* options for unlock indicator colors */ |
75 | 75 | char insidevercolor[9] = "006effbf"; |
84 | 84 | char layoutcolor[9] = "000000ff"; |
85 | 85 | char timecolor[9] = "000000ff"; |
86 | 86 | char datecolor[9] = "000000ff"; |
87 | char modifcolor[9] = "000000ff"; | |
87 | 88 | char keyhlcolor[9] = "33db00ff"; |
88 | 89 | char bshlcolor[9] = "db3300ff"; |
89 | 90 | char separatorcolor[9] = "000000ff"; |
90 | 91 | char greetercolor[9] = "000000ff"; |
91 | 92 | |
93 | char verifoutlinecolor[9] = "00000000"; | |
94 | char wrongoutlinecolor[9] = "00000000"; | |
95 | char layoutoutlinecolor[9] = "00000000"; | |
96 | char timeoutlinecolor[9] = "00000000"; | |
97 | char dateoutlinecolor[9] = "00000000"; | |
98 | char greeteroutlinecolor[9] = "00000000"; | |
99 | char modifoutlinecolor[9] = "00000000"; | |
100 | ||
92 | 101 | /* int defining which display the lock indicator should be shown on. If -1, then show on all displays.*/ |
93 | 102 | int screen_number = 0; |
103 | ||
94 | 104 | /* 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 | 105 | int internal_line_source = 0; |
96 | /* bool for showing the clock; why am I commenting this? */ | |
106 | ||
107 | /* refresh rate in seconds, default to 1s */ | |
108 | float refresh_rate = 1.0; | |
109 | ||
97 | 110 | bool show_clock = false; |
98 | 111 | bool slideshow_enabled = false; |
99 | 112 | bool always_show_clock = false; |
100 | 113 | bool show_indicator = false; |
101 | float refresh_rate = 1.0; | |
114 | bool show_modkey_text = true; | |
102 | 115 | |
103 | 116 | /* there's some issues with compositing - upstream removed support for this, but we'll allow people to supply an arg to enable it */ |
104 | 117 | bool composite = false; |
166 | 179 | double circle_radius = 90.0; |
167 | 180 | double ring_width = 7.0; |
168 | 181 | double greeter_size = 32.0; |
182 | ||
183 | double timeoutlinewidth = 0; | |
184 | double dateoutlinewidth = 0; | |
185 | double verifoutlinewidth = 0; | |
186 | double wrongoutlinewidth = 0; | |
187 | double modifieroutlinewidth = 0; | |
188 | double layoutoutlinewidth = 0; | |
189 | double greeteroutlinewidth = 0; | |
169 | 190 | |
170 | 191 | char* verif_text = "verifying…"; |
171 | 192 | char* wrong_text = "wrong!"; |
221 | 242 | static int randr_base = -1; |
222 | 243 | |
223 | 244 | cairo_surface_t *img = NULL; |
224 | cairo_surface_t *blur_img = NULL; | |
225 | 245 | cairo_surface_t *img_slideshow[256]; |
246 | cairo_surface_t *blur_bg_img = NULL; | |
226 | 247 | int slideshow_image_count = 0; |
227 | 248 | int slideshow_interval = 10; |
228 | 249 | bool slideshow_random_selection = false; |
229 | 250 | |
230 | bool tile = false; | |
231 | bool centered = false; | |
251 | background_type_t bg_type = NONE; | |
252 | ||
232 | 253 | bool ignore_empty_password = false; |
233 | 254 | bool skip_repeated_empty_password = false; |
234 | 255 | bool pass_media_keys = false; |
242 | 263 | // allow you to disable. handy if you use bar with lots of crap. |
243 | 264 | bool redraw_thread = false; |
244 | 265 | |
266 | // experimental bar stuff | |
245 | 267 | #define BAR_VERT 0 |
246 | 268 | #define BAR_FLAT 1 |
247 | 269 | #define BAR_DEFAULT 0 |
248 | 270 | #define BAR_REVERSED 1 |
249 | 271 | #define BAR_BIDIRECTIONAL 2 |
250 | // experimental bar stuff | |
272 | #define MAX_BAR_COUNT 65535 | |
273 | #define MIN_BAR_COUNT 1 | |
274 | ||
251 | 275 | bool bar_enabled = false; |
252 | 276 | double *bar_heights = NULL; |
253 | 277 | double bar_step = 15; |
254 | 278 | double bar_base_height = 25; |
255 | 279 | double bar_periodic_step = 15; |
256 | 280 | double max_bar_height = 25; |
257 | int num_bars = 0; | |
258 | int bar_width = 150; | |
281 | int bar_count = 10; | |
259 | 282 | int bar_orientation = BAR_FLAT; |
260 | 283 | |
261 | 284 | char bar_base_color[9] = "000000ff"; |
262 | char bar_expr[32] = "0\0"; | |
285 | char bar_x_expr[32] = "0"; | |
286 | char bar_y_expr[32] = ""; // empty string on y means use x as offset based on orientation | |
287 | char bar_width_expr[32] = ""; // empty string means full width based on bar orientation | |
263 | 288 | bool bar_bidirectional = false; |
264 | 289 | bool bar_reversed = false; |
265 | 290 | |
575 | 600 | else if (strcmp(mod_name, XKB_MOD_NAME_LOGO) == 0) |
576 | 601 | mod_name = "Super"; |
577 | 602 | |
578 | char *tmp; | |
579 | if (modifier_string == NULL) { | |
580 | if (asprintf(&tmp, "%s", mod_name) != -1) | |
603 | if (show_modkey_text) { | |
604 | char *tmp; | |
605 | if (modifier_string == NULL) { | |
606 | if (asprintf(&tmp, "%s", mod_name) != -1) | |
607 | modifier_string = tmp; | |
608 | } else if (asprintf(&tmp, "%s, %s", modifier_string, mod_name) != -1) { | |
609 | free(modifier_string); | |
581 | 610 | modifier_string = tmp; |
582 | } else if (asprintf(&tmp, "%s, %s", modifier_string, mod_name) != -1) { | |
583 | free(modifier_string); | |
584 | modifier_string = tmp; | |
611 | } | |
585 | 612 | } |
586 | 613 | } |
587 | 614 | |
1406 | 1433 | {"raw", required_argument, NULL, 998}, |
1407 | 1434 | {"tiling", no_argument, NULL, 't'}, |
1408 | 1435 | {"centered", no_argument, NULL, 'C'}, |
1436 | {"fill", no_argument, NULL, 'F'}, | |
1437 | {"scale", no_argument, NULL, 'L'}, | |
1438 | {"max", no_argument, NULL, 'M'}, | |
1409 | 1439 | {"ignore-empty-password", no_argument, NULL, 'e'}, |
1410 | 1440 | {"inactivity-timeout", required_argument, NULL, 'I'}, |
1411 | 1441 | {"show-failed-attempts", no_argument, NULL, 'f'}, |
1442 | {"screen", required_argument, NULL, 'S'}, | |
1443 | {"blur", required_argument, NULL, 'B'}, | |
1412 | 1444 | |
1413 | 1445 | // options for unlock indicator colors |
1414 | {"insidevercolor", required_argument, NULL, 300}, | |
1415 | {"insidewrongcolor", required_argument, NULL, 301}, | |
1416 | {"insidecolor", required_argument, NULL, 302}, | |
1417 | {"ringvercolor", required_argument, NULL, 303}, | |
1418 | {"ringwrongcolor", required_argument, NULL, 304}, | |
1419 | {"ringcolor", required_argument, NULL, 305}, | |
1420 | {"linecolor", required_argument, NULL, 306}, | |
1421 | {"verifcolor", required_argument, NULL, 307}, | |
1422 | {"wrongcolor", required_argument, NULL, 308}, | |
1423 | {"layoutcolor", required_argument, NULL, 309}, | |
1424 | {"timecolor", required_argument, NULL, 310}, | |
1425 | {"datecolor", required_argument, NULL, 311}, | |
1426 | {"keyhlcolor", required_argument, NULL, 312}, | |
1427 | {"bshlcolor", required_argument, NULL, 313}, | |
1428 | {"separatorcolor", required_argument, NULL, 314}, | |
1429 | {"greetercolor", required_argument, NULL, 315}, | |
1446 | {"insidever-color", required_argument, NULL, 300}, | |
1447 | {"insidewrong-color", required_argument, NULL, 301}, | |
1448 | {"inside-color", required_argument, NULL, 302}, | |
1449 | {"ringver-color", required_argument, NULL, 303}, | |
1450 | {"ringwrong-color", required_argument, NULL, 304}, | |
1451 | {"ring-color", required_argument, NULL, 305}, | |
1452 | {"line-color", required_argument, NULL, 306}, | |
1453 | {"verif-color", required_argument, NULL, 307}, | |
1454 | {"wrong-color", required_argument, NULL, 308}, | |
1455 | {"layout-color", required_argument, NULL, 309}, | |
1456 | {"time-color", required_argument, NULL, 310}, | |
1457 | {"date-color", required_argument, NULL, 311}, | |
1458 | {"modif-color", required_argument, NULL, 322}, | |
1459 | {"keyhl-color", required_argument, NULL, 312}, | |
1460 | {"bshl-color", required_argument, NULL, 313}, | |
1461 | {"separator-color", required_argument, NULL, 314}, | |
1462 | {"greeter-color", required_argument, NULL, 315}, | |
1463 | ||
1464 | // text outline colors | |
1465 | {"verifoutline-color", required_argument, NULL, 316}, | |
1466 | {"wrongoutline-color", required_argument, NULL, 317}, | |
1467 | {"layoutoutline-color", required_argument, NULL, 318}, | |
1468 | {"timeoutline-color", required_argument, NULL, 319}, | |
1469 | {"dateoutline-color", required_argument, NULL, 320}, | |
1470 | {"greeteroutline-color", required_argument, NULL, 321}, | |
1471 | {"modifoutline-color", required_argument, NULL, 323}, | |
1430 | 1472 | |
1431 | 1473 | {"line-uses-ring", no_argument, NULL, 'r'}, |
1432 | 1474 | {"line-uses-inside", no_argument, NULL, 's'}, |
1433 | 1475 | |
1434 | {"screen", required_argument, NULL, 'S'}, | |
1435 | {"blur", required_argument, NULL, 'B'}, | |
1436 | 1476 | {"clock", no_argument, NULL, 'k'}, |
1437 | 1477 | {"force-clock", no_argument, NULL, 400}, |
1438 | 1478 | {"indicator", no_argument, NULL, 401}, |
1449 | 1489 | {"greeter-align", required_argument, NULL, 506}, |
1450 | 1490 | |
1451 | 1491 | // string stuff |
1452 | {"timestr", required_argument, NULL, 510}, | |
1453 | {"datestr", required_argument, NULL, 511}, | |
1454 | {"veriftext", required_argument, NULL, 512}, | |
1455 | {"wrongtext", required_argument, NULL, 513}, | |
1492 | {"time-str", required_argument, NULL, 510}, | |
1493 | {"date-str", required_argument, NULL, 511}, | |
1494 | {"verif-text", required_argument, NULL, 512}, | |
1495 | {"wrong-text", required_argument, NULL, 513}, | |
1456 | 1496 | {"keylayout", required_argument, NULL, 514}, |
1457 | {"noinputtext", required_argument, NULL, 515}, | |
1458 | {"locktext", required_argument, NULL, 516}, | |
1459 | {"lockfailedtext", required_argument, NULL, 517}, | |
1460 | {"greetertext", required_argument, NULL, 518}, | |
1497 | {"noinput-text", required_argument, NULL, 515}, | |
1498 | {"lock-text", required_argument, NULL, 516}, | |
1499 | {"lockfailed-text", required_argument, NULL, 517}, | |
1500 | {"greeter-text", required_argument, NULL, 518}, | |
1501 | {"no-modkey-text", no_argument, NULL, 519}, | |
1461 | 1502 | |
1462 | 1503 | // fonts |
1463 | 1504 | {"time-font", required_argument, NULL, 520}, |
1468 | 1509 | {"greeter-font", required_argument, NULL, 525}, |
1469 | 1510 | |
1470 | 1511 | // text size |
1471 | {"timesize", required_argument, NULL, 530}, | |
1472 | {"datesize", required_argument, NULL, 531}, | |
1473 | {"verifsize", required_argument, NULL, 532}, | |
1474 | {"wrongsize", required_argument, NULL, 533}, | |
1475 | {"layoutsize", required_argument, NULL, 534}, | |
1476 | {"modsize", required_argument, NULL, 535}, | |
1477 | {"greetersize", required_argument, NULL, 536}, | |
1512 | {"time-size", required_argument, NULL, 530}, | |
1513 | {"date-size", required_argument, NULL, 531}, | |
1514 | {"verif-size", required_argument, NULL, 532}, | |
1515 | {"wrong-size", required_argument, NULL, 533}, | |
1516 | {"layout-size", required_argument, NULL, 534}, | |
1517 | {"modif-size", required_argument, NULL, 535}, | |
1518 | {"greeter-size", required_argument, NULL, 536}, | |
1478 | 1519 | |
1479 | 1520 | // text/indicator positioning |
1480 | {"timepos", required_argument, NULL, 540}, | |
1481 | {"datepos", required_argument, NULL, 541}, | |
1482 | {"verifpos", required_argument, NULL, 542}, | |
1483 | {"wrongpos", required_argument, NULL, 543}, | |
1484 | {"layoutpos", required_argument, NULL, 544}, | |
1485 | {"statuspos", required_argument, NULL, 545}, | |
1486 | {"modifpos", required_argument, NULL, 546}, | |
1487 | {"indpos", required_argument, NULL, 547}, | |
1488 | {"greeterpos", required_argument, NULL, 548}, | |
1521 | {"time-pos", required_argument, NULL, 540}, | |
1522 | {"date-pos", required_argument, NULL, 541}, | |
1523 | {"verif-pos", required_argument, NULL, 542}, | |
1524 | {"wrong-pos", required_argument, NULL, 543}, | |
1525 | {"layout-pos", required_argument, NULL, 544}, | |
1526 | {"status-pos", required_argument, NULL, 545}, | |
1527 | {"modif-pos", required_argument, NULL, 546}, | |
1528 | {"ind-pos", required_argument, NULL, 547}, | |
1529 | {"greeter-pos", required_argument, NULL, 548}, | |
1530 | ||
1531 | // text outline width | |
1532 | {"timeoutline-width", required_argument, NULL, 560}, | |
1533 | {"dateoutline-width", required_argument, NULL, 561}, | |
1534 | {"verifoutline-width", required_argument, NULL, 562}, | |
1535 | {"wrongoutline-width", required_argument, NULL, 563}, | |
1536 | {"modifieroutline-width", required_argument, NULL, 564}, | |
1537 | {"layoutoutline-width", required_argument, NULL, 565}, | |
1538 | {"greeteroutline-width", required_argument, NULL, 566}, | |
1489 | 1539 | |
1490 | 1540 | // pass keys |
1491 | 1541 | {"pass-media-keys", no_argument, NULL, 601}, |
1496 | 1546 | // bar indicator stuff |
1497 | 1547 | {"bar-indicator", no_argument, NULL, 700}, |
1498 | 1548 | {"bar-direction", required_argument, NULL, 701}, |
1499 | {"bar-width", required_argument, NULL, 702}, | |
1500 | 1549 | {"bar-orientation", required_argument, NULL, 703}, |
1501 | 1550 | {"bar-step", required_argument, NULL, 704}, |
1502 | 1551 | {"bar-max-height", required_argument, NULL, 705}, |
1503 | 1552 | {"bar-base-width", required_argument, NULL, 706}, |
1504 | 1553 | {"bar-color", required_argument, NULL, 707}, |
1505 | 1554 | {"bar-periodic-step", required_argument, NULL, 708}, |
1506 | {"bar-position", required_argument, NULL, 709}, | |
1555 | {"bar-pos", required_argument, NULL, 709}, | |
1556 | {"bar-count", required_argument, NULL, 710}, | |
1557 | {"bar-total-width", required_argument, NULL, 711}, | |
1507 | 1558 | |
1508 | 1559 | // misc. |
1509 | 1560 | {"redraw-thread", no_argument, NULL, 900}, |
1524 | 1575 | if (getenv("WAYLAND_DISPLAY") != NULL) |
1525 | 1576 | errx(EXIT_FAILURE, "i3lock is a program for X11 and does not work on Wayland. Try https://github.com/swaywm/swaylock instead"); |
1526 | 1577 | |
1527 | char *optstring = "hvnbdc:p:ui:tCeI:frsS:kB:m"; | |
1578 | char *optstring = "hvnbdc:p:ui:tCFLMeI:frsS:kB:m"; | |
1528 | 1579 | char *arg = NULL; |
1529 | 1580 | int opt = 0; |
1530 | 1581 | char padded[9] = "ffffffff"; \ |
1540 | 1591 | if (strlen(arg) != 8 || sscanf(arg, "%08[0-9a-fA-F]", acolor) != 1)\ |
1541 | 1592 | errx(1, #acolor " is invalid, color must be given in 3 or 4-byte format: rrggbb[aa]\n"); |
1542 | 1593 | |
1594 | #define parse_outline_width(awidth)\ | |
1595 | arg = optarg;\ | |
1596 | if (sscanf(arg, "%lf", &awidth) != 1)\ | |
1597 | errx(1, #awidth " must be a number\n");\ | |
1598 | if (awidth < 0) {\ | |
1599 | fprintf(stderr, #awidth " must be a positive double; ignoring...\n");\ | |
1600 | awidth = 0;\ | |
1601 | } | |
1602 | ||
1543 | 1603 | while ((o = getopt_long(argc, argv, optstring, longopts, &longoptind)) != -1) { |
1544 | 1604 | switch (o) { |
1545 | 1605 | case 'v': |
1546 | errx(EXIT_SUCCESS, "version " I3LOCK_VERSION " © 2010 Michael Stapelberg, © 2015 Cassandra Fox, © 2020 Raymond Li"); | |
1606 | errx(EXIT_SUCCESS, "version " I3LOCK_VERSION " © 2010 Michael Stapelberg, © 2015 Cassandra Fox, © 2021 Raymond Li"); | |
1547 | 1607 | case 'n': |
1548 | 1608 | dont_fork = true; |
1549 | 1609 | break; |
1564 | 1624 | image_path = strdup(optarg); |
1565 | 1625 | break; |
1566 | 1626 | case 't': |
1567 | if(centered) { | |
1568 | errx(EXIT_FAILURE, "i3lock-color: Options tiling and centered conflict."); | |
1569 | } | |
1570 | tile = true; | |
1627 | if(bg_type != NONE) { | |
1628 | errx(EXIT_FAILURE, "i3lock-color: Only one background type can be used."); | |
1629 | } | |
1630 | bg_type = TILE; | |
1571 | 1631 | break; |
1572 | 1632 | case 'C': |
1573 | if(tile) { | |
1574 | errx(EXIT_FAILURE, "i3lock-color: Options tiling and centered conflict."); | |
1575 | } | |
1576 | centered = true; | |
1633 | if(bg_type != NONE) { | |
1634 | errx(EXIT_FAILURE, "i3lock-color: Only one background type can be used."); | |
1635 | } | |
1636 | bg_type = CENTER; | |
1637 | break; | |
1638 | case 'F': | |
1639 | if(bg_type != NONE) { | |
1640 | errx(EXIT_FAILURE, "i3lock-color: Only one background type can be used."); | |
1641 | } | |
1642 | bg_type = FILL; | |
1643 | break; | |
1644 | case 'L': | |
1645 | if(bg_type != NONE) { | |
1646 | errx(EXIT_FAILURE, "i3lock-color: Only one background type can be used."); | |
1647 | } | |
1648 | bg_type = SCALE; | |
1649 | break; | |
1650 | case 'M': | |
1651 | if(bg_type != NONE) { | |
1652 | errx(EXIT_FAILURE, "i3lock-color: Only one background type can be used."); | |
1653 | } | |
1654 | bg_type = MAX; | |
1577 | 1655 | break; |
1578 | 1656 | case 'p': |
1579 | 1657 | if (!strcmp(optarg, "win")) { |
1666 | 1744 | case 315: |
1667 | 1745 | parse_color(greetercolor); |
1668 | 1746 | break; |
1747 | case 316: | |
1748 | parse_color(verifoutlinecolor); | |
1749 | break; | |
1750 | case 317: | |
1751 | parse_color(wrongoutlinecolor); | |
1752 | break; | |
1753 | case 318: | |
1754 | parse_color(layoutoutlinecolor); | |
1755 | break; | |
1756 | case 319: | |
1757 | parse_color(timeoutlinecolor); | |
1758 | break; | |
1759 | case 320: | |
1760 | parse_color(dateoutlinecolor); | |
1761 | break; | |
1762 | case 321: | |
1763 | parse_color(greeteroutlinecolor); | |
1764 | break; | |
1765 | case 322: | |
1766 | parse_color(modifcolor); | |
1767 | break; | |
1768 | case 323: | |
1769 | parse_color(modifoutlinecolor); | |
1770 | break; | |
1771 | ||
1669 | 1772 | |
1670 | 1773 | // General indicator opts |
1671 | 1774 | case 400: |
1768 | 1871 | case 518: |
1769 | 1872 | greeter_text = optarg; |
1770 | 1873 | break; |
1874 | case 519: | |
1875 | show_modkey_text = false; | |
1876 | break; | |
1771 | 1877 | |
1772 | 1878 | // Font stuff |
1773 | 1879 | case 520: |
1959 | 2065 | errx(1, "indpos must be of the form x:y\n"); |
1960 | 2066 | } |
1961 | 2067 | break; |
2068 | ||
2069 | // text outline width | |
2070 | case 560: | |
2071 | parse_outline_width(timeoutlinewidth); | |
2072 | break; | |
2073 | case 561: | |
2074 | parse_outline_width(dateoutlinewidth); | |
2075 | break; | |
2076 | case 562: | |
2077 | parse_outline_width(verifoutlinewidth); | |
2078 | break; | |
2079 | case 563: | |
2080 | parse_outline_width(wrongoutlinewidth); | |
2081 | break; | |
2082 | case 564: | |
2083 | parse_outline_width(modifieroutlinewidth); | |
2084 | break; | |
2085 | case 565: | |
2086 | parse_outline_width(layoutoutlinewidth); | |
2087 | break; | |
2088 | case 566: | |
2089 | parse_outline_width(greeteroutlinewidth); | |
2090 | break; | |
2091 | ||
1962 | 2092 | |
1963 | 2093 | // Pass keys |
1964 | 2094 | case 601: |
1992 | 2122 | break; |
1993 | 2123 | } |
1994 | 2124 | break; |
1995 | case 702: | |
1996 | bar_width = atoi(optarg); | |
1997 | if (bar_width < 1) bar_width = 150; | |
1998 | // num_bars and bar_heights* initialized later when we grab display info | |
1999 | break; | |
2000 | 2125 | case 703: |
2001 | 2126 | arg = optarg; |
2002 | 2127 | if (strcmp(arg, "vertical") == 0) |
2027 | 2152 | bar_periodic_step = opt; |
2028 | 2153 | break; |
2029 | 2154 | case 709: |
2030 | //read in to ind_x_expr and ind_y_expr | |
2031 | if (strlen(optarg) > 31) { | |
2032 | // this is overly restrictive since both the x and y string buffers have size 32, but it's easier to check. | |
2033 | errx(1, "indicator position string can be at most 31 characters\n"); | |
2034 | } | |
2035 | 2155 | arg = optarg; |
2036 | if (sscanf(arg, "%31s", bar_expr) != 1) { | |
2037 | errx(1, "bar-position must be of the form [pos] with a max length of 31\n"); | |
2156 | if (sscanf(arg, "%31[^:]:%31[^:]", bar_x_expr, bar_y_expr) < 1) { | |
2157 | errx(1, "bar-position must be a single number or of the form x:y with a max length of 31\n"); | |
2158 | } | |
2159 | break; | |
2160 | case 710: | |
2161 | bar_count = atoi(optarg); | |
2162 | if (bar_count > MAX_BAR_COUNT || bar_count < MIN_BAR_COUNT) { | |
2163 | errx(1, "bar-count must be between %d and %d\n", MIN_BAR_COUNT, MAX_BAR_COUNT); | |
2164 | } | |
2165 | break; | |
2166 | case 711: | |
2167 | arg = optarg; | |
2168 | if (sscanf(arg, "%31s", bar_width_expr) != 1) { | |
2169 | errx(1, "missing argument for bar-total-width\n"); | |
2038 | 2170 | } |
2039 | 2171 | break; |
2040 | 2172 | |
2183 | 2315 | last_resolution[0] = screen->width_in_pixels; |
2184 | 2316 | last_resolution[1] = screen->height_in_pixels; |
2185 | 2317 | |
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)); | |
2318 | if (bar_enabled) { | |
2319 | bar_heights = (double*) calloc(bar_count, sizeof(double)); | |
2193 | 2320 | } |
2194 | 2321 | |
2195 | 2322 | xcb_change_window_attributes(conn, screen->root, XCB_CW_EVENT_MASK, |
2209 | 2336 | |
2210 | 2337 | free(image_raw_format); |
2211 | 2338 | |
2212 | xcb_pixmap_t* blur_pixmap = NULL; | |
2213 | 2339 | if (blur) { |
2214 | blur_pixmap = malloc(sizeof(xcb_pixmap_t)); | |
2215 | xcb_visualtype_t *vistype = get_root_visual_type(screen); | |
2216 | *blur_pixmap = capture_bg_pixmap(conn, screen, last_resolution); | |
2217 | cairo_surface_t *xcb_img = cairo_xcb_surface_create(conn, *blur_pixmap, vistype, last_resolution[0], last_resolution[1]); | |
2218 | ||
2219 | blur_img = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, last_resolution[0], last_resolution[1]); | |
2220 | cairo_t *ctx = cairo_create(blur_img); | |
2340 | xcb_pixmap_t bg_pixmap = capture_bg_pixmap(conn, screen, last_resolution); | |
2341 | cairo_surface_t *xcb_img = cairo_xcb_surface_create(conn, bg_pixmap, get_root_visual_type(screen), last_resolution[0], last_resolution[1]); | |
2342 | ||
2343 | blur_bg_img = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, last_resolution[0], last_resolution[1]); | |
2344 | cairo_t *ctx = cairo_create(blur_bg_img); | |
2345 | ||
2221 | 2346 | cairo_set_source_surface(ctx, xcb_img, 0, 0); |
2222 | 2347 | cairo_paint(ctx); |
2223 | ||
2224 | blur_image_surface(blur_img, blur_sigma); | |
2225 | if (img) { | |
2226 | // Display image centered on all outputs. | |
2227 | draw_image(last_resolution, ctx); | |
2228 | cairo_surface_destroy(img); | |
2229 | img = NULL; | |
2230 | } | |
2348 | blur_image_surface(blur_bg_img, blur_sigma); | |
2349 | ||
2231 | 2350 | cairo_destroy(ctx); |
2232 | 2351 | cairo_surface_destroy(xcb_img); |
2352 | xcb_free_pixmap(conn, bg_pixmap); | |
2233 | 2353 | } |
2234 | 2354 | |
2235 | 2355 | xcb_window_t stolen_focus = find_focused_window(conn, screen->root); |
2240 | 2360 | xcb_pixmap_t pixmap = create_bg_pixmap(conn, win, last_resolution, color); |
2241 | 2361 | render_lock(last_resolution, pixmap); |
2242 | 2362 | xcb_change_window_attributes(conn, win, XCB_CW_BACK_PIXMAP, (uint32_t[]){pixmap}); |
2243 | ||
2244 | 2363 | xcb_free_pixmap(conn, pixmap); |
2245 | if (blur_pixmap) { | |
2246 | xcb_free_pixmap(conn, *blur_pixmap); | |
2247 | free(blur_pixmap); | |
2248 | blur_pixmap = NULL; | |
2249 | } | |
2250 | ||
2251 | 2364 | |
2252 | 2365 | cursor = create_cursor(conn, screen, win, curs_choice); |
2253 | 2366 |
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 |
62 | 62 | # LICENSE |
63 | 63 | # |
64 | 64 | # Copyright (c) 2016 Michael Stapelberg <[email protected]> |
65 | # Copyright (c) 2020 Raymond Li <[email protected]> | |
65 | # Copyright (c) 2021 Raymond Li <[email protected]> | |
66 | 66 | # |
67 | 67 | # Copying and distribution of this file, with or without modification, are |
68 | 68 | # permitted in any medium without royalty provided the copyright notice |
68 | 68 | # LICENSE |
69 | 69 | # |
70 | 70 | # Copyright (c) 2016 Michael Stapelberg <[email protected]> |
71 | # Copyright (c) 2020 Raymond Li <[email protected]> | |
71 | # Copyright (c) 2021 Raymond Li <[email protected]> | |
72 | 72 | # |
73 | 73 | # Copying and distribution of this file, with or without modification, |
74 | 74 | # are permitted in any medium without royalty provided the copyright |
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 |
1 | 1 | * vim:ts=4:sw=4:expandtab |
2 | 2 | * |
3 | 3 | * © 2010 Michael Stapelberg |
4 | * © 2020 Raymond Li | |
4 | * © 2021 Raymond Li | |
5 | 5 | * |
6 | 6 | * See LICENSE for licensing information |
7 | 7 | * |
2 | 2 | * |
3 | 3 | * © 2010 Michael Stapelberg |
4 | 4 | * © 2015 Cassandra Fox |
5 | * © 2020 Raymond Li | |
5 | * © 2021 Raymond Li | |
6 | 6 | * |
7 | 7 | * See LICENSE for licensing information |
8 | 8 | * |
61 | 61 | |
62 | 62 | /* A Cairo surface containing the specified image (-i), if any. */ |
63 | 63 | extern cairo_surface_t *img; |
64 | extern cairo_surface_t *blur_img; | |
65 | 64 | extern cairo_surface_t *img_slideshow[256]; |
65 | extern cairo_surface_t *blur_bg_img; | |
66 | 66 | extern int slideshow_image_count; |
67 | 67 | extern int slideshow_interval; |
68 | 68 | extern bool slideshow_random_selection; |
69 | 69 | |
70 | 70 | unsigned long lastCheck; |
71 | 71 | |
72 | /* Whether the image should be tiled or centered. */ | |
73 | extern bool centered; | |
74 | extern bool tile; | |
72 | /* How the background image should be displayed */ | |
73 | extern background_type_t bg_type; | |
75 | 74 | /* The background color to use (in hex). */ |
76 | 75 | extern char color[9]; |
77 | 76 | /* indicator color options */ |
87 | 86 | extern char layoutcolor[9]; |
88 | 87 | extern char timecolor[9]; |
89 | 88 | extern char datecolor[9]; |
89 | extern char modifcolor[9]; | |
90 | 90 | extern char keyhlcolor[9]; |
91 | 91 | extern char bshlcolor[9]; |
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]; | |
102 | extern char modifoutlinecolor[9]; | |
95 | 103 | |
96 | 104 | extern int screen_number; |
97 | 105 | extern float refresh_rate; |
136 | 144 | extern double layout_size; |
137 | 145 | extern double greeter_size; |
138 | 146 | |
147 | extern double timeoutlinewidth; | |
148 | extern double dateoutlinewidth; | |
149 | extern double verifoutlinewidth; | |
150 | extern double wrongoutlinewidth; | |
151 | extern double modifieroutlinewidth; | |
152 | extern double layoutoutlinewidth; | |
153 | extern double greeteroutlinewidth; | |
154 | ||
139 | 155 | extern char *verif_text; |
140 | 156 | extern char *wrong_text; |
141 | 157 | extern char *noinput_text; |
186 | 202 | rgba_t layout16; |
187 | 203 | rgba_t time16; |
188 | 204 | rgba_t date16; |
205 | rgba_t modif16; | |
189 | 206 | rgba_t keyhl16; |
190 | 207 | rgba_t bshl16; |
191 | 208 | rgba_t sep16; |
192 | 209 | rgba_t bar16; |
193 | 210 | rgba_t greeter16; |
194 | 211 | rgba_t background; |
212 | ||
213 | rgba_t verifoutline16; | |
214 | rgba_t wrongoutline16; | |
215 | rgba_t layoutoutline16; | |
216 | rgba_t timeoutline16; | |
217 | rgba_t dateoutline16; | |
218 | rgba_t greeteroutline16; | |
219 | rgba_t modifoutline16; | |
195 | 220 | |
196 | 221 | // experimental bar stuff |
197 | 222 | |
205 | 230 | extern double bar_periodic_step; |
206 | 231 | extern double max_bar_height; |
207 | 232 | extern double bar_position; |
208 | extern int num_bars; | |
209 | extern int bar_width; | |
233 | extern int bar_count; | |
210 | 234 | extern int bar_orientation; |
211 | 235 | |
212 | 236 | extern char bar_base_color[9]; |
213 | extern char bar_expr[32]; | |
237 | extern char bar_x_expr[32]; | |
238 | extern char bar_y_expr[32]; | |
239 | extern char bar_width_expr[32]; | |
214 | 240 | extern bool bar_bidirectional; |
215 | 241 | extern bool bar_reversed; |
216 | 242 | |
310 | 336 | |
311 | 337 | cairo_set_source_rgba(ctx, text.color.red, text.color.green, text.color.blue, text.color.alpha); |
312 | 338 | cairo_move_to(ctx, x, text.y); |
313 | cairo_show_text(ctx, text.str); | |
314 | ||
339 | ||
340 | cairo_text_path(ctx, text.str); | |
341 | cairo_fill_preserve(ctx); | |
342 | ||
343 | cairo_set_source_rgba(ctx, text.outline_color.red, text.outline_color.green, text.outline_color.blue, text.outline_color.alpha); | |
344 | cairo_set_line_width(ctx, text.outline_width); | |
315 | 345 | cairo_stroke(ctx); |
316 | 346 | } |
317 | 347 | |
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) | |
348 | static void draw_single_bar(cairo_t *ctx, double pos, double offset, double width, double height) { | |
349 | if (bar_reversed) { | |
350 | offset -= height; | |
351 | } else if (bar_bidirectional) { | |
352 | offset -= height / 2; | |
353 | } | |
354 | ||
355 | if (bar_orientation == BAR_VERT) | |
356 | cairo_rectangle(ctx, offset, pos, height, width); | |
357 | else | |
358 | cairo_rectangle(ctx, pos, offset, width, height); | |
359 | cairo_fill(ctx); | |
360 | } | |
361 | ||
362 | static void draw_bar(cairo_t *ctx, double bar_x, double bar_y, double bar_width, double screen_x, double screen_y) { | |
363 | ||
364 | cairo_save(ctx); | |
365 | ||
366 | switch (auth_state) { | |
367 | case STATE_AUTH_VERIFY: | |
368 | case STATE_AUTH_LOCK: | |
369 | cairo_set_source_rgba(ctx, ringver16.red, ringver16.green, ringver16.blue, ringver16.alpha); | |
370 | break; | |
371 | case STATE_AUTH_WRONG: | |
372 | case STATE_I3LOCK_LOCK_FAILED: | |
373 | cairo_set_source_rgba(ctx, ringwrong16.red, ringwrong16.green, ringwrong16.blue, ringwrong16.alpha); | |
374 | break; | |
375 | default: | |
376 | cairo_set_source_rgba(ctx, bar16.red, bar16.green, bar16.blue, bar16.alpha); | |
377 | break; | |
378 | } | |
379 | ||
380 | if (bar_orientation == BAR_VERT) | |
381 | draw_single_bar(ctx, bar_y, bar_x, bar_width, bar_base_height); | |
382 | else | |
383 | draw_single_bar(ctx, bar_x, bar_y, bar_width, bar_base_height); | |
384 | ||
385 | if (unlock_state == STATE_BACKSPACE_ACTIVE) | |
386 | cairo_set_source_rgba(ctx, bshl16.red, bshl16.green, bshl16.blue, bshl16.alpha); | |
387 | else | |
388 | cairo_set_source_rgba(ctx, keyhl16.red, keyhl16.green, keyhl16.blue, keyhl16.alpha); | |
389 | ||
390 | cairo_set_operator(ctx, CAIRO_OPERATOR_SOURCE); | |
391 | ||
392 | double base_width = bar_width / bar_count; | |
393 | double bar_pos, bar_offset; | |
394 | if (bar_orientation == BAR_VERT) { | |
395 | bar_pos = bar_y; | |
396 | bar_offset = bar_x; | |
397 | } else { | |
398 | bar_pos = bar_x; | |
399 | bar_offset = bar_y; | |
400 | } | |
401 | ||
402 | for (int i = 0; i < bar_count; ++i) { | |
403 | double bar_height = bar_heights[i]; | |
404 | if (bar_bidirectional) bar_height *= 2; | |
405 | if (bar_height > 0) { | |
406 | draw_single_bar(ctx, bar_pos + i * base_width, bar_offset, base_width, bar_height); | |
407 | } | |
408 | } | |
409 | ||
410 | for (int i = 0; i < bar_count; ++i) { | |
411 | if (bar_heights[i] > 0) { | |
429 | 412 | bar_heights[i] -= bar_periodic_step; |
430 | } | |
413 | } | |
414 | } | |
415 | ||
416 | cairo_restore(ctx); | |
431 | 417 | } |
432 | 418 | |
433 | 419 | static void draw_indic(cairo_t *ctx, double ind_x, double ind_y) { |
596 | 582 | colorgen(&tmp, layoutcolor, &layout16); |
597 | 583 | colorgen(&tmp, timecolor, &time16); |
598 | 584 | colorgen(&tmp, datecolor, &date16); |
585 | colorgen(&tmp, modifcolor, &modif16); | |
599 | 586 | colorgen(&tmp, keyhlcolor, &keyhl16); |
600 | 587 | colorgen(&tmp, bshlcolor, &bshl16); |
601 | 588 | colorgen(&tmp, separatorcolor, &sep16); |
602 | 589 | colorgen(&tmp, bar_base_color, &bar16); |
603 | 590 | colorgen(&tmp, greetercolor, &greeter16); |
604 | 591 | colorgen(&tmp, color, &background); |
592 | ||
593 | colorgen(&tmp, verifoutlinecolor, &verifoutline16); | |
594 | colorgen(&tmp, wrongoutlinecolor, &wrongoutline16); | |
595 | colorgen(&tmp, layoutoutlinecolor, &layoutoutline16); | |
596 | colorgen(&tmp, timeoutlinecolor, &timeoutline16); | |
597 | colorgen(&tmp, dateoutlinecolor, &dateoutline16); | |
598 | colorgen(&tmp, greeteroutlinecolor, &greeteroutline16); | |
599 | colorgen(&tmp, modifoutlinecolor, &modifoutline16); | |
605 | 600 | } |
606 | 601 | |
607 | 602 | static te_expr *compile_expression(const char *const from, const char *expression, const te_variable *variables, int var_count) { |
629 | 624 | if (unlock_state == STATE_KEY_ACTIVE || |
630 | 625 | unlock_state == STATE_BACKSPACE_ACTIVE) { |
631 | 626 | // 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; | |
627 | // maybe see about doing ((double) rand() / RAND_MAX) * bar_count | |
628 | int index = rand() % bar_count; | |
634 | 629 | bar_heights[index] = max_bar_height; |
635 | 630 | for (int i = 0; i < ((max_bar_height / bar_step) + 1); ++i) { |
636 | 631 | int low_ind = index - i; |
637 | 632 | while (low_ind < 0) { |
638 | low_ind += num_bars; | |
633 | low_ind += bar_count; | |
639 | 634 | } |
640 | int high_ind = (index + i) % num_bars; | |
635 | int high_ind = (index + i) % bar_count; | |
641 | 636 | int tmp_height = max_bar_height - (bar_step * i); |
642 | 637 | if (tmp_height < 0) |
643 | 638 | tmp_height = 0; |
649 | 644 | break; |
650 | 645 | } |
651 | 646 | } |
652 | draw_bar(ctx, draw_data->bar_x, draw_data->bar_y, draw_data->bar_offset); | |
647 | draw_bar(ctx, draw_data->bar_x, draw_data->bar_y, draw_data->bar_width, draw_data->screen_x, draw_data->screen_y); | |
653 | 648 | } |
654 | 649 | |
655 | 650 | draw_text(ctx, draw_data->status_text); |
702 | 697 | } |
703 | 698 | } |
704 | 699 | |
705 | if (blur_img || img) { | |
706 | if (blur_img) { | |
707 | cairo_set_source_surface(xcb_ctx, blur_img, 0, 0); | |
708 | cairo_paint(xcb_ctx); | |
709 | } else { // img can no longer be non-NULL if blur_img is not null | |
710 | draw_image(resolution, xcb_ctx); | |
711 | } | |
700 | if (blur_bg_img) { | |
701 | cairo_set_source_surface(xcb_ctx, blur_bg_img, 0, 0); | |
702 | cairo_paint(xcb_ctx); | |
712 | 703 | } else { |
713 | 704 | cairo_set_source_rgba(xcb_ctx, background.red, background.green, background.blue, background.alpha); |
714 | 705 | cairo_rectangle(xcb_ctx, 0, 0, resolution[0], resolution[1]); |
715 | 706 | cairo_fill(xcb_ctx); |
707 | } | |
708 | ||
709 | if (img) { | |
710 | draw_image(resolution, img, xcb_ctx); | |
716 | 711 | } |
717 | 712 | |
718 | 713 | /* |
732 | 727 | strncpy(draw_data.status_text.str, verif_text, sizeof(draw_data.status_text.str) - 1); |
733 | 728 | draw_data.status_text.font = get_font_face(VERIF_FONT); |
734 | 729 | draw_data.status_text.color = verif16; |
730 | draw_data.status_text.outline_color = verifoutline16; | |
735 | 731 | draw_data.status_text.size = verif_size; |
732 | draw_data.status_text.outline_width = verifoutlinewidth; | |
736 | 733 | draw_data.status_text.align = verif_align; |
737 | 734 | break; |
738 | 735 | case STATE_AUTH_LOCK: |
740 | 737 | strncpy(draw_data.status_text.str, lock_text, sizeof(draw_data.status_text.str) - 1); |
741 | 738 | draw_data.status_text.font = get_font_face(VERIF_FONT); |
742 | 739 | draw_data.status_text.color = verif16; |
740 | draw_data.status_text.outline_color = verifoutline16; | |
743 | 741 | draw_data.status_text.size = verif_size; |
742 | draw_data.status_text.outline_width = verifoutlinewidth; | |
744 | 743 | draw_data.status_text.align = verif_align; |
745 | 744 | break; |
746 | 745 | case STATE_AUTH_WRONG: |
748 | 747 | strncpy(draw_data.status_text.str, wrong_text, sizeof(draw_data.status_text.str) - 1); |
749 | 748 | draw_data.status_text.font = get_font_face(WRONG_FONT); |
750 | 749 | draw_data.status_text.color = wrong16; |
750 | draw_data.status_text.outline_color = wrongoutline16; | |
751 | 751 | draw_data.status_text.size = wrong_size; |
752 | draw_data.status_text.outline_width = wrongoutlinewidth; | |
752 | 753 | draw_data.status_text.align = wrong_align; |
753 | 754 | break; |
754 | 755 | case STATE_I3LOCK_LOCK_FAILED: |
756 | 757 | strncpy(draw_data.status_text.str, lock_failed_text, sizeof(draw_data.status_text.str) - 1); |
757 | 758 | draw_data.status_text.font = get_font_face(WRONG_FONT); |
758 | 759 | draw_data.status_text.color = wrong16; |
760 | draw_data.status_text.outline_color = wrongoutline16; | |
759 | 761 | draw_data.status_text.size = wrong_size; |
762 | draw_data.status_text.outline_width = wrongoutlinewidth; | |
760 | 763 | draw_data.status_text.align = wrong_align; |
761 | 764 | break; |
762 | 765 | default: |
765 | 768 | strncpy(draw_data.status_text.str, noinput_text, sizeof(draw_data.status_text.str) - 1); |
766 | 769 | draw_data.status_text.font = get_font_face(WRONG_FONT); |
767 | 770 | draw_data.status_text.color = wrong16; |
771 | draw_data.status_text.outline_color = wrongoutline16; | |
768 | 772 | draw_data.status_text.size = wrong_size; |
773 | draw_data.status_text.outline_width = wrongoutlinewidth; | |
769 | 774 | draw_data.status_text.align = wrong_align; |
770 | 775 | break; |
771 | 776 | } |
773 | 778 | draw_data.status_text.show = true; |
774 | 779 | draw_data.status_text.font = get_font_face(WRONG_FONT); |
775 | 780 | draw_data.status_text.color = wrong16; |
781 | draw_data.status_text.outline_color = wrongoutline16; | |
776 | 782 | draw_data.status_text.size = wrong_size; |
783 | draw_data.status_text.outline_width = wrongoutlinewidth; | |
777 | 784 | draw_data.status_text.align = wrong_align; |
778 | 785 | // TODO: variable for this |
779 | 786 | draw_data.status_text.size = 32.0; |
791 | 798 | draw_data.mod_text.show = true; |
792 | 799 | strncpy(draw_data.mod_text.str, modifier_string, sizeof(draw_data.mod_text.str) - 1); |
793 | 800 | draw_data.mod_text.size = modifier_size; |
801 | draw_data.mod_text.outline_width = modifieroutlinewidth; | |
794 | 802 | draw_data.mod_text.font = get_font_face(WRONG_FONT); |
795 | 803 | draw_data.mod_text.align = modif_align; |
796 | draw_data.mod_text.color = wrong16; | |
804 | draw_data.mod_text.color = modif16; | |
805 | draw_data.mod_text.outline_color = modifoutline16; | |
797 | 806 | } |
798 | 807 | |
799 | 808 | if (layout_text) { |
800 | 809 | draw_data.keylayout_text.show = true; |
801 | 810 | strncpy(draw_data.keylayout_text.str, layout_text, sizeof(draw_data.keylayout_text.str) - 1); |
802 | 811 | draw_data.keylayout_text.size = layout_size; |
812 | draw_data.keylayout_text.outline_width = layoutoutlinewidth; | |
803 | 813 | draw_data.keylayout_text.font = get_font_face(LAYOUT_FONT); |
804 | 814 | draw_data.keylayout_text.color = layout16; |
815 | draw_data.keylayout_text.outline_color = layoutoutline16; | |
805 | 816 | draw_data.keylayout_text.align = layout_align; |
806 | 817 | } |
807 | 818 | |
809 | 820 | draw_data.greeter_text.show = true; |
810 | 821 | strncpy(draw_data.greeter_text.str, greeter_text, sizeof(draw_data.greeter_text.str) - 1); |
811 | 822 | draw_data.greeter_text.size = greeter_size; |
823 | draw_data.greeter_text.outline_width = greeteroutlinewidth; | |
812 | 824 | draw_data.greeter_text.font = get_font_face(GREETER_FONT); |
813 | 825 | draw_data.greeter_text.color = greeter16; |
826 | draw_data.greeter_text.outline_color = greeteroutline16; | |
814 | 827 | draw_data.greeter_text.align = greeter_align; |
815 | 828 | } |
816 | 829 | |
824 | 837 | if (*draw_data.time_text.str) { |
825 | 838 | draw_data.time_text.show = true; |
826 | 839 | draw_data.time_text.size = time_size; |
840 | draw_data.time_text.outline_width = timeoutlinewidth; | |
827 | 841 | draw_data.time_text.color = time16; |
842 | draw_data.time_text.outline_color = timeoutline16; | |
828 | 843 | draw_data.time_text.font = get_font_face(TIME_FONT); |
829 | 844 | draw_data.time_text.align = time_align; |
830 | 845 | } |
832 | 847 | if (*draw_data.date_text.str) { |
833 | 848 | draw_data.date_text.show = true; |
834 | 849 | draw_data.date_text.size = date_size; |
850 | draw_data.date_text.outline_width = dateoutlinewidth; | |
835 | 851 | draw_data.date_text.color = date16; |
852 | draw_data.date_text.outline_color = dateoutline16; | |
836 | 853 | draw_data.date_text.font = get_font_face(DATE_FONT); |
837 | 854 | draw_data.date_text.align = date_align; |
838 | 855 | } |
840 | 857 | if (*draw_data.greeter_text.str) { |
841 | 858 | draw_data.greeter_text.show = true; |
842 | 859 | draw_data.greeter_text.size = greeter_size; |
860 | draw_data.greeter_text.outline_width = greeteroutlinewidth; | |
843 | 861 | draw_data.greeter_text.color = greeter16; |
862 | draw_data.greeter_text.outline_color = greeteroutline16; | |
844 | 863 | draw_data.greeter_text.font = get_font_face(GREETER_FONT); |
845 | 864 | draw_data.greeter_text.align = greeter_align; |
846 | 865 | } |
855 | 874 | scaling_factor, button_diameter_physical); |
856 | 875 | |
857 | 876 | // variable mapping for evaluating the clock position expression |
858 | const unsigned int vars_size = 11; | |
877 | const unsigned int vars_size = 14; | |
859 | 878 | te_variable vars[] = |
860 | 879 | {{"w", &width}, |
861 | 880 | {"h", &height}, |
867 | 886 | {"ty", &draw_data.time_text.y}, |
868 | 887 | {"dx", &draw_data.date_text.x}, |
869 | 888 | {"dy", &draw_data.date_text.y}, |
889 | {"bw", &draw_data.bar_width}, | |
890 | {"bx", &draw_data.bar_x}, | |
891 | {"by", &draw_data.bar_y}, | |
870 | 892 | {"r", &radius}}; |
871 | 893 | |
872 | 894 | te_expr *te_ind_x_expr = compile_expression("--indpos", ind_x_expr, vars, vars_size); |
885 | 907 | te_expr *te_wrong_y_expr = compile_expression("--wrongpos", wrong_y_expr, vars, vars_size); |
886 | 908 | te_expr *te_modif_x_expr = compile_expression("--modifpos", modif_x_expr, vars, vars_size); |
887 | 909 | te_expr *te_modif_y_expr = compile_expression("--modifpos", modif_y_expr, vars, vars_size); |
888 | te_expr *te_bar_expr = compile_expression("--bar-position", bar_expr, vars, vars_size); | |
910 | te_expr *te_bar_x_expr = compile_expression("--bar-position", bar_x_expr, vars, vars_size); | |
911 | te_expr *te_bar_y_expr = strlen(bar_y_expr) ? compile_expression("--bar-position", bar_y_expr, vars, vars_size) : NULL; | |
912 | te_expr *te_bar_width_expr = strlen(bar_width_expr) ? compile_expression("--bar-width", bar_width_expr, vars, vars_size) : NULL; | |
889 | 913 | |
890 | 914 | te_expr *te_greeter_x_expr = compile_expression("--greeterpos", greeter_x_expr, vars, vars_size); |
891 | 915 | te_expr *te_greeter_y_expr = compile_expression("--greeterpos", greeter_y_expr, vars, vars_size); |
913 | 937 | height = xr_resolutions[current_screen].height / scaling_factor; |
914 | 938 | screen_x = xr_resolutions[current_screen].x / scaling_factor; |
915 | 939 | screen_y = xr_resolutions[current_screen].y / scaling_factor; |
916 | if (te_ind_x_expr && te_ind_y_expr) { | |
917 | draw_data.indicator_x = te_eval(te_ind_x_expr); | |
918 | draw_data.indicator_y = te_eval(te_ind_y_expr); | |
919 | } else { | |
920 | draw_data.indicator_x = screen_x + width / 2; | |
921 | draw_data.indicator_y = screen_y + height / 2; | |
922 | } | |
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 | draw_data.bar_offset = te_eval(te_bar_expr); | |
940 | draw_data.screen_x = screen_x; | |
941 | draw_data.screen_y = screen_y; | |
942 | draw_data.indicator_x = te_eval(te_ind_x_expr); | |
943 | draw_data.indicator_y = te_eval(te_ind_y_expr); | |
926 | 944 | draw_data.time_text.x = te_eval(te_time_x_expr); |
927 | 945 | draw_data.time_text.y = te_eval(te_time_y_expr); |
928 | 946 | draw_data.date_text.x = te_eval(te_date_x_expr); |
952 | 970 | draw_data.mod_text.x = te_eval(te_modif_x_expr); |
953 | 971 | draw_data.mod_text.y = te_eval(te_modif_y_expr); |
954 | 972 | |
973 | if (te_bar_y_expr) { | |
974 | draw_data.bar_x = te_eval(te_bar_x_expr); | |
975 | draw_data.bar_y = te_eval(te_bar_y_expr); | |
976 | } else { | |
977 | double bar_offset = te_eval(te_bar_x_expr); | |
978 | if (bar_orientation == BAR_VERT) { | |
979 | draw_data.bar_x = bar_offset; | |
980 | draw_data.bar_y = screen_y; | |
981 | } else { | |
982 | draw_data.bar_x = screen_x; | |
983 | draw_data.bar_y = bar_offset; | |
984 | } | |
985 | } | |
986 | if (te_bar_width_expr) | |
987 | draw_data.bar_width = te_eval(te_bar_width_expr); | |
988 | else if (bar_orientation == BAR_VERT) | |
989 | draw_data.bar_width = height; | |
990 | else | |
991 | draw_data.bar_width = width; | |
992 | ||
993 | ||
955 | 994 | 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); | |
995 | DEBUG("Bar at %fx%f with width %f on screen %d\n", draw_data.bar_x, draw_data.bar_y, draw_data.bar_width, current_screen + 1); | |
957 | 996 | DEBUG("Time at %fx%f on screen %d\n", draw_data.time_text.x, draw_data.time_text.y, current_screen + 1); |
958 | 997 | DEBUG("Date at %fx%f on screen %d\n", draw_data.date_text.x, draw_data.date_text.y, current_screen + 1); |
959 | 998 | DEBUG("Layout at %fx%f on screen %d\n", draw_data.keylayout_text.x, draw_data.keylayout_text.y, current_screen + 1); |
968 | 1007 | * hope for the best. */ |
969 | 1008 | width = last_resolution[0] / scaling_factor; |
970 | 1009 | height = last_resolution[1] / scaling_factor; |
1010 | draw_data.screen_x = 0; | |
1011 | draw_data.screen_y = 0; | |
971 | 1012 | draw_data.indicator_x = width / 2; |
972 | 1013 | 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 | 1014 | |
976 | 1015 | draw_data.time_text.x = te_eval(te_time_x_expr); |
977 | 1016 | draw_data.time_text.y = te_eval(te_time_y_expr); |
1000 | 1039 | draw_data.mod_text.x = te_eval(te_modif_x_expr); |
1001 | 1040 | draw_data.mod_text.y = te_eval(te_modif_y_expr); |
1002 | 1041 | |
1042 | if (te_bar_y_expr) { | |
1043 | draw_data.bar_x = te_eval(te_bar_x_expr); | |
1044 | draw_data.bar_y = te_eval(te_bar_y_expr); | |
1045 | } else { | |
1046 | double bar_offset = te_eval(te_bar_x_expr); | |
1047 | if (bar_orientation == BAR_VERT) { | |
1048 | draw_data.bar_x = bar_offset; | |
1049 | draw_data.bar_y = screen_y; | |
1050 | } else { | |
1051 | draw_data.bar_x = screen_x; | |
1052 | draw_data.bar_y = bar_offset; | |
1053 | } | |
1054 | } | |
1055 | if (te_bar_width_expr) | |
1056 | draw_data.bar_width = te_eval(te_bar_width_expr); | |
1057 | else if (bar_orientation == BAR_VERT) | |
1058 | draw_data.bar_width = height; | |
1059 | else | |
1060 | draw_data.bar_width = width; | |
1061 | ||
1003 | 1062 | 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); | |
1063 | DEBUG("Bar at %fx%f with width %f\n", draw_data.bar_x, draw_data.bar_y, draw_data.bar_width); | |
1005 | 1064 | DEBUG("Time at %fx%f\n", draw_data.time_text.x, draw_data.time_text.y); |
1006 | 1065 | DEBUG("Date at %fx%f\n", draw_data.date_text.x, draw_data.date_text.y); |
1007 | 1066 | DEBUG("Layout at %fx%f\n", draw_data.keylayout_text.x, draw_data.keylayout_text.y); |
1027 | 1086 | te_free(te_wrong_y_expr); |
1028 | 1087 | te_free(te_modif_x_expr); |
1029 | 1088 | te_free(te_modif_y_expr); |
1030 | te_free(te_bar_expr); | |
1089 | te_free(te_bar_x_expr); | |
1090 | te_free(te_bar_y_expr); | |
1091 | te_free(te_bar_width_expr); | |
1031 | 1092 | te_free(te_greeter_x_expr); |
1032 | 1093 | te_free(te_greeter_y_expr); |
1033 | 1094 | |
1043 | 1104 | |
1044 | 1105 | /** |
1045 | 1106 | * Draws the configured image on the provided context. The image is drawn centered on all monitors, tiled, or just |
1046 | * painted starting from 0,0. | |
1107 | * painted starting from 0,0. It is also scaled if bg_type is FILL, MAX, or SCALE. | |
1047 | 1108 | */ |
1048 | void draw_image(uint32_t* resolution, cairo_t* xcb_ctx) { | |
1049 | if (centered) { | |
1050 | double image_width = cairo_image_surface_get_width(img); | |
1051 | double image_height = cairo_image_surface_get_height(img); | |
1052 | ||
1053 | xcb_randr_get_screen_resources_current_reply_t *reply = xcb_randr_get_screen_resources_current_reply( | |
1054 | conn, xcb_randr_get_screen_resources_current(conn, screen->root), NULL); | |
1055 | ||
1056 | xcb_timestamp_t timestamp = reply->config_timestamp; | |
1057 | int len = xcb_randr_get_screen_resources_current_outputs_length(reply); | |
1058 | xcb_randr_output_t *randr_outputs = xcb_randr_get_screen_resources_current_outputs(reply); | |
1059 | ||
1060 | // For every output | |
1061 | for (int i = 0; i < len; i++) { | |
1062 | xcb_randr_get_output_info_reply_t *output = xcb_randr_get_output_info_reply( | |
1063 | conn, xcb_randr_get_output_info(conn, randr_outputs[i], timestamp), NULL); | |
1064 | if (output == NULL) | |
1065 | continue; | |
1066 | ||
1067 | if (output->crtc == XCB_NONE || output->connection == XCB_RANDR_CONNECTION_DISCONNECTED) | |
1068 | continue; | |
1069 | ||
1070 | xcb_randr_get_crtc_info_cookie_t infoCookie = xcb_randr_get_crtc_info(conn, output->crtc, | |
1071 | timestamp); | |
1072 | xcb_randr_get_crtc_info_reply_t *crtc = xcb_randr_get_crtc_info_reply(conn, infoCookie, NULL); | |
1073 | ||
1074 | // Paint around center of monitor | |
1075 | double origin_x = crtc->x + (crtc->width / 2.0 - image_width / 2.0); | |
1076 | double origin_y = crtc->y + (crtc->height / 2.0 - image_height / 2.0); | |
1077 | ||
1078 | cairo_set_source_surface(xcb_ctx, img, origin_x, origin_y); | |
1079 | cairo_paint(xcb_ctx); | |
1080 | ||
1081 | free(crtc); | |
1082 | free(output); | |
1083 | } | |
1084 | } else if (tile) { | |
1085 | /* create a pattern and fill a rectangle as big as the screen */ | |
1086 | cairo_pattern_t *pattern; | |
1087 | pattern = cairo_pattern_create_for_surface(img); | |
1088 | cairo_set_source(xcb_ctx, pattern); | |
1089 | cairo_pattern_set_extend(pattern, CAIRO_EXTEND_REPEAT); | |
1090 | cairo_rectangle(xcb_ctx, 0, 0, resolution[0], resolution[1]); | |
1091 | cairo_fill(xcb_ctx); | |
1092 | cairo_pattern_destroy(pattern); | |
1093 | } else { | |
1109 | void draw_image(uint32_t* root_resolution, cairo_surface_t *img, cairo_t* xcb_ctx) { | |
1110 | ||
1111 | if (bg_type == NONE) { | |
1112 | // Don't do any image manipulation | |
1094 | 1113 | cairo_set_source_surface(xcb_ctx, img, 0, 0); |
1095 | 1114 | cairo_paint(xcb_ctx); |
1096 | } | |
1097 | ||
1115 | return; | |
1116 | } | |
1117 | ||
1118 | cairo_pattern_t *pattern = cairo_pattern_create_for_surface(img); | |
1119 | cairo_pattern_set_extend(pattern, bg_type == TILE ? CAIRO_EXTEND_REPEAT : CAIRO_EXTEND_NONE); | |
1120 | cairo_set_source(xcb_ctx, pattern); | |
1121 | ||
1122 | double image_width = cairo_image_surface_get_width(img); | |
1123 | double image_height = cairo_image_surface_get_height(img); | |
1124 | ||
1125 | for (int i = 0; i < xr_screens; i++) { | |
1126 | // Find out scaling factors using bg_type and aspect ratios | |
1127 | double scale_x = 1, scale_y = 1; | |
1128 | if (bg_type == SCALE) { | |
1129 | scale_x = xr_resolutions[i].width / image_width; | |
1130 | scale_y = xr_resolutions[i].height / image_height; | |
1131 | ||
1132 | } else if (bg_type == MAX || bg_type == FILL) { | |
1133 | double aspect_diff = (double) xr_resolutions[i].height / xr_resolutions[i].width - image_height / image_width; | |
1134 | if((bg_type == MAX && aspect_diff > 0) || (bg_type == FILL && aspect_diff < 0)) { | |
1135 | scale_x = scale_y = xr_resolutions[i].width / image_width; | |
1136 | } else if ((bg_type == MAX && aspect_diff < 0) || (bg_type == FILL && aspect_diff > 0)) { | |
1137 | scale_x = scale_y = xr_resolutions[i].height / image_height; | |
1138 | } | |
1139 | } | |
1140 | ||
1141 | // Scale and translate the pattern | |
1142 | cairo_matrix_t matrix; | |
1143 | cairo_matrix_init_scale(&matrix, 1/scale_x, 1/scale_y); | |
1144 | ||
1145 | if (bg_type == TILE) { | |
1146 | // Start image from top-left corner | |
1147 | cairo_matrix_translate(&matrix, -xr_resolutions[i].x, -xr_resolutions[i].y); | |
1148 | } else { | |
1149 | // Draw image in the center of the screen | |
1150 | cairo_matrix_translate(&matrix, | |
1151 | (image_width * scale_x - xr_resolutions[i].width ) / 2 - xr_resolutions[i].x, | |
1152 | (image_height * scale_y - xr_resolutions[i].height) / 2 - xr_resolutions[i].y); | |
1153 | } | |
1154 | ||
1155 | cairo_pattern_set_matrix(pattern, &matrix); | |
1156 | ||
1157 | // Draw to screen | |
1158 | cairo_rectangle(xcb_ctx, xr_resolutions[i].x, xr_resolutions[i].y, xr_resolutions[i].width, xr_resolutions[i].height); | |
1159 | cairo_fill(xcb_ctx); | |
1160 | } | |
1161 | ||
1162 | cairo_pattern_destroy(pattern); | |
1098 | 1163 | } |
1099 | 1164 | |
1100 | 1165 | /* |
33 | 33 | |
34 | 34 | double indicator_x, indicator_y; |
35 | 35 | |
36 | double bar_x, bar_y; | |
37 | double bar_offset; | |
36 | double screen_x, screen_y; | |
37 | double bar_x, bar_y, bar_width; | |
38 | 38 | } DrawData; |
39 | 39 | |
40 | typedef enum { | |
41 | NONE, | |
42 | TILE, | |
43 | CENTER, | |
44 | FILL, | |
45 | SCALE, | |
46 | MAX, | |
47 | } background_type_t; | |
48 | ||
40 | 49 | void render_lock(uint32_t* resolution, xcb_drawable_t drawable); |
41 | void draw_image(uint32_t* resolution, cairo_t* xcb_ctx); | |
50 | void draw_image(uint32_t* resolution, cairo_surface_t* img, cairo_t* xcb_ctx); | |
42 | 51 | void init_colors_once(void); |
43 | 52 | void redraw_screen(void); |
44 | 53 | void clear_indicator(void); |