diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8bf2f5b..952842c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,7 +12,7 @@ jobs: # 22.04 is the earliest version with OpenSSL 3 runs-on: ubuntu-22.04 env: - AW_WEBUI_DIST: ./aw-webui/dist + AW_WEBUI_DIR: ./aw-webui/dist steps: - uses: actions/checkout@v3 - uses: dtolnay/rust-toolchain@nightly diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index bcba263..ef067f2 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -20,7 +20,7 @@ jobs: clippy: runs-on: ubuntu-latest env: - AW_WEBUI_DIST: ./src/bundle + AW_WEBUI_DIR: ./src/bundle steps: - uses: actions/checkout@v3 - run: sudo apt-get install -y libdbus-1-dev @@ -33,7 +33,7 @@ jobs: test: runs-on: ubuntu-latest env: - AW_WEBUI_DIST: ./src/bundle + AW_WEBUI_DIR: ./src/bundle steps: - uses: actions/checkout@v3 - run: sudo apt-get install -y libdbus-1-dev diff --git a/Cargo.lock b/Cargo.lock index d4e9d0a..68e8f06 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -329,7 +329,7 @@ name = "aw-client-rust" version = "0.1.0" source = "git+https://github.com/2e3s/aw-server-rust?rev=81db4c8#81db4c8f15b13f106bef960f3a4adf770fc71b50" dependencies = [ - "aw-models", + "aw-models 0.1.0 (git+https://github.com/2e3s/aw-server-rust?rev=81db4c8)", "chrono", "gethostname 0.4.3", "reqwest", @@ -341,10 +341,10 @@ dependencies = [ [[package]] name = "aw-datastore" version = "0.1.0" -source = "git+https://github.com/2e3s/aw-server-rust?rev=81db4c8#81db4c8f15b13f106bef960f3a4adf770fc71b50" +source = "git+https://github.com/ActivityWatch/aw-server-rust?rev=448312d#448312d410980d4a92a0fb4d4bb3fa3494cf6c89" dependencies = [ "appdirs", - "aw-models", + "aw-models 0.1.0 (git+https://github.com/ActivityWatch/aw-server-rust?rev=448312d)", "aw-transform", "chrono", "log", @@ -354,6 +354,18 @@ dependencies = [ "serde_json", ] +[[package]] +name = "aw-models" +version = "0.1.0" +source = "git+https://github.com/ActivityWatch/aw-server-rust?rev=448312d#448312d410980d4a92a0fb4d4bb3fa3494cf6c89" +dependencies = [ + "chrono", + "log", + "schemars", + "serde", + "serde_json", +] + [[package]] name = "aw-models" version = "0.1.0" @@ -369,10 +381,10 @@ dependencies = [ [[package]] name = "aw-query" version = "0.1.0" -source = "git+https://github.com/2e3s/aw-server-rust?rev=81db4c8#81db4c8f15b13f106bef960f3a4adf770fc71b50" +source = "git+https://github.com/ActivityWatch/aw-server-rust?rev=448312d#448312d410980d4a92a0fb4d4bb3fa3494cf6c89" dependencies = [ "aw-datastore", - "aw-models", + "aw-models 0.1.0 (git+https://github.com/ActivityWatch/aw-server-rust?rev=448312d)", "aw-transform", "chrono", "fancy-regex", @@ -385,12 +397,12 @@ dependencies = [ [[package]] name = "aw-server" version = "0.12.1" -source = "git+https://github.com/2e3s/aw-server-rust?rev=81db4c8#81db4c8f15b13f106bef960f3a4adf770fc71b50" +source = "git+https://github.com/ActivityWatch/aw-server-rust?rev=448312d#448312d410980d4a92a0fb4d4bb3fa3494cf6c89" dependencies = [ "android_logger", "appdirs", "aw-datastore", - "aw-models", + "aw-models 0.1.0 (git+https://github.com/ActivityWatch/aw-server-rust?rev=448312d)", "aw-query", "aw-transform", "chrono", @@ -407,7 +419,7 @@ dependencies = [ "openssl-sys", "rocket", "rocket_cors", - "rust-embed", + "rust-embed 8.0.0", "serde", "serde_json", "toml", @@ -417,9 +429,9 @@ dependencies = [ [[package]] name = "aw-transform" version = "0.1.0" -source = "git+https://github.com/2e3s/aw-server-rust?rev=81db4c8#81db4c8f15b13f106bef960f3a4adf770fc71b50" +source = "git+https://github.com/ActivityWatch/aw-server-rust?rev=448312d#448312d410980d4a92a0fb4d4bb3fa3494cf6c89" dependencies = [ - "aw-models", + "aw-models 0.1.0 (git+https://github.com/ActivityWatch/aw-server-rust?rev=448312d)", "chrono", "fancy-regex", "log", @@ -442,7 +454,7 @@ dependencies = [ "ksni", "log", "open", - "rust-embed", + "rust-embed 6.8.1", "tokio", "toml", "watchers", @@ -2715,8 +2727,9 @@ dependencies = [ [[package]] name = "rocket_cors" -version = "0.6.0-alpha1" -source = "git+https://github.com/lawliet89/rocket_cors?rev=54fae07#54fae0701dffbe5df686465780218644ee3fae5f" +version = "0.6.0-alpha2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b12771b47f52e34d5d0e0e444aeba382863e73263cb9e18847e7d5b74aa2cbd0" dependencies = [ "http", "log", @@ -2807,8 +2820,19 @@ version = "6.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a36224c3276f8c4ebc8c20f158eca7ca4359c8db89991c4925132aaaf6702661" dependencies = [ - "rust-embed-impl", - "rust-embed-utils", + "rust-embed-impl 6.8.1", + "rust-embed-utils 7.8.1", + "walkdir", +] + +[[package]] +name = "rust-embed" +version = "8.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1e7d90385b59f0a6bf3d3b757f3ca4ece2048265d70db20a2016043d4509a40" +dependencies = [ + "rust-embed-impl 8.0.0", + "rust-embed-utils 8.0.0", "walkdir", ] @@ -2820,7 +2844,21 @@ checksum = "49b94b81e5b2c284684141a2fb9e2a31be90638caf040bf9afbc5a0416afe1ac" dependencies = [ "proc-macro2 1.0.63", "quote 1.0.29", - "rust-embed-utils", + "rust-embed-utils 7.8.1", + "shellexpand", + "syn 2.0.24", + "walkdir", +] + +[[package]] +name = "rust-embed-impl" +version = "8.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c3d8c6fd84090ae348e63a84336b112b5c3918b3bf0493a581f7bd8ee623c29" +dependencies = [ + "proc-macro2 1.0.63", + "quote 1.0.29", + "rust-embed-utils 8.0.0", "shellexpand", "syn 2.0.24", "walkdir", @@ -2836,6 +2874,16 @@ dependencies = [ "walkdir", ] +[[package]] +name = "rust-embed-utils" +version = "8.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "873feff8cb7bf86fdf0a71bb21c95159f4e4a37dd7a4bd1855a940909b583ada" +dependencies = [ + "sha2", + "walkdir", +] + [[package]] name = "rustc-demangle" version = "0.1.23" diff --git a/Cargo.toml b/Cargo.toml index 67e2bdf..763277c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,8 +36,8 @@ anyhow = { workspace = true } tokio = { workspace = true, features = ["rt", "macros", "signal"] } ksni = {version = "0.2.1", optional = true} -aw-server = { git = "https://github.com/2e3s/aw-server-rust", optional = true, rev = "81db4c8" } -aw-datastore = { git = "https://github.com/2e3s/aw-server-rust", optional = true, rev = "81db4c8" } +aw-server = { git = "https://github.com/ActivityWatch/aw-server-rust", optional = true, rev = "448312d" } +aw-datastore = { git = "https://github.com/ActivityWatch/aw-server-rust", optional = true, rev = "448312d" } open = { version = "5.0.0", optional = true } rust-embed = { version = "6.8.1", features = ["interpolate-folder-path"], optional = true } diff --git a/README.md b/README.md index 92fa6a7..0338ee0 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # Awatcher -[![Build Status](https://github.com/2e3s/awatcher/workflows/check/badge.svg?branch=main)](https://github.com/2e3s/awatcher/actions?query=branch%3Amain) [![Dependency Status](https://deps.rs/repo/github/2e3s/awatcher/status.svg)](https://deps.rs/repo/github/2e3s/awatcher) +[![Build Status](https://github.com/2e3s/awatcher/workflows/check/badge.svg?branch=main)](https://github.com/2e3s/awatcher/actions?query=branch%3Amain) +[![Dependency Status](https://deps.rs/repo/github/2e3s/awatcher/status.svg)](https://deps.rs/repo/github/2e3s/awatcher) Awatcher is a window activity and idle watcher with an optional tray and UI for statistics. The goal is to compensate the fragmentation of desktop environments on Linux by supporting all reportable environments, @@ -9,50 +10,14 @@ The foundation is [ActivityWatch](https://github.com/ActivityWatch), which inclu The unbundled watcher is supposed to replace the original idle and active window watchers from the original distribution. The bundled executable can be used independently as it contains the server, UI and tray. -The crate also provides a library with watchers which can send the data to the server. - -## Build - -### Prerequisites - -Names of packages are from Ubuntu, other distributions may have different names. - -- Rust stable or nightly (for the bundle) toolchain -- pkg-config -- libssl-dev -- libdbus-1-dev (for the bundled version) -- build-essential - -### Compile - -- `cargo build --release` in the root of the repository. -- The target file will be located at `target/release/awatcher`. - -Add `--no-default-features` to the build command if you want to opt out of the Gnome and KDE support, -add `--features=?` ("gnome" or "kwin_window") on top of that if you want to enable just one. - -To track your activities in browsers install the plugin for your browser from -[here](https://github.com/ActivityWatch/aw-watcher-web) (Firefox, Chrome etc). - -#### Compile with bundle - -The executable can be bundled with a tray icon, ActivityWatch server and, optionally, Web UI (if steps 1-2 are done): - -1. Clone and follow the instruction in [ActivityWatch/aw-webui@839366e](https://github.com/ActivityWatch/aw-webui/commit/839366e66f859faadd7f9128de3bea14b25ce4ae) -to build the "dist" folder, -1. Build the executable with `AW_WEBUI_DIST=path/to/dist` and `--features=bundle`. - -This should be compiled on nightly. The complete bundled version is also built and released. - -Gnome needs [the extension](https://extensions.gnome.org/extension/615/appindicator-support/) to support StatusNotifierItem specification. - -The tray can be disabled with `--no-tray` option in the bundled version. +The binaries for the bundle, bundled DEB and ActivityWatch watchers replacement can be downloaded from +[releases](https://github.com/2e3s/awatcher/releases). ## Supported environments ActivityWatch server should be run before `awatcher` is running. At this moment only Linux is supported. The watcher type is selected automatically -by availability of necessary interfaces in the given environment. +as soon as the environment has the necessary interfaces. | Environment | Active window | Idle | | --------------- | -------------------- | ------------------- | @@ -108,7 +73,7 @@ Copy the section as many times as needed for every given filter. The first matching filter stops the replacement. There should be at least 1 match field, and at least 1 replace field for a valid filter. -Matches are case sensitive regular expressions between implici ^ and $: +Matches are case sensitive regular expressions between implicit ^ and $: - `.` matches 1 any character - `.*` matches any number of any characters - `.+` matches 1 or more any characters. @@ -137,3 +102,40 @@ to see what application names and titles are reported to the server. ``` $ awatcher -vvv --no-server ``` + +## Build + +### Prerequisites + +Names of packages are from Ubuntu, other distributions may have different names. + +- Rust stable or nightly (for the bundle) toolchain +- pkg-config +- libssl-dev +- libdbus-1-dev (for the bundled version) +- build-essential + +### Compile + +- `cargo build --release` in the root of the repository. +- The target file will be located at `target/release/awatcher`. + +Add `--no-default-features` to the build command if you want to opt out of the Gnome and KDE support, +add `--features=?` ("gnome" or "kwin_window") on top of that if you want to enable just one. + +To track your activities in browsers install the plugin for your browser from +[here](https://github.com/ActivityWatch/aw-watcher-web) (Firefox, Chrome etc). + +#### Compile with bundle + +The executable can be bundled with a tray icon, ActivityWatch server and, optionally, Web UI (if steps 1-2 are done): + +1. Clone and follow the instruction in [ActivityWatch/aw-webui@839366e](https://github.com/ActivityWatch/aw-webui/commit/839366e66f859faadd7f9128de3bea14b25ce4ae) +to build the "dist" folder, +1. Build the executable with `AW_WEBUI_DIR=/absolute/path/to/dist` and `--features=bundle`. + +This should be compiled on nightly. The complete bundled version is also built and released. + +Gnome needs [the extension](https://extensions.gnome.org/extension/615/appindicator-support/) to support StatusNotifierItem specification. + +The tray can be disabled with `--no-tray` option in the bundled version. diff --git a/src/bundle/server.rs b/src/bundle/server.rs index edbb34f..a71a46a 100644 --- a/src/bundle/server.rs +++ b/src/bundle/server.rs @@ -1,5 +1,5 @@ use anyhow::anyhow; -use aw_server::endpoints::{build_rocket, embed_asset_resolver}; +use aw_server::endpoints::{build_rocket, AssetResolver, ServerState}; use std::sync::Mutex; pub async fn run(port: u32) { @@ -15,9 +15,9 @@ pub async fn run(port: u32) { config.port = u16::try_from(port).unwrap(); let legacy_import = false; - let server_state = aw_server::endpoints::ServerState { + let server_state = ServerState { datastore: Mutex::new(aw_datastore::Datastore::new(db_path, legacy_import)), - asset_resolver: embed_asset_resolver!("$AW_WEBUI_DIST", None), + asset_resolver: AssetResolver::new(None), device_id, }; build_rocket(server_state, config).launch().await.unwrap();