Compare commits
2 Commits
c2c093595a
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
7603975062
|
|||
|
833706f5a5
|
@@ -20,4 +20,4 @@ Please describe the tests that you ran to verify your changes.
|
|||||||
- [ ] I have made corresponding changes to the documentation
|
- [ ] I have made corresponding changes to the documentation
|
||||||
- [ ] My changes generate no new warnings
|
- [ ] My changes generate no new warnings
|
||||||
- [ ] I have added tests that prove my fix is effective or that my feature works
|
- [ ] I have added tests that prove my fix is effective or that my feature works
|
||||||
- [ ] New and existing unit tests pass locally with my changes
|
- [ ] New and existing unit tests pass locally with my changes
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ updates:
|
|||||||
prefix: "deps"
|
prefix: "deps"
|
||||||
reviewers:
|
reviewers:
|
||||||
- "JorySeverijnse"
|
- "JorySeverijnse"
|
||||||
versioning-strategy: "increase"
|
versioning-strategy: "auto"
|
||||||
groups:
|
groups:
|
||||||
rust-dependencies:
|
rust-dependencies:
|
||||||
patterns:
|
patterns:
|
||||||
|
|||||||
@@ -14,10 +14,16 @@ jobs:
|
|||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v7
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- uses: ./.github/actions/deps
|
||||||
|
|
||||||
|
- uses: Swatinem/rust-cache@v2
|
||||||
|
|
||||||
|
- uses: dtolnay/rust-toolchain@stable
|
||||||
|
|
||||||
- name: Set version
|
- name: Set version
|
||||||
id: version
|
id: version
|
||||||
run: |
|
run: |
|
||||||
@@ -26,10 +32,19 @@ jobs:
|
|||||||
VERSION=$(grep -m1 '^version =' Cargo.toml | cut -d'"' -f2)
|
VERSION=$(grep -m1 '^version =' Cargo.toml | cut -d'"' -f2)
|
||||||
echo "VERSION=${VERSION}-nightly.$DATE.$SHA" >> $GITHUB_OUTPUT
|
echo "VERSION=${VERSION}-nightly.$DATE.$SHA" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Build release binary
|
||||||
|
run: cargo build --release
|
||||||
|
|
||||||
|
- name: Upload binary
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: rustlock-${{ steps.version.outputs.VERSION }}
|
||||||
|
path: target/release/rustlock
|
||||||
|
|
||||||
- name: Create nightly release
|
- name: Create nightly release
|
||||||
uses: softprops/action-gh-release@v3
|
uses: softprops/action-gh-release@v3
|
||||||
with:
|
with:
|
||||||
tag_name: nightly-${{ steps.version.outputs.VERSION }}
|
tag_name: ${{ steps.version.outputs.VERSION }}
|
||||||
name: Nightly Build ${{ steps.version.outputs.VERSION }}
|
name: Nightly Build ${{ steps.version.outputs.VERSION }}
|
||||||
prerelease: true
|
prerelease: true
|
||||||
generate_release_notes: true
|
generate_release_notes: true
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ jobs:
|
|||||||
quality-checks:
|
quality-checks:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v7
|
||||||
|
|
||||||
- uses: ./.github/actions/deps
|
- uses: ./.github/actions/deps
|
||||||
|
|
||||||
@@ -31,9 +31,6 @@ jobs:
|
|||||||
- name: Run clippy
|
- name: Run clippy
|
||||||
run: cargo clippy --all-targets -- -D warnings
|
run: cargo clippy --all-targets -- -D warnings
|
||||||
|
|
||||||
- name: Run unit tests (default features)
|
|
||||||
run: cargo test --quiet
|
|
||||||
|
|
||||||
- name: Run unit tests (all features)
|
- name: Run unit tests (all features)
|
||||||
run: cargo test --all-features --quiet
|
run: cargo test --all-features --quiet
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ jobs:
|
|||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v7
|
||||||
|
|
||||||
- name: Determine tag
|
- name: Determine tag
|
||||||
id: tag
|
id: tag
|
||||||
@@ -29,13 +29,21 @@ jobs:
|
|||||||
publish-crates:
|
publish-crates:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [release]
|
needs: [release]
|
||||||
if: secrets.CARGO_REGISTRY_TOKEN != ''
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v7
|
||||||
|
|
||||||
|
- uses: ./.github/actions/deps
|
||||||
|
|
||||||
|
- uses: Swatinem/rust-cache@v2
|
||||||
|
|
||||||
- uses: dtolnay/rust-toolchain@stable
|
- uses: dtolnay/rust-toolchain@stable
|
||||||
|
|
||||||
- name: Publish to crates.io
|
- name: Publish to crates.io
|
||||||
env:
|
env:
|
||||||
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
|
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
|
||||||
run: cargo publish
|
run: |
|
||||||
|
if [ -z "$CARGO_REGISTRY_TOKEN" ]; then
|
||||||
|
echo "CARGO_REGISTRY_TOKEN not set — skipping publish"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
cargo publish
|
||||||
|
|||||||
@@ -11,6 +11,14 @@ on:
|
|||||||
- 'Cargo.lock'
|
- 'Cargo.lock'
|
||||||
- 'deny.toml'
|
- 'deny.toml'
|
||||||
- '.github/workflows/security.yml'
|
- '.github/workflows/security.yml'
|
||||||
|
pull_request:
|
||||||
|
branches: [main, master]
|
||||||
|
paths:
|
||||||
|
- 'Cargo.toml'
|
||||||
|
- 'Cargo.lock'
|
||||||
|
- 'deny.toml'
|
||||||
|
- '.github/workflows/security.yml'
|
||||||
|
types: [opened, synchronize, reopened]
|
||||||
|
|
||||||
env:
|
env:
|
||||||
CARGO_TERM_COLOR: always
|
CARGO_TERM_COLOR: always
|
||||||
@@ -19,7 +27,7 @@ jobs:
|
|||||||
security-audit:
|
security-audit:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v7
|
||||||
|
|
||||||
- name: Install Rust
|
- name: Install Rust
|
||||||
uses: dtolnay/rust-toolchain@stable
|
uses: dtolnay/rust-toolchain@stable
|
||||||
@@ -39,4 +47,3 @@ jobs:
|
|||||||
|
|
||||||
- name: Check for outdated dependencies
|
- name: Check for outdated dependencies
|
||||||
run: cargo outdated --exit-code 1 || echo "Some dependencies are outdated"
|
run: cargo outdated --exit-code 1 || echo "Some dependencies are outdated"
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
repos:
|
||||||
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
|
rev: v5.0.0
|
||||||
|
hooks:
|
||||||
|
- id: trailing-whitespace
|
||||||
|
exclude: \.md$
|
||||||
|
- id: end-of-file-fixer
|
||||||
|
- id: check-yaml
|
||||||
|
- id: check-toml
|
||||||
|
- id: check-added-large-files
|
||||||
|
exclude: ^assets/
|
||||||
|
- id: check-merge-conflict
|
||||||
|
|
||||||
|
- repo: local
|
||||||
|
hooks:
|
||||||
|
- id: fmt
|
||||||
|
name: cargo fmt
|
||||||
|
entry: cargo fmt
|
||||||
|
args: ["--", "--check"]
|
||||||
|
language: system
|
||||||
|
types: [rust]
|
||||||
|
pass_filenames: false
|
||||||
|
- id: clippy
|
||||||
|
name: cargo clippy
|
||||||
|
entry: cargo clippy
|
||||||
|
args: ["--", "-D", "warnings"]
|
||||||
|
language: system
|
||||||
|
pass_filenames: false
|
||||||
@@ -16,6 +16,7 @@ cairo-rs = { version = "0.20", default-features = false, features = ["png"] }
|
|||||||
gdk-pixbuf = { version = "0.20", default-features = false, features = ["v2_40"] }
|
gdk-pixbuf = { version = "0.20", default-features = false, features = ["v2_40"] }
|
||||||
pangocairo = { version = "0.20" }
|
pangocairo = { version = "0.20" }
|
||||||
clap = { version = "4.6", default-features = false, features = ["derive", "std", "help", "usage", "error-context"] }
|
clap = { version = "4.6", default-features = false, features = ["derive", "std", "help", "usage", "error-context"] }
|
||||||
|
clap_complete = { version = "4.6", default-features = false }
|
||||||
toml = { version = "1.1", default-features = false, features = ["parse", "display", "serde"] }
|
toml = { version = "1.1", default-features = false, features = ["parse", "display", "serde"] }
|
||||||
serde = { version = "1.0", default-features = false, features = ["derive", "std"] }
|
serde = { version = "1.0", default-features = false, features = ["derive", "std"] }
|
||||||
zeroize = "1.8"
|
zeroize = "1.8"
|
||||||
@@ -25,11 +26,9 @@ whoami = "1.6"
|
|||||||
zbus = { version = "5.14", default-features = false, features = ["tokio"] }
|
zbus = { version = "5.14", default-features = false, features = ["tokio"] }
|
||||||
mpris = "2.0"
|
mpris = "2.0"
|
||||||
tokio = { version = "1.51", default-features = false, features = ["rt", "rt-multi-thread", "macros", "time", "sync"] }
|
tokio = { version = "1.51", default-features = false, features = ["rt", "rt-multi-thread", "macros", "time", "sync"] }
|
||||||
rand = { version = "0.10" }
|
|
||||||
reqwest = { version = "0.12", default-features = false, features = ["blocking", "rustls-tls"], optional = true }
|
reqwest = { version = "0.12", default-features = false, features = ["blocking", "rustls-tls"], optional = true }
|
||||||
image = { version = "0.25", default-features = false, features = ["png", "jpeg"] }
|
image = { version = "0.25", default-features = false, features = ["png", "jpeg"] }
|
||||||
fastblur = "0.1"
|
pam-client = "0.5"
|
||||||
pam-client = "0.5"
|
|
||||||
calloop = "0.13"
|
calloop = "0.13"
|
||||||
xkbcommon = "0.7"
|
xkbcommon = "0.7"
|
||||||
calloop-wayland-source = "0.3"
|
calloop-wayland-source = "0.3"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
GNU GENERAL PUBLIC LICENSE
|
GNU GENERAL PUBLIC LICENSE
|
||||||
Version 3, 29 June 2007
|
Version 3, 29 June 2007
|
||||||
Copyright © 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
Copyright © 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ To “convey” a work means any kind of propagation that enables other parties
|
|||||||
|
|
||||||
An interactive user interface displays “Appropriate Legal Notices” to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.
|
An interactive user interface displays “Appropriate Legal Notices” to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
1. Source Code.
|
1. Source Code.
|
||||||
The “source code” for a work means the preferred form of the work for making modifications to it. “Object code” means any non-source form of a work.
|
The “source code” for a work means the preferred form of the work for making modifications to it. “Object code” means any non-source form of a work.
|
||||||
|
|
||||||
A “Standard Interface” means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.
|
A “Standard Interface” means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.
|
||||||
@@ -59,24 +59,24 @@ The Corresponding Source need not include anything that users can regenerate aut
|
|||||||
|
|
||||||
The Corresponding Source for a work in source code form is that same work.
|
The Corresponding Source for a work in source code form is that same work.
|
||||||
|
|
||||||
2. Basic Permissions.
|
2. Basic Permissions.
|
||||||
All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.
|
All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.
|
You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
|
Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
|
||||||
|
|
||||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.
|
No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.
|
||||||
|
|
||||||
When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures.
|
When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures.
|
||||||
|
|
||||||
4. Conveying Verbatim Copies.
|
4. Conveying Verbatim Copies.
|
||||||
You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.
|
You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.
|
You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
5. Conveying Modified Source Versions.
|
5. Conveying Modified Source Versions.
|
||||||
You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:
|
You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
a) The work must carry prominent notices stating that you modified it, and giving a relevant date.
|
a) The work must carry prominent notices stating that you modified it, and giving a relevant date.
|
||||||
@@ -89,7 +89,7 @@ d) If the work has interactive user interfaces, each must display Appropriate Le
|
|||||||
|
|
||||||
A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an “aggregate” if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.
|
A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an “aggregate” if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.
|
||||||
|
|
||||||
6. Conveying Non-Source Forms.
|
6. Conveying Non-Source Forms.
|
||||||
You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:
|
You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:
|
||||||
|
|
||||||
a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.
|
a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.
|
||||||
@@ -114,7 +114,7 @@ The requirement to provide Installation Information does not include a requireme
|
|||||||
|
|
||||||
Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.
|
Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.
|
||||||
|
|
||||||
7. Additional Terms.
|
7. Additional Terms.
|
||||||
“Additional permissions” are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.
|
“Additional permissions” are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.
|
||||||
|
|
||||||
When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.
|
When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.
|
||||||
@@ -139,7 +139,7 @@ If you add terms to a covered work in accord with this section, you must place,
|
|||||||
|
|
||||||
Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.
|
Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.
|
||||||
|
|
||||||
8. Termination.
|
8. Termination.
|
||||||
You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11).
|
You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11).
|
||||||
|
|
||||||
However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.
|
However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.
|
||||||
@@ -148,17 +148,17 @@ Moreover, your license from a particular copyright holder is reinstated permanen
|
|||||||
|
|
||||||
Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.
|
Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.
|
||||||
|
|
||||||
9. Acceptance Not Required for Having Copies.
|
9. Acceptance Not Required for Having Copies.
|
||||||
You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.
|
You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
10. Automatic Licensing of Downstream Recipients.
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.
|
Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
An “entity transaction” is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.
|
An “entity transaction” is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.
|
You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
11. Patents.
|
11. Patents.
|
||||||
A “contributor” is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's “contributor version”.
|
A “contributor” is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's “contributor version”.
|
||||||
|
|
||||||
A contributor's “essential patent claims” are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, “control” includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.
|
A contributor's “essential patent claims” are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, “control” includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.
|
||||||
@@ -175,13 +175,13 @@ A patent license is “discriminatory” if it does not include within the scope
|
|||||||
|
|
||||||
Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.
|
Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
12. No Surrender of Others' Freedom.
|
12. No Surrender of Others' Freedom.
|
||||||
If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.
|
If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
13. Use with the GNU Affero General Public License.
|
13. Use with the GNU Affero General Public License.
|
||||||
Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such.
|
Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such.
|
||||||
|
|
||||||
14. Revised Versions of this License.
|
14. Revised Versions of this License.
|
||||||
The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
|
The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
|
||||||
|
|
||||||
Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation.
|
Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation.
|
||||||
@@ -190,13 +190,13 @@ If the Program specifies that a proxy can decide which future versions of the GN
|
|||||||
|
|
||||||
Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.
|
Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.
|
||||||
|
|
||||||
15. Disclaimer of Warranty.
|
15. Disclaimer of Warranty.
|
||||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
16. Limitation of Liability.
|
16. Limitation of Liability.
|
||||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||||
|
|
||||||
17. Interpretation of Sections 15 and 16.
|
17. Interpretation of Sections 15 and 16.
|
||||||
If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.
|
If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
END OF TERMS AND CONDITIONS
|
||||||
@@ -207,7 +207,7 @@ If you develop a new program, and you want it to be of the greatest possible use
|
|||||||
|
|
||||||
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found.
|
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
<one line to give the program's name and a brief idea of what it does.>
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
Copyright (C) <year> <name of author>
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
@@ -220,8 +220,8 @@ Also add information on how to contact you by electronic and paper mail.
|
|||||||
|
|
||||||
If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode:
|
If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
<program> Copyright (C) <year> <name of author>
|
<program> Copyright (C) <year> <name of author>
|
||||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.
|
This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an “about box”.
|
The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an “about box”.
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
# 🔒 RustLock
|
# 🔒 RustLock
|
||||||
|
|
||||||
[](https://github.com/yourusername/rustlock/blob/main/LICENSE)
|
[](https://github.com/yourusername/rustlock/blob/main/LICENSE)
|
||||||
[](https://github.com/yourusername/rustlock/releases)
|
[](https://github.com/yourusername/rustlock/releases)
|
||||||
|
|
||||||
A high-performance Wayland screen locker written in Rust, inspired by `swaylock-effects`.
|
A high-performance Wayland screen locker written in Rust, inspired by `swaylock-effects`.
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<img src="assets/rustlock-effects.webp" alt="RustLock effects demo" width="800">
|
||||||
|
</p>
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## ✨ Features
|
## ✨ Features
|
||||||
@@ -13,7 +17,7 @@ A high-performance Wayland screen locker written in Rust, inspired by `swaylock-
|
|||||||
- 🎨 **Visual Effects**:
|
- 🎨 **Visual Effects**:
|
||||||
- Gaussian blur (configurable radius and passes)
|
- Gaussian blur (configurable radius and passes)
|
||||||
- Vignette effect (configurable base and factor)
|
- Vignette effect (configurable base and factor)
|
||||||
- Pixelate, Swirl, and Melting effects
|
- Pixelate and Swirl effects
|
||||||
- Smooth fade-in animation
|
- Smooth fade-in animation
|
||||||
- 🔐 **Password Indicator**:
|
- 🔐 **Password Indicator**:
|
||||||
- Circular ring with configurable radius and thickness
|
- Circular ring with configurable radius and thickness
|
||||||
@@ -123,7 +127,6 @@ Options can be provided via command line or a configuration file at `~/.config/r
|
|||||||
| `--effect-vignette <B>:<F>` | — | Vignette: base : factor (e.g., `0.5:0.5`) |
|
| `--effect-vignette <B>:<F>` | — | Vignette: base : factor (e.g., `0.5:0.5`) |
|
||||||
| `--effect-pixelate <S>` | — | Pixelate effect with block size in pixels |
|
| `--effect-pixelate <S>` | — | Pixelate effect with block size in pixels |
|
||||||
| `--effect-swirl <A>` | — | Swirl distortion with angle |
|
| `--effect-swirl <A>` | — | Swirl distortion with angle |
|
||||||
| `--effect-melting <F>` | — | Melting distortion with factor |
|
|
||||||
| **Colors** (hex `RRGGBB[AA]`) | | |
|
| **Colors** (hex `RRGGBB[AA]`) | | |
|
||||||
| `--ring-color <HEX>` | `#785412` | Outer ring color |
|
| `--ring-color <HEX>` | `#785412` | Outer ring color |
|
||||||
| `--line-color <HEX>` | `#00000000` | Separator line color |
|
| `--line-color <HEX>` | `#00000000` | Separator line color |
|
||||||
@@ -135,14 +138,14 @@ Options can be provided via command line or a configuration file at `~/.config/r
|
|||||||
| `--caps-lock-color <HEX>` | `#E5A445` | Caps lock indicator ring color |
|
| `--caps-lock-color <HEX>` | `#E5A445` | Caps lock indicator ring color |
|
||||||
| `--caps-lock-text-color <HEX>` | `#E5A445` | Caps lock text color |
|
| `--caps-lock-text-color <HEX>` | `#E5A445` | Caps lock text color |
|
||||||
| `--verifying-color <HEX>` | `#0072FF` | Verifying feedback ring color |
|
| `--verifying-color <HEX>` | `#0072FF` | Verifying feedback ring color |
|
||||||
| `--show-caps-lock-text` | `true` | Show "CAPS" text when caps lock is active |
|
| `--show-caps-lock-text` | `false` | Show "CAPS" text when caps lock is active |
|
||||||
| **Display** | | |
|
| **Display** | | |
|
||||||
| `--show-media` | `true` | Show MPRIS media player information |
|
| `--show-media` | `false` | Show MPRIS media player information |
|
||||||
| `--show-battery` | `true` | Show battery status |
|
| `--show-battery` | `false` | Show battery status |
|
||||||
| `--show-network` | `true` | Show WiFi SSID and signal strength |
|
| `--show-network` | `false` | Show WiFi SSID and signal strength |
|
||||||
| `--show-bluetooth` | `true` | Show Bluetooth status |
|
| `--show-bluetooth` | `false` | Show Bluetooth status |
|
||||||
| `--show-album-art` | `true` | Show album art for media |
|
| `--show-album-art` | `false` | Show album art for media |
|
||||||
| `--show-keyboard-layout` | `true` | Show keyboard layout indicator |
|
| `--show-keyboard-layout` | `false` | Show keyboard layout indicator |
|
||||||
| **Feedback & Timing** | | |
|
| **Feedback & Timing** | | |
|
||||||
| `--fade-in <SECONDS>` | `0.2` | Fade-in animation duration |
|
| `--fade-in <SECONDS>` | `0.2` | Fade-in animation duration |
|
||||||
| `--grace <SECONDS>` | `0` | Grace period — any key press unlocks within N seconds |
|
| `--grace <SECONDS>` | `0` | Grace period — any key press unlocks within N seconds |
|
||||||
|
|||||||
|
After Width: | Height: | Size: 149 KiB |
|
After Width: | Height: | Size: 103 KiB |
|
After Width: | Height: | Size: 2.9 MiB |
|
After Width: | Height: | Size: 2.7 MiB |
|
After Width: | Height: | Size: 760 KiB |
|
After Width: | Height: | Size: 154 KiB |
|
After Width: | Height: | Size: 784 KiB |
|
After Width: | Height: | Size: 443 KiB |
@@ -28,9 +28,28 @@
|
|||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
pkgs.pkg-config
|
pkgs.pkg-config
|
||||||
pkgs.rustPlatform.bindgenHook
|
pkgs.rustPlatform.bindgenHook
|
||||||
pkgs.rustfmt
|
];
|
||||||
pkgs.clippy
|
};
|
||||||
|
|
||||||
|
devShells.${system}.default = pkgs.mkShell {
|
||||||
|
packages = with pkgs; [
|
||||||
|
cargo
|
||||||
|
rustc
|
||||||
|
rustfmt
|
||||||
|
clippy
|
||||||
|
cargo-audit
|
||||||
|
cargo-deny
|
||||||
|
prek
|
||||||
|
pkg-config
|
||||||
|
rustPlatform.bindgenHook
|
||||||
|
cairo
|
||||||
|
pam
|
||||||
|
gdk-pixbuf
|
||||||
|
librsvg
|
||||||
|
pango
|
||||||
|
libxkbcommon
|
||||||
|
dbus
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,8 @@ use zeroize::Zeroizing;
|
|||||||
type AuthChannels = (
|
type AuthChannels = (
|
||||||
channel::Sender<(Zeroizing<String>, u64)>,
|
channel::Sender<(Zeroizing<String>, u64)>,
|
||||||
channel::Channel<(bool, u64)>,
|
channel::Channel<(bool, u64)>,
|
||||||
);pub struct LockConversation {
|
);
|
||||||
|
pub struct LockConversation {
|
||||||
pub password: Option<Zeroizing<String>>,
|
pub password: Option<Zeroizing<String>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,13 +40,10 @@ impl pam_client::ConversationHandler for LockConversation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_and_run_auth_loop(
|
pub fn create_and_run_auth_loop(service_name: String) -> Option<AuthChannels> {
|
||||||
service_name: String,
|
|
||||||
) -> Option<AuthChannels> {
|
|
||||||
let username = username();
|
let username = username();
|
||||||
|
|
||||||
let (auth_req_send, auth_req_recv) =
|
let (auth_req_send, auth_req_recv) = channel::channel::<(Zeroizing<String>, u64)>();
|
||||||
channel::channel::<(Zeroizing<String>, u64)>();
|
|
||||||
let (auth_res_send, auth_res_recv) = channel::channel::<(bool, u64)>();
|
let (auth_res_send, auth_res_recv) = channel::channel::<(bool, u64)>();
|
||||||
|
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
@@ -55,20 +53,21 @@ pub fn create_and_run_auth_loop(
|
|||||||
// Creating a new context each time is expensive because it
|
// Creating a new context each time is expensive because it
|
||||||
// re-parses configs and re-loads shared libraries for every attempt.
|
// re-parses configs and re-loads shared libraries for every attempt.
|
||||||
let conversation = LockConversation { password: None };
|
let conversation = LockConversation { password: None };
|
||||||
let mut context = match Context::new(service_name.as_str(), Some(username.as_str()), conversation) {
|
let mut context =
|
||||||
Ok(ctx) => {
|
match Context::new(service_name.as_str(), Some(username.as_str()), conversation) {
|
||||||
debug!("Prepared to authenticate user '{}'", username);
|
Ok(ctx) => {
|
||||||
ctx
|
debug!("Prepared to authenticate user '{}'", username);
|
||||||
}
|
ctx
|
||||||
Err(err) => {
|
}
|
||||||
error!("Failed to initialize PAM context: {:?}", err);
|
Err(err) => {
|
||||||
|
error!("Failed to initialize PAM context: {:?}", err);
|
||||||
error!(
|
error!(
|
||||||
"Ensure that the PAM service '{}' is correctly configured.",
|
"Ensure that the PAM service '{}' is correctly configured.",
|
||||||
service_name
|
service_name
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let running = Arc::new(AtomicBool::new(true));
|
let running = Arc::new(AtomicBool::new(true));
|
||||||
let running_clone = running.clone();
|
let running_clone = running.clone();
|
||||||
|
|||||||
@@ -45,6 +45,13 @@ impl fmt::Display for RingShape {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq, clap::ValueEnum)]
|
||||||
|
pub enum CompletionShell {
|
||||||
|
Bash,
|
||||||
|
Fish,
|
||||||
|
Zsh,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Parser, Debug, Clone, Serialize, Deserialize)]
|
#[derive(Parser, Debug, Clone, Serialize, Deserialize)]
|
||||||
#[command(author, version, about, long_about = None)]
|
#[command(author, version, about, long_about = None)]
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
@@ -91,10 +98,6 @@ pub struct Config {
|
|||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub effect_swirl: Option<f32>,
|
pub effect_swirl: Option<f32>,
|
||||||
|
|
||||||
#[arg(long)]
|
|
||||||
#[serde(default)]
|
|
||||||
pub effect_melting: Option<f32>,
|
|
||||||
|
|
||||||
#[arg(long, default_value = "785412", value_parser = util::parse_hex_color)]
|
#[arg(long, default_value = "785412", value_parser = util::parse_hex_color)]
|
||||||
#[serde(
|
#[serde(
|
||||||
deserialize_with = "util::deserialize_hex_color",
|
deserialize_with = "util::deserialize_hex_color",
|
||||||
@@ -144,7 +147,7 @@ pub struct Config {
|
|||||||
)]
|
)]
|
||||||
pub verifying_color: (f64, f64, f64, f64),
|
pub verifying_color: (f64, f64, f64, f64),
|
||||||
|
|
||||||
#[arg(long, action = clap::ArgAction::SetTrue, default_value_t = true)]
|
#[arg(long, action = clap::ArgAction::SetTrue)]
|
||||||
pub show_caps_lock_text: bool,
|
pub show_caps_lock_text: bool,
|
||||||
|
|
||||||
#[arg(long, default_value = "00000000", value_parser = util::parse_hex_color)]
|
#[arg(long, default_value = "00000000", value_parser = util::parse_hex_color)]
|
||||||
@@ -196,19 +199,19 @@ pub struct Config {
|
|||||||
#[arg(long, default_value = "10000")]
|
#[arg(long, default_value = "10000")]
|
||||||
pub auth_timeout: u64,
|
pub auth_timeout: u64,
|
||||||
|
|
||||||
#[arg(long, action = clap::ArgAction::SetTrue, default_value_t = true)]
|
#[arg(long, action = clap::ArgAction::SetTrue)]
|
||||||
pub show_media: bool,
|
pub show_media: bool,
|
||||||
|
|
||||||
#[arg(long, action = clap::ArgAction::SetTrue, default_value_t = true)]
|
#[arg(long, action = clap::ArgAction::SetTrue)]
|
||||||
pub show_battery: bool,
|
pub show_battery: bool,
|
||||||
|
|
||||||
#[arg(long, action = clap::ArgAction::SetTrue, default_value_t = true)]
|
#[arg(long, action = clap::ArgAction::SetTrue)]
|
||||||
pub show_network: bool,
|
pub show_network: bool,
|
||||||
|
|
||||||
#[arg(long, action = clap::ArgAction::SetTrue, default_value_t = true)]
|
#[arg(long, action = clap::ArgAction::SetTrue)]
|
||||||
pub show_bluetooth: bool,
|
pub show_bluetooth: bool,
|
||||||
|
|
||||||
#[arg(long, action = clap::ArgAction::SetTrue, default_value_t = true)]
|
#[arg(long, action = clap::ArgAction::SetTrue)]
|
||||||
pub show_album_art: bool,
|
pub show_album_art: bool,
|
||||||
|
|
||||||
#[arg(long, action = clap::ArgAction::SetTrue)]
|
#[arg(long, action = clap::ArgAction::SetTrue)]
|
||||||
@@ -293,6 +296,10 @@ pub struct Config {
|
|||||||
#[arg(long, default_value = "5")]
|
#[arg(long, default_value = "5")]
|
||||||
pub command_timeout: u64,
|
pub command_timeout: u64,
|
||||||
|
|
||||||
|
/// Generate shell completions for the given shell
|
||||||
|
#[arg(long, value_enum)]
|
||||||
|
#[serde(skip)]
|
||||||
|
pub completions: Option<CompletionShell>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Config {
|
impl Config {
|
||||||
@@ -300,6 +307,26 @@ impl Config {
|
|||||||
use clap::CommandFactory;
|
use clap::CommandFactory;
|
||||||
|
|
||||||
let mut config = Config::parse();
|
let mut config = Config::parse();
|
||||||
|
|
||||||
|
// Handle --completions early (before config file merge so file can't inject it)
|
||||||
|
if let Some(shell) = config.completions {
|
||||||
|
use clap_complete::Shell;
|
||||||
|
let mut cmd = Config::command();
|
||||||
|
let name = "rustlock";
|
||||||
|
match shell {
|
||||||
|
CompletionShell::Bash => {
|
||||||
|
clap_complete::generate(Shell::Bash, &mut cmd, name, &mut std::io::stdout())
|
||||||
|
}
|
||||||
|
CompletionShell::Fish => {
|
||||||
|
clap_complete::generate(Shell::Fish, &mut cmd, name, &mut std::io::stdout())
|
||||||
|
}
|
||||||
|
CompletionShell::Zsh => {
|
||||||
|
clap_complete::generate(Shell::Zsh, &mut cmd, name, &mut std::io::stdout())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::process::exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
let cmd = Config::command();
|
let cmd = Config::command();
|
||||||
let matches = cmd.get_matches();
|
let matches = cmd.get_matches();
|
||||||
|
|
||||||
@@ -347,7 +374,6 @@ impl Config {
|
|||||||
|
|
||||||
config
|
config
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|||||||
@@ -0,0 +1,285 @@
|
|||||||
|
//! Visual effects for lock screen backgrounds.
|
||||||
|
//!
|
||||||
|
//! Each effect takes a `&mut ImageSurface` and processes it in-place.
|
||||||
|
//! Effects are applied in order: blur → vignette → pixelate → swirl.
|
||||||
|
|
||||||
|
use anyhow::{Context, Result};
|
||||||
|
use cairo::ImageSurface;
|
||||||
|
|
||||||
|
/// Apply a swirl effect (radial rotation around the image centre).
|
||||||
|
pub fn apply_swirl(surface: &mut ImageSurface, angle: f32) -> Result<()> {
|
||||||
|
let width = surface.width();
|
||||||
|
let height = surface.height();
|
||||||
|
let center_x = width as f32 / 2.0;
|
||||||
|
let center_y = height as f32 / 2.0;
|
||||||
|
let radius = center_x.min(center_y);
|
||||||
|
|
||||||
|
let stride = surface.stride() as usize;
|
||||||
|
let mut data = vec![0u8; stride * height as usize];
|
||||||
|
surface
|
||||||
|
.with_data(|src| data.copy_from_slice(src))
|
||||||
|
.context("swirl: failed to read surface data")?;
|
||||||
|
let original = data.clone();
|
||||||
|
|
||||||
|
for y in 0..height {
|
||||||
|
for x in 0..width {
|
||||||
|
let dx = x as f32 - center_x;
|
||||||
|
let dy = y as f32 - center_y;
|
||||||
|
let d = (dx * dx + dy * dy).sqrt();
|
||||||
|
|
||||||
|
if d < radius {
|
||||||
|
let percent = (radius - d) / radius;
|
||||||
|
let theta = percent * percent * angle;
|
||||||
|
let s = theta.sin();
|
||||||
|
let c = theta.cos();
|
||||||
|
|
||||||
|
let nx = (c * dx - s * dy + center_x) as i32;
|
||||||
|
let ny = (s * dx + c * dy + center_y) as i32;
|
||||||
|
|
||||||
|
if nx >= 0 && nx < width && ny >= 0 && ny < height {
|
||||||
|
let src_idx = (ny as usize * stride) + (nx as usize * 4);
|
||||||
|
let dst_idx = (y as usize * stride) + (x as usize * 4);
|
||||||
|
data[dst_idx..dst_idx + 4].copy_from_slice(&original[src_idx..src_idx + 4]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut surface_data = surface
|
||||||
|
.data()
|
||||||
|
.context("swirl: failed to write surface data")?;
|
||||||
|
surface_data.copy_from_slice(&data);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Pixelate the surface.
|
||||||
|
pub fn apply_pixelate(surface: &mut ImageSurface, pixel_size: u32) -> Result<()> {
|
||||||
|
if pixel_size <= 1 {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
|
let width = surface.width();
|
||||||
|
let height = surface.height();
|
||||||
|
let stride = surface.stride() as usize;
|
||||||
|
let mut data = vec![0u8; stride * height as usize];
|
||||||
|
surface
|
||||||
|
.with_data(|src| data.copy_from_slice(src))
|
||||||
|
.context("pixelate: failed to read surface data")?;
|
||||||
|
|
||||||
|
for y in (0..height).step_by(pixel_size as usize) {
|
||||||
|
for x in (0..width).step_by(pixel_size as usize) {
|
||||||
|
let mut r = 0u32;
|
||||||
|
let mut g = 0u32;
|
||||||
|
let mut b = 0u32;
|
||||||
|
let mut count = 0u32;
|
||||||
|
|
||||||
|
// Average pixels in the block
|
||||||
|
for py in 0..pixel_size {
|
||||||
|
for px in 0..pixel_size {
|
||||||
|
let cur_x = x + px as i32;
|
||||||
|
let cur_y = y + py as i32;
|
||||||
|
if cur_x < width && cur_y < height {
|
||||||
|
let index = (cur_y as usize * stride) + (cur_x as usize * 4);
|
||||||
|
r += data[index] as u32;
|
||||||
|
g += data[index + 1] as u32;
|
||||||
|
b += data[index + 2] as u32;
|
||||||
|
count += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if count > 0 {
|
||||||
|
let r = r.checked_div(count).unwrap_or(0) as u8;
|
||||||
|
let g = g.checked_div(count).unwrap_or(0) as u8;
|
||||||
|
let b = b.checked_div(count).unwrap_or(0) as u8;
|
||||||
|
|
||||||
|
// Fill the block
|
||||||
|
for py in 0..pixel_size {
|
||||||
|
for px in 0..pixel_size {
|
||||||
|
let cur_x = x + px as i32;
|
||||||
|
let cur_y = y + py as i32;
|
||||||
|
if cur_x < width && cur_y < height {
|
||||||
|
let index = (cur_y as usize * stride) + (cur_x as usize * 4);
|
||||||
|
data[index] = r;
|
||||||
|
data[index + 1] = g;
|
||||||
|
data[index + 2] = b;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut surface_data = surface
|
||||||
|
.data()
|
||||||
|
.context("pixelate: failed to write surface data")?;
|
||||||
|
surface_data.copy_from_slice(&data);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Apply a box blur effect (fast two-pass sliding-window implementation).
|
||||||
|
/// Uses multiply-shift to avoid slow integer division in the hot loop.
|
||||||
|
pub fn apply_blur(surface: &mut ImageSurface, radius: u32, times: u32) -> Result<()> {
|
||||||
|
if radius == 0 || times == 0 {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
|
let width = surface.width() as usize;
|
||||||
|
let height = surface.height() as usize;
|
||||||
|
let stride = surface.stride() as usize;
|
||||||
|
let r = radius as usize;
|
||||||
|
|
||||||
|
let mut data = vec![0u8; stride * height];
|
||||||
|
surface
|
||||||
|
.with_data(|src| data.copy_from_slice(src))
|
||||||
|
.context("blur: failed to read surface data")?;
|
||||||
|
|
||||||
|
let mut scratch = vec![0u8; stride * height];
|
||||||
|
|
||||||
|
// Precompute ceil(2^32 / c) for every possible window size c.
|
||||||
|
let max_count = (2 * r + 1).min(width.max(height));
|
||||||
|
let factor: Vec<u32> = (0..=max_count)
|
||||||
|
.map(|c| {
|
||||||
|
if c == 0 {
|
||||||
|
0
|
||||||
|
} else {
|
||||||
|
(1u64 << 32).div_ceil(c as u64) as u32
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
|
fn div_mul(n: u32, factor: u32) -> u8 {
|
||||||
|
((n as u64 * factor as u64) >> 32) as u8
|
||||||
|
}
|
||||||
|
|
||||||
|
for _ in 0..times {
|
||||||
|
// Horizontal box blur: data -> scratch
|
||||||
|
for y in 0..height {
|
||||||
|
let row = y * stride;
|
||||||
|
let init_end = r.min(width - 1);
|
||||||
|
let mut b_acc = 0u32;
|
||||||
|
let mut g_acc = 0u32;
|
||||||
|
let mut r_acc = 0u32;
|
||||||
|
for x in 0..=init_end {
|
||||||
|
let px = row + x * 4;
|
||||||
|
b_acc += data[px] as u32;
|
||||||
|
g_acc += data[px + 1] as u32;
|
||||||
|
r_acc += data[px + 2] as u32;
|
||||||
|
}
|
||||||
|
let mut count = (init_end + 1) as u32;
|
||||||
|
|
||||||
|
for x in 0..width {
|
||||||
|
let dst = row + x * 4;
|
||||||
|
let f = factor[count as usize];
|
||||||
|
scratch[dst] = div_mul(b_acc, f);
|
||||||
|
scratch[dst + 1] = div_mul(g_acc, f);
|
||||||
|
scratch[dst + 2] = div_mul(r_acc, f);
|
||||||
|
scratch[dst + 3] = data[dst + 3];
|
||||||
|
|
||||||
|
if x >= r {
|
||||||
|
let old = row + (x - r) * 4;
|
||||||
|
b_acc -= data[old] as u32;
|
||||||
|
g_acc -= data[old + 1] as u32;
|
||||||
|
r_acc -= data[old + 2] as u32;
|
||||||
|
count -= 1;
|
||||||
|
}
|
||||||
|
if x + r + 1 < width {
|
||||||
|
let new = row + (x + r + 1) * 4;
|
||||||
|
b_acc += data[new] as u32;
|
||||||
|
g_acc += data[new + 1] as u32;
|
||||||
|
r_acc += data[new + 2] as u32;
|
||||||
|
count += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Vertical box blur: scratch -> data
|
||||||
|
let init_end = r.min(height - 1);
|
||||||
|
let mut b_acc = vec![0u32; width];
|
||||||
|
let mut g_acc = vec![0u32; width];
|
||||||
|
let mut r_acc = vec![0u32; width];
|
||||||
|
for y in 0..=init_end {
|
||||||
|
let row = y * stride;
|
||||||
|
for x in 0..width {
|
||||||
|
let px = row + x * 4;
|
||||||
|
b_acc[x] += scratch[px] as u32;
|
||||||
|
g_acc[x] += scratch[px + 1] as u32;
|
||||||
|
r_acc[x] += scratch[px + 2] as u32;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let mut count = (init_end + 1) as u32;
|
||||||
|
|
||||||
|
for y in 0..height {
|
||||||
|
let f = factor[count as usize];
|
||||||
|
let dst_row = y * stride;
|
||||||
|
for x in 0..width {
|
||||||
|
let dst = dst_row + x * 4;
|
||||||
|
data[dst] = div_mul(b_acc[x], f);
|
||||||
|
data[dst + 1] = div_mul(g_acc[x], f);
|
||||||
|
data[dst + 2] = div_mul(r_acc[x], f);
|
||||||
|
}
|
||||||
|
|
||||||
|
if y >= r {
|
||||||
|
let old_row = (y - r) * stride;
|
||||||
|
for x in 0..width {
|
||||||
|
let px = old_row + x * 4;
|
||||||
|
b_acc[x] -= scratch[px] as u32;
|
||||||
|
g_acc[x] -= scratch[px + 1] as u32;
|
||||||
|
r_acc[x] -= scratch[px + 2] as u32;
|
||||||
|
}
|
||||||
|
count -= 1;
|
||||||
|
}
|
||||||
|
if y + r + 1 < height {
|
||||||
|
let new_row = (y + r + 1) * stride;
|
||||||
|
for x in 0..width {
|
||||||
|
let px = new_row + x * 4;
|
||||||
|
b_acc[x] += scratch[px] as u32;
|
||||||
|
g_acc[x] += scratch[px + 1] as u32;
|
||||||
|
r_acc[x] += scratch[px + 2] as u32;
|
||||||
|
}
|
||||||
|
count += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut surface_data = surface.data()?;
|
||||||
|
surface_data.copy_from_slice(&data);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Apply a vignette effect (darken edges).
|
||||||
|
pub fn apply_vignette(surface: &mut ImageSurface, base: f32, factor: f32) -> Result<()> {
|
||||||
|
let width = surface.width();
|
||||||
|
let height = surface.height();
|
||||||
|
let center_x = width as f32 / 2.0;
|
||||||
|
let center_y = height as f32 / 2.0;
|
||||||
|
let max_distance = (center_x * center_x + center_y * center_y).sqrt();
|
||||||
|
|
||||||
|
let stride = surface.stride() as usize;
|
||||||
|
let mut data = vec![0u8; stride * height as usize];
|
||||||
|
surface
|
||||||
|
.with_data(|src| data.copy_from_slice(src))
|
||||||
|
.context("vignette: failed to read surface data")?;
|
||||||
|
|
||||||
|
for y in 0..height {
|
||||||
|
for x in 0..width {
|
||||||
|
let dx = x as f32 - center_x;
|
||||||
|
let dy = y as f32 - center_y;
|
||||||
|
let distance = (dx * dx + dy * dy).sqrt();
|
||||||
|
let vignette_factor = base + (1.0 - base) * (distance / max_distance).powf(factor);
|
||||||
|
|
||||||
|
let index = (y as usize * stride) + (x as usize * 4);
|
||||||
|
for i in 0..3 {
|
||||||
|
let value = data[index + i] as f32 * vignette_factor;
|
||||||
|
data[index + i] = value.clamp(0.0, 255.0) as u8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut surface_data = surface
|
||||||
|
.data()
|
||||||
|
.context("vignette: failed to write surface data")?;
|
||||||
|
surface_data.copy_from_slice(&data);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
@@ -165,7 +165,8 @@ impl InputHandler {
|
|||||||
/// Check if key highlight should be shown
|
/// Check if key highlight should be shown
|
||||||
pub fn should_show_key_highlight(&self) -> bool {
|
pub fn should_show_key_highlight(&self) -> bool {
|
||||||
if let Some(timer) = self.key_highlight_timer {
|
if let Some(timer) = self.key_highlight_timer {
|
||||||
timer.elapsed() < std::time::Duration::from_millis(self.config.key_highlight_window_duration)
|
timer.elapsed()
|
||||||
|
< std::time::Duration::from_millis(self.config.key_highlight_window_duration)
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,9 @@ pub struct LockedSurface {
|
|||||||
/// Last clock minute (unix-minute) we rendered, to detect %H:%M rollover.
|
/// Last clock minute (unix-minute) we rendered, to detect %H:%M rollover.
|
||||||
last_minute: i64,
|
last_minute: i64,
|
||||||
ctrl_held: bool,
|
ctrl_held: bool,
|
||||||
|
/// True while the pointer button is held on the indicator ring (hold-to-peek).
|
||||||
|
/// Cleared on button release, matching Ctrl-hold transient behavior.
|
||||||
|
peek_toggled: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LockedSurface {
|
impl LockedSurface {
|
||||||
@@ -64,6 +67,7 @@ impl LockedSurface {
|
|||||||
dirty: true,
|
dirty: true,
|
||||||
last_minute: i64::MIN,
|
last_minute: i64::MIN,
|
||||||
ctrl_held: false,
|
ctrl_held: false,
|
||||||
|
peek_toggled: false,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,10 +186,10 @@ impl LockedSurface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !self.config.hide_password {
|
if !self.config.hide_password {
|
||||||
|
let buf = self.input_handler.password_buffer();
|
||||||
let length = self.input_handler.password_length();
|
let length = self.input_handler.password_length();
|
||||||
if self.ctrl_held {
|
if self.ctrl_held || self.peek_toggled {
|
||||||
self.renderer
|
self.renderer.peek_password(buf.as_str());
|
||||||
.peek_password(self.input_handler.password_buffer().as_str());
|
|
||||||
} else {
|
} else {
|
||||||
self.renderer.set_password_display(length);
|
self.renderer.set_password_display(length);
|
||||||
}
|
}
|
||||||
@@ -302,6 +306,15 @@ impl LockedSurface {
|
|||||||
self.dirty = true;
|
self.dirty = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Set peek mode on/off. Called when the user presses (held=true) or
|
||||||
|
/// releases (held=false) the mouse button on the indicator ring. Works
|
||||||
|
/// like Ctrl-hold — peek only lasts while the button is held.
|
||||||
|
pub fn set_peek_held(&mut self, held: bool) {
|
||||||
|
self.peek_toggled = held;
|
||||||
|
log::debug!("set_peek_held: peek_toggled = {}", self.peek_toggled);
|
||||||
|
self.dirty = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct LockManager {
|
pub struct LockManager {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
mod auth;
|
mod auth;
|
||||||
mod config;
|
mod config;
|
||||||
|
mod effects;
|
||||||
mod input;
|
mod input;
|
||||||
mod lock;
|
mod lock;
|
||||||
mod render;
|
mod render;
|
||||||
@@ -65,10 +66,9 @@ fn setup_file_logging(config: &Config) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if config.log_file {
|
} else if config.log_file {
|
||||||
let default_path = std::path::PathBuf::from(
|
let default_path =
|
||||||
std::env::var("HOME").unwrap_or_else(|_| "/tmp".to_string()),
|
std::path::PathBuf::from(std::env::var("HOME").unwrap_or_else(|_| "/tmp".to_string()))
|
||||||
)
|
.join(".rustlock.log");
|
||||||
.join(".rustlock.log");
|
|
||||||
match OpenOptions::new()
|
match OpenOptions::new()
|
||||||
.create(true)
|
.create(true)
|
||||||
.write(true)
|
.write(true)
|
||||||
@@ -506,8 +506,16 @@ impl KeyboardHandler for WaylandLock {
|
|||||||
modifiers: Modifiers,
|
modifiers: Modifiers,
|
||||||
layout: u32,
|
layout: u32,
|
||||||
) {
|
) {
|
||||||
|
let ctrl_changed = self.modifiers.ctrl != modifiers.ctrl;
|
||||||
self.modifiers = modifiers;
|
self.modifiers = modifiers;
|
||||||
self.current_layout = layout;
|
self.current_layout = layout;
|
||||||
|
if ctrl_changed {
|
||||||
|
log::debug!(
|
||||||
|
"update_modifiers: ctrl {} -> {}",
|
||||||
|
!modifiers.ctrl,
|
||||||
|
modifiers.ctrl
|
||||||
|
);
|
||||||
|
}
|
||||||
if let Ok(mut lock_manager) = self.lock_manager.lock() {
|
if let Ok(mut lock_manager) = self.lock_manager.lock() {
|
||||||
lock_manager.set_ctrl_held(modifiers.ctrl);
|
lock_manager.set_ctrl_held(modifiers.ctrl);
|
||||||
}
|
}
|
||||||
@@ -650,7 +658,10 @@ impl Dispatch<ZwlrScreencopyFrameV1, CaptureData> for WaylandLock {
|
|||||||
if let Ok(surface) = mgr.buffer_to_surface(handle, &mut pool) {
|
if let Ok(surface) = mgr.buffer_to_surface(handle, &mut pool) {
|
||||||
let mut ss = Screenshot::new(surface);
|
let mut ss = Screenshot::new(surface);
|
||||||
if let Err(e) = ss.apply_effects(&state.config) {
|
if let Err(e) = ss.apply_effects(&state.config) {
|
||||||
log::error!("Failed to apply effects to screenshot {}: {e}", data.output_idx);
|
log::error!(
|
||||||
|
"Failed to apply effects to screenshot {}: {e}",
|
||||||
|
data.output_idx
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if data.output_idx < state.captured_backgrounds.len() {
|
if data.output_idx < state.captured_backgrounds.len() {
|
||||||
state.captured_backgrounds[data.output_idx] = Some(ss.into_inner());
|
state.captured_backgrounds[data.output_idx] = Some(ss.into_inner());
|
||||||
@@ -694,12 +705,14 @@ impl PointerHandler for WaylandLock {
|
|||||||
events: &[PointerEvent],
|
events: &[PointerEvent],
|
||||||
) {
|
) {
|
||||||
for event in events {
|
for event in events {
|
||||||
if let PointerEventKind::Press { button, .. } = event.kind {
|
match event.kind {
|
||||||
if button == 0x110 {
|
PointerEventKind::Press { button: 0x110, .. } => {
|
||||||
let (x, y) = event.position;
|
let (x, y) = event.position;
|
||||||
if let Ok(lm) = self.lock_manager.lock() {
|
if let Ok(lm) = self.lock_manager.lock() {
|
||||||
for surface in &lm.surfaces {
|
for surface in &lm.surfaces {
|
||||||
if surface.matches_surface(&event.surface) {
|
if surface.matches_surface(&event.surface) {
|
||||||
|
// Check media controls first
|
||||||
|
let mut handled = false;
|
||||||
for (action, rx, ry, rw, rh) in &surface.renderer.media_rects {
|
for (action, rx, ry, rw, rh) in &surface.renderer.media_rects {
|
||||||
if x >= *rx && x <= rx + rw && y >= *ry && y <= ry + rh {
|
if x >= *rx && x <= rx + rw && y >= *ry && y <= ry + rh {
|
||||||
match *action {
|
match *action {
|
||||||
@@ -709,13 +722,54 @@ impl PointerHandler for WaylandLock {
|
|||||||
"prev" => self.system_manager.media_prev(),
|
"prev" => self.system_manager.media_prev(),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
return;
|
handled = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if handled {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Check indicator ring hit — hold to peek (like Ctrl)
|
||||||
|
let cx = surface.renderer.width as f64 / 2.0;
|
||||||
|
let cy = surface.renderer.height as f64 / 2.0;
|
||||||
|
let r = surface.renderer.config.indicator_radius as f64;
|
||||||
|
let shape = surface.renderer.config.ring_shape;
|
||||||
|
if crate::render::ring_shape::point_in_shape(cx, cy, r, shape, x, y)
|
||||||
|
{
|
||||||
|
drop(lm);
|
||||||
|
if let Ok(mut lm) = self.lock_manager.lock() {
|
||||||
|
if let Some(s) = lm
|
||||||
|
.surfaces
|
||||||
|
.iter_mut()
|
||||||
|
.find(|s| s.matches_surface(&event.surface))
|
||||||
|
{
|
||||||
|
s.set_peek_held(true);
|
||||||
|
s.update();
|
||||||
|
let _ = s.commit(&mut self.pool);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
PointerEventKind::Release { button: 0x110, .. } => {
|
||||||
|
if let Ok(mut lm) = self.lock_manager.lock() {
|
||||||
|
// Clear peek on ALL surfaces. Wayland button release events
|
||||||
|
// can reference a different wl_surface proxy than the press
|
||||||
|
// event (compositor-dependent pointer grab semantics), so
|
||||||
|
// matching by surface might miss the LockedSurface that has
|
||||||
|
// peek_toggled=true. Iterating every surface guarantees peek
|
||||||
|
// always ends on button release — matching Ctrl-hold behavior.
|
||||||
|
for surface in &mut lm.surfaces {
|
||||||
|
surface.set_peek_held(false);
|
||||||
|
surface.update();
|
||||||
|
let _ = surface.commit(&mut self.pool);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -757,12 +811,16 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||||||
|
|
||||||
let system_manager = Arc::new(SystemManager::new(&config));
|
let system_manager = Arc::new(SystemManager::new(&config));
|
||||||
|
|
||||||
let (auth_tx_actual, auth_feedback_rx_actual) =
|
let (auth_tx_actual, auth_feedback_rx_actual) = match auth::create_and_run_auth_loop(
|
||||||
match auth::create_and_run_auth_loop(config.pam_service.clone()) {
|
config.pam_service.clone(),
|
||||||
|
) {
|
||||||
Some(channels) => channels,
|
Some(channels) => channels,
|
||||||
None => {
|
None => {
|
||||||
log::error!("Failed to initialize authentication. This usually means PAM is not configured correctly.");
|
log::error!("Failed to initialize authentication. This usually means PAM is not configured correctly.");
|
||||||
log::error!("Please ensure you have a PAM service file at /etc/pam.d/{}", config.pam_service);
|
log::error!(
|
||||||
|
"Please ensure you have a PAM service file at /etc/pam.d/{}",
|
||||||
|
config.pam_service
|
||||||
|
);
|
||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -902,8 +960,13 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||||||
// treat as auth failure so the user gets feedback instead of hanging forever.
|
// treat as auth failure so the user gets feedback instead of hanging forever.
|
||||||
if state.auth_pending_seq.is_some() {
|
if state.auth_pending_seq.is_some() {
|
||||||
if let Some(at) = state.auth_pending_at {
|
if let Some(at) = state.auth_pending_at {
|
||||||
if Instant::now().duration_since(at) >= Duration::from_millis(state.config.auth_timeout) {
|
if Instant::now().duration_since(at)
|
||||||
log::warn!("Authentication timed out after {} ms", state.config.auth_timeout);
|
>= Duration::from_millis(state.config.auth_timeout)
|
||||||
|
{
|
||||||
|
log::warn!(
|
||||||
|
"Authentication timed out after {} ms",
|
||||||
|
state.config.auth_timeout
|
||||||
|
);
|
||||||
// Clear pending seq so the eventual PAM result is ignored as stale
|
// Clear pending seq so the eventual PAM result is ignored as stale
|
||||||
state.auth_pending_seq = None;
|
state.auth_pending_seq = None;
|
||||||
state.handle_auth_result(false);
|
state.handle_auth_result(false);
|
||||||
|
|||||||
@@ -12,8 +12,7 @@ impl Renderer {
|
|||||||
|
|
||||||
if a > 0.0 {
|
if a > 0.0 {
|
||||||
self.context.new_path();
|
self.context.new_path();
|
||||||
self.context
|
self.context.set_source_rgba(r, g, b, a * self.fade_alpha);
|
||||||
.set_source_rgba(r, g, b, a * self.fade_alpha);
|
|
||||||
self.context.set_line_width(thickness + 2.0);
|
self.context.set_line_width(thickness + 2.0);
|
||||||
self.context.set_line_join(cairo::LineJoin::Round);
|
self.context.set_line_join(cairo::LineJoin::Round);
|
||||||
ring_shape::build_ring_path(
|
ring_shape::build_ring_path(
|
||||||
@@ -180,19 +179,25 @@ impl Renderer {
|
|||||||
pub(crate) fn update_feedback_timers(&mut self) {
|
pub(crate) fn update_feedback_timers(&mut self) {
|
||||||
self.update_uptime();
|
self.update_uptime();
|
||||||
if let Some(start) = self.wrong_password_start {
|
if let Some(start) = self.wrong_password_start {
|
||||||
if start.elapsed() > std::time::Duration::from_millis(self.config.wrong_password_duration) {
|
if start.elapsed()
|
||||||
|
> std::time::Duration::from_millis(self.config.wrong_password_duration)
|
||||||
|
{
|
||||||
self.wrong_password_shown = false;
|
self.wrong_password_shown = false;
|
||||||
self.wrong_password_start = None;
|
self.wrong_password_start = None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Some(start) = self.key_highlight_start {
|
if let Some(start) = self.key_highlight_start {
|
||||||
if start.elapsed() > std::time::Duration::from_millis(self.config.key_highlight_duration) {
|
if start.elapsed()
|
||||||
|
> std::time::Duration::from_millis(self.config.key_highlight_duration)
|
||||||
|
{
|
||||||
self.key_highlight_shown = false;
|
self.key_highlight_shown = false;
|
||||||
self.key_highlight_start = None;
|
self.key_highlight_start = None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Some(start) = self.cleared_feedback_start {
|
if let Some(start) = self.cleared_feedback_start {
|
||||||
if start.elapsed() > std::time::Duration::from_millis(self.config.cleared_feedback_duration) {
|
if start.elapsed()
|
||||||
|
> std::time::Duration::from_millis(self.config.cleared_feedback_duration)
|
||||||
|
{
|
||||||
self.cleared_feedback_shown = false;
|
self.cleared_feedback_shown = false;
|
||||||
self.cleared_feedback_start = None;
|
self.cleared_feedback_start = None;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,30 +75,57 @@ impl Renderer {
|
|||||||
let thickness = self.config.indicator_thickness as f64;
|
let thickness = self.config.indicator_thickness as f64;
|
||||||
let shape = self.config.ring_shape;
|
let shape = self.config.ring_shape;
|
||||||
|
|
||||||
self.context.new_path();
|
let max_dots = self.config.max_dots as f64;
|
||||||
self.context.set_source_rgba(1.0, 1.0, 1.0, self.fade_alpha);
|
let dot_radius = radius - thickness - 10.0;
|
||||||
|
let t_offset = ring_shape::top_centre_offset(shape);
|
||||||
|
|
||||||
let count = self.password_display.len();
|
let count = self.password_display.len();
|
||||||
if count == 0 {
|
if count == 0 {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let max_dots = self.config.max_dots as f64;
|
if self.peeking {
|
||||||
let dot_radius = radius - thickness - 10.0;
|
// Draw each character at the same ring-perimeter positions as dots
|
||||||
let t_offset = ring_shape::top_centre_offset(shape);
|
self.context.set_font_size(14.0);
|
||||||
|
self.context.set_source_rgba(1.0, 1.0, 1.0, self.fade_alpha);
|
||||||
for i in 0..count {
|
for (i, ch) in self.password_display.chars().enumerate() {
|
||||||
let t = (i as f64 / max_dots) + t_offset;
|
let t = (i as f64 / max_dots) + t_offset;
|
||||||
let (x, y) = ring_shape::perimeter_point(center_x, center_y, dot_radius, shape, t);
|
let (x, y) = ring_shape::perimeter_point(center_x, center_y, dot_radius, shape, t);
|
||||||
|
|
||||||
|
let mut ch_str = String::new();
|
||||||
|
ch_str.push(ch);
|
||||||
|
let te = render_try!(self.context.text_extents(&ch_str));
|
||||||
|
self.context.new_path();
|
||||||
|
self.context.move_to(
|
||||||
|
x - te.x_bearing() - te.width() / 2.0,
|
||||||
|
y - te.y_bearing() - te.height() / 2.0,
|
||||||
|
);
|
||||||
|
render_try!(self.context.show_text(&ch_str));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
self.context.new_path();
|
self.context.new_path();
|
||||||
self.context.arc(x, y, 4.0, 0.0, 2.0 * std::f64::consts::PI);
|
self.context.set_source_rgba(1.0, 1.0, 1.0, self.fade_alpha);
|
||||||
render_try!(self.context.fill());
|
|
||||||
|
for i in 0..count {
|
||||||
|
let t = (i as f64 / max_dots) + t_offset;
|
||||||
|
let (x, y) = ring_shape::perimeter_point(center_x, center_y, dot_radius, shape, t);
|
||||||
|
|
||||||
|
self.context.new_path();
|
||||||
|
self.context.arc(x, y, 4.0, 0.0, 2.0 * std::f64::consts::PI);
|
||||||
|
render_try!(self.context.fill());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cursor indicator
|
// Cursor indicator (shared between peek and dot modes).
|
||||||
if self.fade_alpha > 0.0 && self.cursor_position > 0 {
|
if self.fade_alpha > 0.0 {
|
||||||
let cursor_t = ((self.cursor_position as f64 - 0.5) / max_dots) + t_offset;
|
// At position 0, place the cursor squarely at the first-dot position
|
||||||
|
// (t_offset) instead of subtracting 0.5, which would push t negative
|
||||||
|
// and cause perimeter_point to wrap it to the far end of the ring.
|
||||||
|
let cursor_t = if self.cursor_position == 0 {
|
||||||
|
t_offset
|
||||||
|
} else {
|
||||||
|
((self.cursor_position as f64 - 0.5) / max_dots) + t_offset
|
||||||
|
};
|
||||||
let (cx, cy) =
|
let (cx, cy) =
|
||||||
ring_shape::perimeter_point(center_x, center_y, dot_radius, shape, cursor_t);
|
ring_shape::perimeter_point(center_x, center_y, dot_radius, shape, cursor_t);
|
||||||
let dx = cx - center_x;
|
let dx = cx - center_x;
|
||||||
|
|||||||
@@ -15,7 +15,9 @@ impl Renderer {
|
|||||||
if let Ok(img) = image::load_from_memory(data) {
|
if let Ok(img) = image::load_from_memory(data) {
|
||||||
let img = img.to_rgba8();
|
let img = img.to_rgba8();
|
||||||
let (w, h) = img.dimensions();
|
let (w, h) = img.dimensions();
|
||||||
if let Ok(mut surface) = ImageSurface::create(Format::ARgb32, w as i32, h as i32) {
|
if let Ok(mut surface) =
|
||||||
|
ImageSurface::create(Format::ARgb32, w as i32, h as i32)
|
||||||
|
{
|
||||||
if let Ok(mut surface_data) = surface.data() {
|
if let Ok(mut surface_data) = surface.data() {
|
||||||
for y in 0..h {
|
for y in 0..h {
|
||||||
for x in 0..w {
|
for x in 0..w {
|
||||||
@@ -72,7 +74,8 @@ impl Renderer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.context.move_to(text_center_x - te.width() / 2.0, start_y + 20.0);
|
self.context
|
||||||
|
.move_to(text_center_x - te.width() / 2.0, start_y + 20.0);
|
||||||
render_try!(self.context.show_text(&display_text));
|
render_try!(self.context.show_text(&display_text));
|
||||||
|
|
||||||
// All media buttons on one row, evenly spaced.
|
// All media buttons on one row, evenly spaced.
|
||||||
@@ -82,17 +85,18 @@ impl Renderer {
|
|||||||
let btn_y = start_y + 50.0;
|
let btn_y = start_y + 50.0;
|
||||||
|
|
||||||
// Layout: prev | play_pause | next (centered as a group)
|
// Layout: prev | play_pause | next (centered as a group)
|
||||||
let total_buttons: f64 =
|
let total_buttons: f64 = (self.media_prev_icon_surface.is_some() as u32
|
||||||
(self.media_prev_icon_surface.is_some() as u32
|
+ 1
|
||||||
+ 1
|
+ self.media_next_icon_surface.is_some() as u32)
|
||||||
+ self.media_next_icon_surface.is_some() as u32) as f64;
|
as f64;
|
||||||
let group_width = (total_buttons - 1.0) * btn_gap + btn_size;
|
let group_width = (total_buttons - 1.0) * btn_gap + btn_size;
|
||||||
let group_start_x = center_x - group_width / 2.0;
|
let group_start_x = center_x - group_width / 2.0;
|
||||||
let mut btn_x = group_start_x;
|
let mut btn_x = group_start_x;
|
||||||
|
|
||||||
if let Some(ref icon) = self.media_prev_icon_surface {
|
if let Some(ref icon) = self.media_prev_icon_surface {
|
||||||
self.draw_icon_at(btn_x, btn_y - btn_size / 2.0, icon);
|
self.draw_icon_at(btn_x, btn_y - btn_size / 2.0, icon);
|
||||||
self.media_rects.push(("prev", btn_x, btn_y - btn_size / 2.0, btn_size, btn_size));
|
self.media_rects
|
||||||
|
.push(("prev", btn_x, btn_y - btn_size / 2.0, btn_size, btn_size));
|
||||||
btn_x += btn_gap;
|
btn_x += btn_gap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,17 +104,30 @@ impl Renderer {
|
|||||||
if self.system_status.media_playing {
|
if self.system_status.media_playing {
|
||||||
if let Some(ref icon) = self.media_pause_icon_surface {
|
if let Some(ref icon) = self.media_pause_icon_surface {
|
||||||
self.draw_icon_at(btn_x, btn_y - btn_size / 2.0, icon);
|
self.draw_icon_at(btn_x, btn_y - btn_size / 2.0, icon);
|
||||||
self.media_rects.push(("play_pause", btn_x, btn_y - btn_size / 2.0, btn_size, btn_size));
|
self.media_rects.push((
|
||||||
|
"play_pause",
|
||||||
|
btn_x,
|
||||||
|
btn_y - btn_size / 2.0,
|
||||||
|
btn_size,
|
||||||
|
btn_size,
|
||||||
|
));
|
||||||
}
|
}
|
||||||
} else if let Some(ref icon) = self.media_play_icon_surface {
|
} else if let Some(ref icon) = self.media_play_icon_surface {
|
||||||
self.draw_icon_at(btn_x, btn_y - btn_size / 2.0, icon);
|
self.draw_icon_at(btn_x, btn_y - btn_size / 2.0, icon);
|
||||||
self.media_rects.push(("play_pause", btn_x, btn_y - btn_size / 2.0, btn_size, btn_size));
|
self.media_rects.push((
|
||||||
|
"play_pause",
|
||||||
|
btn_x,
|
||||||
|
btn_y - btn_size / 2.0,
|
||||||
|
btn_size,
|
||||||
|
btn_size,
|
||||||
|
));
|
||||||
}
|
}
|
||||||
btn_x += btn_gap;
|
btn_x += btn_gap;
|
||||||
|
|
||||||
if let Some(ref icon) = self.media_next_icon_surface {
|
if let Some(ref icon) = self.media_next_icon_surface {
|
||||||
self.draw_icon_at(btn_x, btn_y - btn_size / 2.0, icon);
|
self.draw_icon_at(btn_x, btn_y - btn_size / 2.0, icon);
|
||||||
self.media_rects.push(("next", btn_x, btn_y - btn_size / 2.0, btn_size, btn_size));
|
self.media_rects
|
||||||
|
.push(("next", btn_x, btn_y - btn_size / 2.0, btn_size, btn_size));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ macro_rules! render_try {
|
|||||||
mod feedback;
|
mod feedback;
|
||||||
mod indicator;
|
mod indicator;
|
||||||
mod media_bar;
|
mod media_bar;
|
||||||
mod ring_shape;
|
pub(crate) mod ring_shape;
|
||||||
mod status_bar;
|
mod status_bar;
|
||||||
|
|
||||||
pub struct Renderer {
|
pub struct Renderer {
|
||||||
@@ -42,6 +42,7 @@ pub struct Renderer {
|
|||||||
pub(crate) key_highlight_angle: f64,
|
pub(crate) key_highlight_angle: f64,
|
||||||
pub(crate) background: Option<ImageSurface>,
|
pub(crate) background: Option<ImageSurface>,
|
||||||
pub(crate) password_display: String,
|
pub(crate) password_display: String,
|
||||||
|
pub(crate) peeking: bool,
|
||||||
pub(crate) cursor_position: usize,
|
pub(crate) cursor_position: usize,
|
||||||
pub(crate) uptime_cache: String,
|
pub(crate) uptime_cache: String,
|
||||||
pub(crate) last_uptime_update: Option<Instant>,
|
pub(crate) last_uptime_update: Option<Instant>,
|
||||||
@@ -85,6 +86,7 @@ impl Renderer {
|
|||||||
key_highlight_angle: 0.0,
|
key_highlight_angle: 0.0,
|
||||||
background: None,
|
background: None,
|
||||||
password_display: String::new(),
|
password_display: String::new(),
|
||||||
|
peeking: false,
|
||||||
cursor_position: 0,
|
cursor_position: 0,
|
||||||
uptime_cache: String::new(),
|
uptime_cache: String::new(),
|
||||||
last_uptime_update: None,
|
last_uptime_update: None,
|
||||||
@@ -127,10 +129,12 @@ impl Renderer {
|
|||||||
|
|
||||||
pub fn set_password_display(&mut self, length: usize) {
|
pub fn set_password_display(&mut self, length: usize) {
|
||||||
self.password_display = ".".repeat(length);
|
self.password_display = ".".repeat(length);
|
||||||
|
self.peeking = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn peek_password(&mut self, password: &str) {
|
pub fn peek_password(&mut self, password: &str) {
|
||||||
self.password_display = password.to_string();
|
self.password_display = password.to_string();
|
||||||
|
self.peeking = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_cursor_position(&mut self, position: usize) {
|
pub fn set_cursor_position(&mut self, position: usize) {
|
||||||
|
|||||||
@@ -9,13 +9,7 @@ const SEGMENTS: usize = 120;
|
|||||||
/// Return the (x, y) point on the shape's perimeter at normalized position `t` ∈ [0, 1].
|
/// Return the (x, y) point on the shape's perimeter at normalized position `t` ∈ [0, 1].
|
||||||
/// `t = 0` is a reference point (rightmost for most shapes); `t` increases clockwise.
|
/// `t = 0` is a reference point (rightmost for most shapes); `t` increases clockwise.
|
||||||
/// `r` is the shape's characteristic radius (distance from center to side/vertex).
|
/// `r` is the shape's characteristic radius (distance from center to side/vertex).
|
||||||
pub(crate) fn perimeter_point(
|
pub(crate) fn perimeter_point(cx: f64, cy: f64, r: f64, shape: RingShape, t: f64) -> (f64, f64) {
|
||||||
cx: f64,
|
|
||||||
cy: f64,
|
|
||||||
r: f64,
|
|
||||||
shape: RingShape,
|
|
||||||
t: f64,
|
|
||||||
) -> (f64, f64) {
|
|
||||||
// Normalize t to [0, 1). Rust's % preserves sign, and the shape-specific
|
// Normalize t to [0, 1). Rust's % preserves sign, and the shape-specific
|
||||||
// functions use floor/truncation that break on negative values.
|
// functions use floor/truncation that break on negative values.
|
||||||
let t = t - t.floor();
|
let t = t - t.floor();
|
||||||
@@ -95,18 +89,17 @@ fn hexagon_perimeter_point(cx: f64, cy: f64, r: f64, t: f64) -> (f64, f64) {
|
|||||||
let local = t * 6.0 - side as f64;
|
let local = t * 6.0 - side as f64;
|
||||||
|
|
||||||
// Shared helper for edges between two vertices
|
// Shared helper for edges between two vertices
|
||||||
let vert = |angle_rad: f64| -> (f64, f64) {
|
let vert =
|
||||||
(cx + r * angle_rad.cos(), cy + r * angle_rad.sin())
|
|angle_rad: f64| -> (f64, f64) { (cx + r * angle_rad.cos(), cy + r * angle_rad.sin()) };
|
||||||
};
|
|
||||||
|
|
||||||
// Vertices clockwise from right (angle = 0)
|
// Vertices clockwise from right (angle = 0)
|
||||||
let v = [
|
let v = [
|
||||||
vert(0.0), // V0: right
|
vert(0.0), // V0: right
|
||||||
vert(std::f64::consts::PI * (1.0 / 3.0)), // V1: bottom-right
|
vert(std::f64::consts::PI * (1.0 / 3.0)), // V1: bottom-right
|
||||||
vert(std::f64::consts::PI * (2.0 / 3.0)), // V2: bottom-left
|
vert(std::f64::consts::PI * (2.0 / 3.0)), // V2: bottom-left
|
||||||
vert(std::f64::consts::PI), // V3: left
|
vert(std::f64::consts::PI), // V3: left
|
||||||
vert(std::f64::consts::PI * (4.0 / 3.0)), // V4: top-left
|
vert(std::f64::consts::PI * (4.0 / 3.0)), // V4: top-left
|
||||||
vert(std::f64::consts::PI * (5.0 / 3.0)), // V5: top-right
|
vert(std::f64::consts::PI * (5.0 / 3.0)), // V5: top-right
|
||||||
];
|
];
|
||||||
|
|
||||||
let (x0, y0) = v[side as usize];
|
let (x0, y0) = v[side as usize];
|
||||||
@@ -214,6 +207,40 @@ pub(crate) fn build_fill_path(
|
|||||||
build_ring_path(ctx, cx, cy, inner_r, shape);
|
build_ring_path(ctx, cx, cy, inner_r, shape);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Check whether a point `(px, py)` lies inside the shape's fill area.
|
||||||
|
/// This is used for hit‑testing (e.g. click & hold to peek) so the clickable
|
||||||
|
/// region matches what the user sees on screen.
|
||||||
|
pub(crate) fn point_in_shape(cx: f64, cy: f64, r: f64, shape: RingShape, px: f64, py: f64) -> bool {
|
||||||
|
let dx = (px - cx).abs();
|
||||||
|
let dy = (py - cy).abs();
|
||||||
|
match shape {
|
||||||
|
RingShape::Circle => dx * dx + dy * dy <= r * r,
|
||||||
|
RingShape::Square => dx <= r && dy <= r,
|
||||||
|
RingShape::Diamond => dx + dy <= r,
|
||||||
|
RingShape::Hexagon => {
|
||||||
|
// Regular hexagon, vertex at (r, 0), edge slopes at ±60°.
|
||||||
|
// For |dx| ≥ r/2 the sloping edge bounds: |dy| ≤ √3 (r − |dx|).
|
||||||
|
// For |dx| ≤ r/2 the flat top bounds: |dy| ≤ √3 r / 2.
|
||||||
|
let sqrt3 = 3.0_f64.sqrt();
|
||||||
|
if dx >= r / 2.0 {
|
||||||
|
dy <= sqrt3 * (r - dx)
|
||||||
|
} else {
|
||||||
|
dy <= r * sqrt3 / 2.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
RingShape::Pill => {
|
||||||
|
// Pill = centre rectangle (2r × 2r) + semicircular caps of
|
||||||
|
// radius r at each end. Total width 4r, height 2r.
|
||||||
|
if dx <= r {
|
||||||
|
dy <= r
|
||||||
|
} else {
|
||||||
|
let ex = dx - r;
|
||||||
|
ex * ex + dy * dy <= r * r
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Return the normalized `t` offset that places the first password dot at the
|
/// Return the normalized `t` offset that places the first password dot at the
|
||||||
/// visual top-centre of the shape. May be negative; callers should NOT wrap.
|
/// visual top-centre of the shape. May be negative; callers should NOT wrap.
|
||||||
pub(crate) fn top_centre_offset(shape: RingShape) -> f64 {
|
pub(crate) fn top_centre_offset(shape: RingShape) -> f64 {
|
||||||
|
|||||||
@@ -36,264 +36,17 @@ impl Screenshot {
|
|||||||
/// Apply configured visual effects to the screenshot.
|
/// Apply configured visual effects to the screenshot.
|
||||||
pub fn apply_effects(&mut self, config: &Config) -> Result<()> {
|
pub fn apply_effects(&mut self, config: &Config) -> Result<()> {
|
||||||
if let Some((radius, times)) = config.effect_blur {
|
if let Some((radius, times)) = config.effect_blur {
|
||||||
self.apply_blur(radius, times)?;
|
crate::effects::apply_blur(&mut self.surface, radius, times)?;
|
||||||
}
|
}
|
||||||
if let Some((base, factor)) = config.effect_vignette {
|
if let Some((base, factor)) = config.effect_vignette {
|
||||||
self.apply_vignette(base, factor)?;
|
crate::effects::apply_vignette(&mut self.surface, base, factor)?;
|
||||||
}
|
}
|
||||||
if let Some(pixel_size) = config.effect_pixelate {
|
if let Some(pixel_size) = config.effect_pixelate {
|
||||||
self.apply_pixelate(pixel_size)?;
|
crate::effects::apply_pixelate(&mut self.surface, pixel_size)?;
|
||||||
}
|
}
|
||||||
if let Some(angle) = config.effect_swirl {
|
if let Some(angle) = config.effect_swirl {
|
||||||
self.apply_swirl(angle)?;
|
crate::effects::apply_swirl(&mut self.surface, angle)?;
|
||||||
}
|
}
|
||||||
if let Some(factor) = config.effect_melting {
|
|
||||||
self.apply_melting(factor)?;
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Apply a swirl effect.
|
|
||||||
pub fn apply_swirl(&mut self, angle: f32) -> Result<()> {
|
|
||||||
let width = self.surface.width();
|
|
||||||
let height = self.surface.height();
|
|
||||||
let center_x = width as f32 / 2.0;
|
|
||||||
let center_y = height as f32 / 2.0;
|
|
||||||
let radius = center_x.min(center_y);
|
|
||||||
|
|
||||||
let stride = self.surface.stride() as usize;
|
|
||||||
let mut data = vec![0u8; stride * height as usize];
|
|
||||||
self.surface
|
|
||||||
.with_data(|src| data.copy_from_slice(src))
|
|
||||||
.context("swirl: failed to read surface data")?;
|
|
||||||
let original = data.clone();
|
|
||||||
|
|
||||||
for y in 0..height {
|
|
||||||
for x in 0..width {
|
|
||||||
let dx = x as f32 - center_x;
|
|
||||||
let dy = y as f32 - center_y;
|
|
||||||
let d = (dx * dx + dy * dy).sqrt();
|
|
||||||
|
|
||||||
if d < radius {
|
|
||||||
let percent = (radius - d) / radius;
|
|
||||||
let theta = percent * percent * angle;
|
|
||||||
let s = theta.sin();
|
|
||||||
let c = theta.cos();
|
|
||||||
|
|
||||||
let nx = (c * dx - s * dy + center_x) as i32;
|
|
||||||
let ny = (s * dx + c * dy + center_y) as i32;
|
|
||||||
|
|
||||||
if nx >= 0 && nx < width && ny >= 0 && ny < height {
|
|
||||||
let src_idx = (ny as usize * stride) + (nx as usize * 4);
|
|
||||||
let dst_idx = (y as usize * stride) + (x as usize * 4);
|
|
||||||
data[dst_idx..dst_idx + 4].copy_from_slice(&original[src_idx..src_idx + 4]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut surface_data = self.surface.data().context("swirl: failed to write surface data")?;
|
|
||||||
surface_data.copy_from_slice(&data);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Apply a melting effect (vertical smear).
|
|
||||||
pub fn apply_melting(&mut self, factor: f32) -> Result<()> {
|
|
||||||
let width = self.surface.width();
|
|
||||||
let height = self.surface.height();
|
|
||||||
|
|
||||||
let stride = self.surface.stride() as usize;
|
|
||||||
let mut data = vec![0u8; stride * height as usize];
|
|
||||||
self.surface
|
|
||||||
.with_data(|src| data.copy_from_slice(src))
|
|
||||||
.context("melting: failed to read surface data")?;
|
|
||||||
|
|
||||||
use rand::RngExt;
|
|
||||||
let mut rng = rand::rng();
|
|
||||||
|
|
||||||
for x in 0..width {
|
|
||||||
let mut melt_amount = 0.0;
|
|
||||||
for y in 0..height {
|
|
||||||
melt_amount += rng.random_range(0.0..factor);
|
|
||||||
let src_y = (y as f32 - melt_amount).max(0.0) as i32;
|
|
||||||
|
|
||||||
let src_idx = (src_y as usize * stride) + (x as usize * 4);
|
|
||||||
let dst_idx = (y as usize * stride) + (x as usize * 4);
|
|
||||||
|
|
||||||
// Copy the pixel from above to create a smear
|
|
||||||
let pixel = [
|
|
||||||
data[src_idx],
|
|
||||||
data[src_idx + 1],
|
|
||||||
data[src_idx + 2],
|
|
||||||
data[src_idx + 3],
|
|
||||||
];
|
|
||||||
data[dst_idx..dst_idx + 4].copy_from_slice(&pixel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut surface_data = self.surface.data().context("melting: failed to write surface data")?;
|
|
||||||
surface_data.copy_from_slice(&data);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Pixelate the surface.
|
|
||||||
pub fn apply_pixelate(&mut self, pixel_size: u32) -> Result<()> {
|
|
||||||
if pixel_size <= 1 {
|
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
|
|
||||||
let width = self.surface.width();
|
|
||||||
let height = self.surface.height();
|
|
||||||
let stride = self.surface.stride() as usize;
|
|
||||||
let mut data = vec![0u8; stride * height as usize];
|
|
||||||
self.surface
|
|
||||||
.with_data(|src| data.copy_from_slice(src))
|
|
||||||
.context("pixelate: failed to read surface data")?;
|
|
||||||
|
|
||||||
for y in (0..height).step_by(pixel_size as usize) {
|
|
||||||
for x in (0..width).step_by(pixel_size as usize) {
|
|
||||||
let mut r = 0u32;
|
|
||||||
let mut g = 0u32;
|
|
||||||
let mut b = 0u32;
|
|
||||||
let mut count = 0u32;
|
|
||||||
|
|
||||||
// Average pixels in the block
|
|
||||||
for py in 0..pixel_size {
|
|
||||||
for px in 0..pixel_size {
|
|
||||||
let cur_x = x + px as i32;
|
|
||||||
let cur_y = y + py as i32;
|
|
||||||
if cur_x < width && cur_y < height {
|
|
||||||
let index = (cur_y as usize * stride) + (cur_x as usize * 4);
|
|
||||||
r += data[index] as u32;
|
|
||||||
g += data[index + 1] as u32;
|
|
||||||
b += data[index + 2] as u32;
|
|
||||||
count += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if count > 0 {
|
|
||||||
let r = r.checked_div(count).unwrap_or(0) as u8;
|
|
||||||
let g = g.checked_div(count).unwrap_or(0) as u8;
|
|
||||||
let b = b.checked_div(count).unwrap_or(0) as u8;
|
|
||||||
|
|
||||||
// Fill the block
|
|
||||||
for py in 0..pixel_size {
|
|
||||||
for px in 0..pixel_size {
|
|
||||||
let cur_x = x + px as i32;
|
|
||||||
let cur_y = y + py as i32;
|
|
||||||
if cur_x < width && cur_y < height {
|
|
||||||
let index = (cur_y as usize * stride) + (cur_x as usize * 4);
|
|
||||||
data[index] = r;
|
|
||||||
data[index + 1] = g;
|
|
||||||
data[index + 2] = b;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut surface_data = self.surface.data().context("pixelate: failed to write surface data")?;
|
|
||||||
surface_data.copy_from_slice(&data);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Apply a Gaussian blur effect.
|
|
||||||
pub fn apply_blur(&mut self, radius: u32, times: u32) -> Result<()> {
|
|
||||||
if radius == 0 || times == 0 {
|
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
|
|
||||||
let width = self.surface.width() as usize;
|
|
||||||
let height = self.surface.height() as usize;
|
|
||||||
let stride = self.surface.stride() as usize;
|
|
||||||
let mut data = vec![0u8; stride * height];
|
|
||||||
|
|
||||||
self.surface
|
|
||||||
.with_data(|src| data.copy_from_slice(src))
|
|
||||||
.context("blur: failed to read surface data")?;
|
|
||||||
|
|
||||||
// Convert from stride-padded surface data to tight RgbaImage.
|
|
||||||
// Cairo stride may be larger than width*4 for alignment, so copy
|
|
||||||
// row by row to strip the padding.
|
|
||||||
let tight_stride = width * 4;
|
|
||||||
let mut tight = vec![0u8; tight_stride * height];
|
|
||||||
for y in 0..height {
|
|
||||||
let src_off = y * stride;
|
|
||||||
let dst_off = y * tight_stride;
|
|
||||||
tight[dst_off..dst_off + tight_stride]
|
|
||||||
.copy_from_slice(&data[src_off..src_off + tight_stride]);
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut img: image::ImageBuffer<image::Rgba<u8>, Vec<u8>> =
|
|
||||||
image::ImageBuffer::from_raw(width as u32, height as u32, tight)
|
|
||||||
.context("blur: failed to create image buffer")?;
|
|
||||||
|
|
||||||
for _ in 0..times {
|
|
||||||
let mut rgb_data: Vec<[u8; 3]> =
|
|
||||||
Vec::with_capacity(width * height);
|
|
||||||
for pixel in img.pixels() {
|
|
||||||
rgb_data.push([pixel[0], pixel[1], pixel[2]]);
|
|
||||||
}
|
|
||||||
|
|
||||||
fastblur::gaussian_blur(
|
|
||||||
&mut rgb_data,
|
|
||||||
width,
|
|
||||||
height,
|
|
||||||
radius as f32,
|
|
||||||
);
|
|
||||||
|
|
||||||
for (i, pixel) in img.pixels_mut().enumerate() {
|
|
||||||
pixel[0] = rgb_data[i][0];
|
|
||||||
pixel[1] = rgb_data[i][1];
|
|
||||||
pixel[2] = rgb_data[i][2];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Copy back from tight buffer into stride-padded surface data
|
|
||||||
let new_data = img.into_raw();
|
|
||||||
let mut surface_data = self.surface.data()?;
|
|
||||||
for y in 0..height {
|
|
||||||
let src_off = y * tight_stride;
|
|
||||||
let dst_off = y * stride;
|
|
||||||
surface_data[dst_off..dst_off + tight_stride]
|
|
||||||
.copy_from_slice(&new_data[src_off..src_off + tight_stride]);
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Apply a vignette effect (darken edges).
|
|
||||||
pub fn apply_vignette(&mut self, base: f32, factor: f32) -> Result<()> {
|
|
||||||
let width = self.surface.width();
|
|
||||||
let height = self.surface.height();
|
|
||||||
let center_x = width as f32 / 2.0;
|
|
||||||
let center_y = height as f32 / 2.0;
|
|
||||||
let max_distance = (center_x * center_x + center_y * center_y).sqrt();
|
|
||||||
|
|
||||||
let stride = self.surface.stride() as usize;
|
|
||||||
let mut data = vec![0u8; stride * height as usize];
|
|
||||||
self.surface
|
|
||||||
.with_data(|src| data.copy_from_slice(src))
|
|
||||||
.context("vignette: failed to read surface data")?;
|
|
||||||
|
|
||||||
for y in 0..height {
|
|
||||||
for x in 0..width {
|
|
||||||
let dx = x as f32 - center_x;
|
|
||||||
let dy = y as f32 - center_y;
|
|
||||||
let distance = (dx * dx + dy * dy).sqrt();
|
|
||||||
let vignette_factor = base + (1.0 - base) * (distance / max_distance).powf(factor);
|
|
||||||
|
|
||||||
let index = (y as usize * stride) + (x as usize * 4);
|
|
||||||
for i in 0..3 {
|
|
||||||
let value = data[index + i] as f32 * vignette_factor;
|
|
||||||
data[index + i] = value.clamp(0.0, 255.0) as u8;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut surface_data = self.surface.data().context("vignette: failed to write surface data")?;
|
|
||||||
surface_data.copy_from_slice(&data);
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -296,16 +296,25 @@ impl SystemManager {
|
|||||||
let action = cmd;
|
let action = cmd;
|
||||||
// Fire-and-forget: don't block the polling loop on MPRIS.
|
// Fire-and-forget: don't block the polling loop on MPRIS.
|
||||||
tokio::task::spawn_blocking(move || {
|
tokio::task::spawn_blocking(move || {
|
||||||
if let Ok(finder) = PlayerFinder::new() {
|
match PlayerFinder::new() {
|
||||||
if let Ok(player) = finder.find_active() {
|
Ok(finder) => {
|
||||||
match action {
|
match finder.find_active() {
|
||||||
BackendCommand::MediaPlayPause => { let _ = player.play_pause(); }
|
Ok(player) => {
|
||||||
BackendCommand::MediaStop => { let _ = player.stop(); }
|
let result = match action {
|
||||||
BackendCommand::MediaNext => { let _ = player.next(); }
|
BackendCommand::MediaPlayPause => player.play_pause(),
|
||||||
BackendCommand::MediaPrev => { let _ = player.previous(); }
|
BackendCommand::MediaStop => player.stop(),
|
||||||
_ => {}
|
BackendCommand::MediaNext => player.next(),
|
||||||
|
BackendCommand::MediaPrev => player.previous(),
|
||||||
|
_ => Ok(()),
|
||||||
|
};
|
||||||
|
if let Err(e) = result {
|
||||||
|
error!("MPRIS command {action:?} failed: {e}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(e) => error!("No active MPRIS player found: {e}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Err(e) => error!("Failed to create MPRIS PlayerFinder: {e}"),
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -320,10 +329,7 @@ impl SystemManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_status(&self) -> SystemStatus {
|
pub fn get_status(&self) -> SystemStatus {
|
||||||
self.status
|
self.status.lock().map(|s| s.clone()).unwrap_or_default()
|
||||||
.lock()
|
|
||||||
.map(|s| s.clone())
|
|
||||||
.unwrap_or_default()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn send_command(&self, cmd: BackendCommand) {
|
pub fn send_command(&self, cmd: BackendCommand) {
|
||||||
|
|||||||