diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml new file mode 100644 index 0000000..d906371 --- /dev/null +++ b/.github/workflows/verify.yml @@ -0,0 +1,44 @@ +on: + push: + branches: + - main + pull_request: + +name: check + +env: + CARGO_TERM_COLOR: always +jobs: + fmt: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + components: rustfmt + override: true + default: true + - name: cargo fmt + uses: actions-rs/cargo@v1 + with: + command: fmt + args: -- --check + clippy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + components: clippy + profile: minimal + default: true + - uses: Swatinem/rust-cache@v2 + - name: Run cargo check + uses: actions-rs/cargo@v1 + with: + command: clippy + args: -- -D warnings diff --git a/src/kwin_window.rs b/src/kwin_window.rs index fb704b3..2686988 100644 --- a/src/kwin_window.rs +++ b/src/kwin_window.rs @@ -180,15 +180,17 @@ impl Watcher for WindowWatcher { })(); match result { Ok(connection) => { - tx.send(Ok(())).unwrap(); + tx.send(None).unwrap(); loop { connection.monitor_activity().wait(); } } - Err(e) => tx.send(Err(e)), + Err(e) => tx.send(Some(e)), } }); - let _ = rx.recv().unwrap(); + if let Some(error) = rx.recv().unwrap() { + panic!("Failed to run a DBus interface: {error}"); + } info!("Starting active window watcher"); loop { diff --git a/src/main.rs b/src/main.rs index bde1328..0f1b124 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,15 +16,9 @@ mod x11_window; use config::Config; use fern::colors::{Color, ColoredLevelConfig}; -use kwin_window::WindowWatcher as KwinWindowWatcher; use report_client::ReportClient; use std::env; use std::{error::Error, str::FromStr, sync::Arc, thread}; -use wl_kwin_idle::IdleWatcher as WlKwinIdleWatcher; -use x11_screensaver_idle::IdleWatcher as X11IdleWatcher; -use x11_window::WindowWatcher as X11WindowWatcher; - -use crate::wl_foreign_toplevel::WindowWatcher as WlrForeignToplevelWindowWatcher; type BoxedError = Box; @@ -64,13 +58,15 @@ macro_rules! watcher { }; } -const IDLE_WATCHERS: &[WatcherConstructor] = - &[watcher!(WlKwinIdleWatcher), watcher!(X11IdleWatcher)]; +const IDLE_WATCHERS: &[WatcherConstructor] = &[ + watcher!(wl_kwin_idle::IdleWatcher), + watcher!(x11_screensaver_idle::IdleWatcher), +]; const ACTIVE_WINDOW_WATCHERS: &[WatcherConstructor] = &[ - watcher!(WlrForeignToplevelWindowWatcher), - watcher!(KwinWindowWatcher), - watcher!(X11WindowWatcher), + watcher!(wl_foreign_toplevel::WindowWatcher), + watcher!(kwin_window::WindowWatcher), + watcher!(x11_window::WindowWatcher), ]; fn setup_logger() -> Result<(), fern::InitError> {