Add github workflow and fix warnings

This commit is contained in:
Demmie 2023-04-23 13:30:35 -04:00
parent 534c8dc984
commit cc50f221a6
No known key found for this signature in database
GPG Key ID: B06DAA3D432C6E9A
3 changed files with 56 additions and 14 deletions

44
.github/workflows/verify.yml vendored Normal file
View File

@ -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

View File

@ -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 {

View File

@ -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<dyn Error>;
@ -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> {