mirror of
https://github.com/2e3s/awatcher.git
synced 2025-06-07 03:55:29 +00:00
Add github workflow and fix warnings
This commit is contained in:
parent
534c8dc984
commit
cc50f221a6
44
.github/workflows/verify.yml
vendored
Normal file
44
.github/workflows/verify.yml
vendored
Normal 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
|
@ -180,15 +180,17 @@ impl Watcher for WindowWatcher {
|
|||||||
})();
|
})();
|
||||||
match result {
|
match result {
|
||||||
Ok(connection) => {
|
Ok(connection) => {
|
||||||
tx.send(Ok(())).unwrap();
|
tx.send(None).unwrap();
|
||||||
loop {
|
loop {
|
||||||
connection.monitor_activity().wait();
|
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");
|
info!("Starting active window watcher");
|
||||||
loop {
|
loop {
|
||||||
|
18
src/main.rs
18
src/main.rs
@ -16,15 +16,9 @@ mod x11_window;
|
|||||||
|
|
||||||
use config::Config;
|
use config::Config;
|
||||||
use fern::colors::{Color, ColoredLevelConfig};
|
use fern::colors::{Color, ColoredLevelConfig};
|
||||||
use kwin_window::WindowWatcher as KwinWindowWatcher;
|
|
||||||
use report_client::ReportClient;
|
use report_client::ReportClient;
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::{error::Error, str::FromStr, sync::Arc, thread};
|
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>;
|
type BoxedError = Box<dyn Error>;
|
||||||
|
|
||||||
@ -64,13 +58,15 @@ macro_rules! watcher {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const IDLE_WATCHERS: &[WatcherConstructor] =
|
const IDLE_WATCHERS: &[WatcherConstructor] = &[
|
||||||
&[watcher!(WlKwinIdleWatcher), watcher!(X11IdleWatcher)];
|
watcher!(wl_kwin_idle::IdleWatcher),
|
||||||
|
watcher!(x11_screensaver_idle::IdleWatcher),
|
||||||
|
];
|
||||||
|
|
||||||
const ACTIVE_WINDOW_WATCHERS: &[WatcherConstructor] = &[
|
const ACTIVE_WINDOW_WATCHERS: &[WatcherConstructor] = &[
|
||||||
watcher!(WlrForeignToplevelWindowWatcher),
|
watcher!(wl_foreign_toplevel::WindowWatcher),
|
||||||
watcher!(KwinWindowWatcher),
|
watcher!(kwin_window::WindowWatcher),
|
||||||
watcher!(X11WindowWatcher),
|
watcher!(x11_window::WindowWatcher),
|
||||||
];
|
];
|
||||||
|
|
||||||
fn setup_logger() -> Result<(), fern::InitError> {
|
fn setup_logger() -> Result<(), fern::InitError> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user