Skip to content

Commit 38d9769

Browse files
authored
Merge pull request #2 from risoflora/v1.1
Implementing v1.1 with macOS support (fix #1)
2 parents 810853b + 698ac1e commit 38d9769

File tree

12 files changed

+344
-202
lines changed

12 files changed

+344
-202
lines changed

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
indent_size = 2
7+
indent_style = space
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true

.github/workflows/CI.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
######################################################################
2+
# Copyright (c) 2022 Silvio Clecio (silvioprog) <silvioprog@gmail.com>
3+
#
4+
# SPDX-License-Identifier: MIT
5+
######################################################################
6+
7+
name: CI/CD
8+
9+
on: [push, pull_request]
10+
11+
env:
12+
CARGO_TERM_COLOR: always
13+
14+
jobs:
15+
build:
16+
name: ${{ matrix.job.target }}
17+
runs-on: ${{ matrix.job.os }}
18+
19+
strategy:
20+
matrix:
21+
job:
22+
- target: x86_64-unknown-linux-gnu
23+
os: ubuntu-22.04
24+
test: false
25+
publish: true
26+
27+
- target: x86_64-apple-darwin
28+
test: false
29+
os: macos-11
30+
31+
- target: aarch64-apple-darwin
32+
os: macos-11
33+
34+
- target: x86_64-pc-windows-msvc
35+
test: false
36+
os: windows-2022
37+
38+
steps:
39+
- uses: actions/checkout@v3
40+
41+
- name: Install Rust toolchain
42+
uses: actions-rs/toolchain@v1
43+
with:
44+
profile: minimal
45+
toolchain: stable
46+
target: ${{ matrix.job.target }}
47+
48+
- name: Cargo build
49+
uses: actions-rs/cargo@v1
50+
with:
51+
command: build
52+
args: --release --target ${{ matrix.job.target }}
53+
54+
- name: Cargo test
55+
if: matrix.job.test
56+
uses: actions-rs/cargo@v1
57+
with:
58+
command: test
59+
args: --target ${{ matrix.job.target }}
60+
61+
- name: Cargo publish
62+
if: startsWith(github.ref, 'refs/tags/') && matrix.job.publish
63+
uses: actions-rs/cargo@v1
64+
with:
65+
command: publish
66+
args: --token ${{ secrets.CARGO_TOKEN }} -v

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,9 @@ Cargo.lock
88

99
# These are backup files generated by rustfmt
1010
**/*.rs.bk
11+
12+
# VSCode files
13+
.vscode
14+
15+
# macOS files
16+
.DS_Store

.travis.yml

Lines changed: 0 additions & 8 deletions
This file was deleted.

Cargo.toml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
[package]
22
name = 'lock_keys'
3-
version = '1.0.0'
3+
version = '1.1.0'
44
authors = ['Silvio Clecio (silvioprog) <silvioprog@gmail.com>']
55
license = 'MIT/Apache-2.0'
66
description = 'Rust library for lock keys handling.'
77
homepage = 'https://github.com/risoflora/lock_keys'
88
repository = 'https://github.com/risoflora/lock_keys'
99
readme = 'README.md'
10-
keywords = [
11-
'capslock',
12-
'numlock',
13-
'numlockx',
14-
'scrolllock',
15-
]
10+
keywords = ['capslock', 'numlock', 'numlockx', 'scrolllock']
1611
categories = [
17-
'api-bindings',
18-
'hardware-support',
19-
'os::macos-apis',
20-
'os::unix-apis',
21-
'os::windows-apis',
12+
'api-bindings',
13+
'hardware-support',
14+
'os::macos-apis',
15+
'os::unix-apis',
16+
'os::windows-apis',
2217
]
18+
edition = '2021'
2319

2420
[dependencies]
2521
[target."cfg(windows)".dependencies.winapi]
2622
version = '0.3'
2723
features = ['winuser']
24+
[target.'cfg(target_os = "macos")'.dependencies]
25+
core-foundation = '0.9'
26+
mach = '0.3'
27+
io-kit-sys = '0.2'

README.md

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,54 @@
11
# `lock_keys`
22

3-
[![Build Status][travis-badge]][travis-url]
3+
[![CI/CD][ci-cd-badge]][ci-cd-url]
44
[![Crates.io][crates-badge]][crates-url]
55
[![Documentation][docs-badge]][docs-url]
66
[![License][license-badge]][license-url]
77

8-
[travis-badge]: https://travis-ci.org/risoflora/lock_keys.svg
9-
[travis-url]: https://travis-ci.org/risoflora/lock_keys
10-
[crates-badge]: https://img.shields.io/crates/v/lock_keys.svg
11-
[crates-url]: https://crates.io/crates/lock_keys
12-
[docs-badge]: https://docs.rs/lock_keys/badge.svg
13-
[docs-url]: https://docs.rs/lock_keys
14-
[license-badge]: https://img.shields.io/crates/l/lock_keys.svg
15-
[license-url]: https://github.com/risoflora/lock_keys#license
16-
178
`lock_keys` provides a cross platform way for lock keys handling.
189

19-
Supported platforms: Linux ([Xlib](https://en.wikipedia.org/wiki/Xlib) static) and Windows ([winuser API](https://docs.microsoft.com/en-us/windows/win32/api/winuser)).
20-
21-
## Example
22-
23-
The example below shows how to turn on the Number Lock key:
24-
25-
```rust
26-
extern crate lock_keys;
27-
28-
use lock_keys::*;
29-
30-
fn main() {
31-
let lockkey = LockKey::new();
32-
lockkey.enable(LockKeys::NumberLock).unwrap();
33-
}
34-
```
10+
Supported platforms: Linux ([Xlib][xlib-wiki-url] static),
11+
Windows ([winuser API][winuser-api-url]) and macOS ([IOKit][iokit-url]).
3512

3613
## Usage
3714

3815
Add this to your `Cargo.toml`:
3916

4017
```ini
4118
[dependencies]
42-
lock_keys = "1.0.0"
19+
lock_keys = "*"
4320
```
4421

45-
and this to your crate root:
22+
and then:
4623

4724
```rust
48-
extern crate lock_keys;
25+
use lock_keys::*;
26+
27+
fn main() {
28+
let lock_key = LockKey::new();
29+
lock_key.enable(LockKeys::CapitalLock).unwrap();
30+
}
4931
```
5032

5133
## Contributions
5234

53-
Pull Requests and Issues are welcome!
35+
Pull Requests are welcome! =)
5436

5537
## License
5638

5739
`lock_keys` is licensed under either of the following, at your option:
5840

59-
- Apache License 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
60-
- MIT License ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
41+
- [Apache License 2.0](LICENSE-APACHE)
42+
- [MIT License](LICENSE-MIT)
43+
44+
[ci-cd-badge]: https://github.com/risoflora/lock_keys/actions/workflows/CI.yml/badge.svg
45+
[ci-cd-url]: https://github.com/risoflora/lock_keys/actions/workflows/CI.yml
46+
[crates-badge]: https://img.shields.io/crates/v/lock_keys.svg
47+
[crates-url]: https://crates.io/crates/lock_keys
48+
[docs-badge]: https://docs.rs/lock_keys/badge.svg
49+
[docs-url]: https://docs.rs/lock_keys
50+
[license-badge]: https://img.shields.io/crates/l/lock_keys.svg
51+
[license-url]: https://github.com/risoflora/lock_keys#license
52+
[xlib-wiki-url]: https://en.wikipedia.org/wiki/Xlib
53+
[winuser-api-url]: https://docs.microsoft.com/en-us/windows/win32/api/winuser
54+
[iokit-url]: https://developer.apple.com/documentation/iokit

examples/capital_lock.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//! How to toggle the state of the Capital Lock key.
2+
3+
use lock_keys::*;
4+
5+
fn main() {
6+
let lock_key = LockKey::new();
7+
lock_key.toggle(LockKeys::CapitalLock).unwrap();
8+
}

examples/numlock.rs

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)