diff --git a/src/main.rs b/src/main.rs index fc42c1a..82fab75 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,6 +8,7 @@ extern crate log; mod bundle; mod config; +use std::error::Error; use std::sync::Arc; use tokio::signal::unix::{signal, SignalKind}; #[cfg(feature = "bundle")] @@ -15,7 +16,7 @@ use tokio::sync::mpsc; use watchers::{run_first_supported, ReportClient, WatcherType}; #[tokio::main(flavor = "current_thread")] -async fn main() -> anyhow::Result<()> { +async fn main() -> anyhow::Result<(), Box> { let config = config::from_cli()?; #[cfg(feature = "bundle")] let no_tray = config.no_tray; diff --git a/watchers/Cargo.toml b/watchers/Cargo.toml index a263525..eedadc3 100644 --- a/watchers/Cargo.toml +++ b/watchers/Cargo.toml @@ -14,7 +14,7 @@ rstest = "0.19.0" tempfile = "3.10.1" [dependencies] -aw-client-rust = { git = "https://github.com/ActivityWatch/aw-server-rust", rev = "448312d" } +aw-client-rust = { git = "https://github.com/ActivityWatch/aw-server-rust", rev = "9275009" } wayland-client = "0.31.1" wayland-protocols = { version = "0.31.2", features = ["staging", "client" ]} wayland-protocols-plasma = { version = "0.2.0", features = ["client"] } diff --git a/watchers/src/config.rs b/watchers/src/config.rs index 6e5e776..0ebe7cb 100644 --- a/watchers/src/config.rs +++ b/watchers/src/config.rs @@ -7,7 +7,7 @@ pub use file_config::FileConfig; use std::time::Duration; pub struct Config { - pub port: u32, + pub port: u16, pub host: String, pub idle_timeout: Duration, pub poll_time_idle: Duration, diff --git a/watchers/src/config/defaults.rs b/watchers/src/config/defaults.rs index a9e3566..21d5f7d 100644 --- a/watchers/src/config/defaults.rs +++ b/watchers/src/config/defaults.rs @@ -7,7 +7,7 @@ pub fn poll_time_idle_seconds() -> u32 { pub fn poll_time_window_seconds() -> u32 { 1 } -pub fn port() -> u32 { +pub fn port() -> u16 { 5600 } pub fn host() -> String { diff --git a/watchers/src/config/file_config.rs b/watchers/src/config/file_config.rs index 4b4fa79..7554509 100644 --- a/watchers/src/config/file_config.rs +++ b/watchers/src/config/file_config.rs @@ -52,7 +52,7 @@ pub fn default_config() -> String { #[derive(Deserialize, DefaultFromSerde)] pub struct ServerConfig { #[serde(default = "defaults::port")] - pub port: u32, + pub port: u16, #[serde(default = "defaults::host")] pub host: String, } diff --git a/watchers/src/report_client.rs b/watchers/src/report_client.rs index 1d4a8e6..d8d4754 100644 --- a/watchers/src/report_client.rs +++ b/watchers/src/report_client.rs @@ -4,6 +4,7 @@ use aw_client_rust::{AwClient, Event as AwEvent}; use chrono::{DateTime, Duration, Utc}; use serde_json::{Map, Value}; use std::future::Future; +use std::error::Error; pub struct ReportClient { pub client: AwClient, @@ -13,8 +14,8 @@ pub struct ReportClient { } impl ReportClient { - pub async fn new(config: Config) -> anyhow::Result { - let client = AwClient::new(&config.host, &config.port.to_string(), "awatcher"); + pub async fn new(config: Config) -> anyhow::Result> { + let client = AwClient::new(&config.host, config.port, "awatcher")?; let hostname = gethostname::gethostname().into_string().unwrap(); let idle_bucket_name = format!("aw-watcher-afk_{hostname}");