Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Cargo Build & Test

on:
push:
branches:
- master
pull_request:
branches:
- master

env:
CARGO_TERM_COLOR: always

jobs:
build_and_test:
name: Rust project - latest
runs-on: ubuntu-latest
strategy:
matrix:
toolchain:
- stable
steps:
- uses: actions/checkout@v4
- name: "Install dependencies"
run: sudo apt update && sudo apt install libudev-dev
- name: "📦 Setup Rust"
run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}
- name: "⚙️ Build"
run: cargo build --verbose
- name: "✅ Run tests"
run: cargo test --verbose
- name: "🤓 Run clippy"
run: cargo clippy --all-features --all-targets -- --deny warnings
- name: "✍️ Check code formatting"
run: cargo fmt --all --check
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# chron_tui - Terminal user interface for adjusting Keychron mouse settings

⚠️ Warning - the project is in a very early stage, try at your own risk and expect A LOT of issues
[![CI](https://github.com/kubastick/chron-tui/actions/workflows/ci.yml/badge.svg)](https://github.com/kubastick/chron-tui/actions/workflows/ci.yml)

⚠️ Warning - the project is in a very early stage, try at your own risk and expect A LOT of issues

![Screenshot of the terminal running tui](./media/preview.png)

## Device support
Expand Down
8 changes: 5 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {

trace!("Initializing HID API");
let api = HidApi::new()?;

#[cfg(target_os = "macos")]
api.set_open_exclusive(false);

trace!("Initializing mouse receiver device");
let vendor_id = 0x3434;
let wired_product_id = 0xd050;
let wireless_receiver_product_id = 0xd028;
let mouse_hid_d = api.open(vendor_id, wired_product_id).or_else(|_| {
api.open(vendor_id, wireless_receiver_product_id)
})?;
let mouse_hid_d = api
.open(vendor_id, wired_product_id)
.or_else(|_| api.open(vendor_id, wireless_receiver_product_id))?;

mouse_hid_d.set_blocking_mode(false)?;
let product_name = mouse_hid_d.get_product_string()?.unwrap_or_default();
Expand Down
6 changes: 4 additions & 2 deletions src/tui_app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl App {
self.current_dpi_index += 1;
let max_index = self.dpi_config.presets.len() as i8 - 1;
self.current_dpi_index = self.current_dpi_index.min(max_index);
},
}
KeyCode::Enter => {
let dpi_preset_index = self.current_dpi_index;
// This do not always succeed, so ignore error for now
Expand Down Expand Up @@ -101,7 +101,9 @@ impl Widget for &App {
false => " ".to_owned(),
};

let list_str = format!("{dpi_highlighted_symbol}#{natural_index} [{dpi_preset_active_symbol}] {dpi_value}");
let list_str = format!(
"{dpi_highlighted_symbol}#{natural_index} [{dpi_preset_active_symbol}] {dpi_value}"
);
let list_item_style = match dpi_highlighted {
true => match dpi_preset_active {
true => Style::new().bold().bg(Color::Green).fg(Color::White),
Expand Down