diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..758a0f1 --- /dev/null +++ b/.github/workflows/ci.yml @@ -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 diff --git a/README.md b/README.md index fa2a906..410b5b0 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/src/main.rs b/src/main.rs index bde3c1a..d65b09f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,15 +11,17 @@ fn main() -> Result<(), Box> { 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(); diff --git a/src/tui_app.rs b/src/tui_app.rs index 166fd2a..e3db4c4 100644 --- a/src/tui_app.rs +++ b/src/tui_app.rs @@ -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 @@ -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),