Skip to content

Commit

Permalink
Merge pull request #2 from risoflora/v1.1
Browse files Browse the repository at this point in the history
Implementing v1.1 with macOS support (fix #1)
  • Loading branch information
silvioprog authored Jan 2, 2023
2 parents 810853b + 698ac1e commit 38d9769
Show file tree
Hide file tree
Showing 12 changed files with 344 additions and 202 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
66 changes: 66 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
######################################################################
# Copyright (c) 2022 Silvio Clecio (silvioprog) <silvioprog@gmail.com>
#
# SPDX-License-Identifier: MIT
######################################################################

name: CI/CD

on: [push, pull_request]

env:
CARGO_TERM_COLOR: always

jobs:
build:
name: ${{ matrix.job.target }}
runs-on: ${{ matrix.job.os }}

strategy:
matrix:
job:
- target: x86_64-unknown-linux-gnu
os: ubuntu-22.04
test: false
publish: true

- target: x86_64-apple-darwin
test: false
os: macos-11

- target: aarch64-apple-darwin
os: macos-11

- target: x86_64-pc-windows-msvc
test: false
os: windows-2022

steps:
- uses: actions/checkout@v3

- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
target: ${{ matrix.job.target }}

- name: Cargo build
uses: actions-rs/cargo@v1
with:
command: build
args: --release --target ${{ matrix.job.target }}

- name: Cargo test
if: matrix.job.test
uses: actions-rs/cargo@v1
with:
command: test
args: --target ${{ matrix.job.target }}

- name: Cargo publish
if: startsWith(github.ref, 'refs/tags/') && matrix.job.publish
uses: actions-rs/cargo@v1
with:
command: publish
args: --token ${{ secrets.CARGO_TOKEN }} -v
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@ Cargo.lock

# These are backup files generated by rustfmt
**/*.rs.bk

# VSCode files
.vscode

# macOS files
.DS_Store
8 changes: 0 additions & 8 deletions .travis.yml

This file was deleted.

24 changes: 12 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
[package]
name = 'lock_keys'
version = '1.0.0'
version = '1.1.0'
authors = ['Silvio Clecio (silvioprog) <silvioprog@gmail.com>']
license = 'MIT/Apache-2.0'
description = 'Rust library for lock keys handling.'
homepage = 'https://github.com/risoflora/lock_keys'
repository = 'https://github.com/risoflora/lock_keys'
readme = 'README.md'
keywords = [
'capslock',
'numlock',
'numlockx',
'scrolllock',
]
keywords = ['capslock', 'numlock', 'numlockx', 'scrolllock']
categories = [
'api-bindings',
'hardware-support',
'os::macos-apis',
'os::unix-apis',
'os::windows-apis',
'api-bindings',
'hardware-support',
'os::macos-apis',
'os::unix-apis',
'os::windows-apis',
]
edition = '2021'

[dependencies]
[target."cfg(windows)".dependencies.winapi]
version = '0.3'
features = ['winuser']
[target.'cfg(target_os = "macos")'.dependencies]
core-foundation = '0.9'
mach = '0.3'
io-kit-sys = '0.2'
58 changes: 26 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,60 +1,54 @@
# `lock_keys`

[![Build Status][travis-badge]][travis-url]
[![CI/CD][ci-cd-badge]][ci-cd-url]
[![Crates.io][crates-badge]][crates-url]
[![Documentation][docs-badge]][docs-url]
[![License][license-badge]][license-url]

[travis-badge]: https://travis-ci.org/risoflora/lock_keys.svg
[travis-url]: https://travis-ci.org/risoflora/lock_keys
[crates-badge]: https://img.shields.io/crates/v/lock_keys.svg
[crates-url]: https://crates.io/crates/lock_keys
[docs-badge]: https://docs.rs/lock_keys/badge.svg
[docs-url]: https://docs.rs/lock_keys
[license-badge]: https://img.shields.io/crates/l/lock_keys.svg
[license-url]: https://github.com/risoflora/lock_keys#license

`lock_keys` provides a cross platform way for lock keys handling.

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)).

## Example

The example below shows how to turn on the Number Lock key:

```rust
extern crate lock_keys;

use lock_keys::*;

fn main() {
let lockkey = LockKey::new();
lockkey.enable(LockKeys::NumberLock).unwrap();
}
```
Supported platforms: Linux ([Xlib][xlib-wiki-url] static),
Windows ([winuser API][winuser-api-url]) and macOS ([IOKit][iokit-url]).

## Usage

Add this to your `Cargo.toml`:

```ini
[dependencies]
lock_keys = "1.0.0"
lock_keys = "*"
```

and this to your crate root:
and then:

```rust
extern crate lock_keys;
use lock_keys::*;

fn main() {
let lock_key = LockKey::new();
lock_key.enable(LockKeys::CapitalLock).unwrap();
}
```

## Contributions

Pull Requests and Issues are welcome!
Pull Requests are welcome! =)

## License

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

- Apache License 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
- MIT License ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
- [Apache License 2.0](LICENSE-APACHE)
- [MIT License](LICENSE-MIT)

[ci-cd-badge]: https://github.com/risoflora/lock_keys/actions/workflows/CI.yml/badge.svg
[ci-cd-url]: https://github.com/risoflora/lock_keys/actions/workflows/CI.yml
[crates-badge]: https://img.shields.io/crates/v/lock_keys.svg
[crates-url]: https://crates.io/crates/lock_keys
[docs-badge]: https://docs.rs/lock_keys/badge.svg
[docs-url]: https://docs.rs/lock_keys
[license-badge]: https://img.shields.io/crates/l/lock_keys.svg
[license-url]: https://github.com/risoflora/lock_keys#license
[xlib-wiki-url]: https://en.wikipedia.org/wiki/Xlib
[winuser-api-url]: https://docs.microsoft.com/en-us/windows/win32/api/winuser
[iokit-url]: https://developer.apple.com/documentation/iokit
8 changes: 8 additions & 0 deletions examples/capital_lock.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//! How to toggle the state of the Capital Lock key.
use lock_keys::*;

fn main() {
let lock_key = LockKey::new();
lock_key.toggle(LockKeys::CapitalLock).unwrap();
}
10 changes: 0 additions & 10 deletions examples/numlock.rs

This file was deleted.

Loading

0 comments on commit 38d9769

Please sign in to comment.