ActivityWatch / aw-watcher-window-wayland

Window and AFK watcher for some Wayland compositors
Mozilla Public License 2.0
60 stars 14 forks source link

Breaking Changes to Rust and SwayWM Broke aw-watcher-window-wayland #35

Closed ddxtanx closed 2 months ago

ddxtanx commented 7 months ago

Firstly, sway no longer works with this watcher: https://github.com/swaywm/sway/releases/tag/1.9 notes that they have switched idle mechanisms to the more standard idle-notify-v1 https://wayland.app/protocols/ext-idle-notify-v1. This leads to the following error occurring every time I try to start aw-watcher-window-wayland on my desktop:

### Setting up display
### Fetching wayland globals
### Setting up toplevel manager
### Setting up idle timeout
thread 'main' panicked at src/idle.rs:79:10:
Wayland session does not expose a Idle object, this window manager is most likely not supported: Missing
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::result::unwrap_failed
   3: aw_watcher_window_wayland::idle::assign_idle_timeout
   4: aw_watcher_window_wayland::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Also, due to updates to rust/various packages compilation no longer works on the latest rust-stable.

With the provided package.lock, rustc-serialize triggers a compilation error

error[E0310]: the parameter type `T` may not live long enough
    --> HOME/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rustc-serialize-0.3.24/src/serialize.rs:1155:5
     |
1155 |     fn decode<D: Decoder>(d: &mut D) -> Result<Cow<'static, T>, D::Error> {
     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |     |
     |     the parameter type `T` must be valid for the static lifetime...
     |     ...so that the type `T` will meet its required lifetime bounds...
     |
note: ...that is required by this bound
    --> HOME/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/borrow.rs:180:30
     |
180  | pub enum Cow<'a, B: ?Sized + 'a>
     |                              ^^
help: consider adding an explicit lifetime bound
     |
1151 | impl<'a, T: ?Sized + 'static> Decodable for Cow<'a, T>
     |                    +++++++++

For more information about this error, try `rustc --explain E0310`.
error: could not compile `rustc-serialize` (lib) due to 1 previous error

but after cargo update-ing, this project's code now triggers the following errors

error[E0308]: mismatched types
   --> src/main.rs:131:54
    |
131 |     let client = aw_client_rust::AwClient::new(host, port, "aw-watcher-wayland");
    |                  -----------------------------       ^^^^ expected `u16`, found `&str`
    |                  |
    |                  arguments to this function are incorrect
    |
note: associated function defined here
   --> HOME/.cargo/git/checkouts/aw-server-rust-880bcc5747287dac/1b56e03/aw-client-rust/src/lib.rs:36:12
    |
36  |     pub fn new(host: &str, port: u16, name: &str) -> Result<AwClient, Box<dyn Error>> {
    |            ^^^

error[E0599]: no method named `create_bucket_simple` found for enum `Result` in the current scope
   --> src/main.rs:135:12
    |
135 |     client.create_bucket_simple(&window_bucket, "currentwindow")
    |            ^^^^^^^^^^^^^^^^^^^^ method not found in `Result<AwClient, Box<dyn Error>>`
    |
note: the method `create_bucket_simple` exists on the type `aw_client_rust::AwClient`
   --> HOME/.cargo/git/checkouts/aw-server-rust-880bcc5747287dac/1b56e03/aw-client-rust/src/lib.rs:75:5
    |
75  | /     pub async fn create_bucket_simple(
76  | |         &self,
77  | |         bucketname: &str,
78  | |         buckettype: &str,
79  | |     ) -> Result<(), reqwest::Error> {
    | |___________________________________^
help: consider using `Result::expect` to unwrap the `aw_client_rust::AwClient` value, panicking if the value is a `Result::Err`
    |
135 |     client.expect("REASON").create_bucket_simple(&window_bucket, "currentwindow")
    |           +++++++++++++++++

error[E0599]: no method named `create_bucket_simple` found for enum `Result` in the current scope
   --> src/main.rs:137:12
    |
137 |     client.create_bucket_simple(&afk_bucket, "afkstatus")
    |            ^^^^^^^^^^^^^^^^^^^^ method not found in `Result<AwClient, Box<dyn Error>>`
    |
note: the method `create_bucket_simple` exists on the type `aw_client_rust::AwClient`
   --> HOME/.cargo/git/checkouts/aw-server-rust-880bcc5747287dac/1b56e03/aw-client-rust/src/lib.rs:75:5
    |
75  | /     pub async fn create_bucket_simple(
76  | |         &self,
77  | |         bucketname: &str,
78  | |         buckettype: &str,
79  | |     ) -> Result<(), reqwest::Error> {
    | |___________________________________^
help: consider using `Result::expect` to unwrap the `aw_client_rust::AwClient` value, panicking if the value is a `Result::Err`
    |
137 |     client.expect("REASON").create_bucket_simple(&afk_bucket, "afkstatus")
    |           +++++++++++++++++

error[E0599]: no method named `heartbeat` found for enum `Result` in the current scope
   --> src/main.rs:155:35
    |
155 |                         if client.heartbeat(&window_bucket, &window_event, HEARTBEAT_INTERVAL_MARGIN_S).is_err() {
    |                                   ^^^^^^^^^ method not found in `Result<AwClient, Box<dyn Error>>`
    |
note: the method `heartbeat` exists on the type `aw_client_rust::AwClient`
   --> HOME/.cargo/git/checkouts/aw-server-rust-880bcc5747287dac/1b56e03/aw-client-rust/src/lib.rs:150:5
    |
150 | /     pub async fn heartbeat(
151 | |         &self,
152 | |         bucketname: &str,
153 | |         event: &Event,
154 | |         pulsetime: f64,
155 | |     ) -> Result<(), reqwest::Error> {
    | |___________________________________^
help: consider using `Result::expect` to unwrap the `aw_client_rust::AwClient` value, panicking if the value is a `Result::Err`
    |
155 |                         if client.expect("REASON").heartbeat(&window_bucket, &window_event, HEARTBEAT_INTERVAL_MARGIN_S).is_err() {
    |                                  +++++++++++++++++

error[E0599]: no method named `heartbeat` found for enum `Result` in the current scope
   --> src/main.rs:164:39
    |
164 | ...                   if client.heartbeat(&window_bucket, &window_event, HEARTBEAT_INTERVAL_MARGIN_S).is_err() {
    |                                 ^^^^^^^^^ method not found in `Result<AwClient, Box<dyn Error>>`
    |
note: the method `heartbeat` exists on the type `aw_client_rust::AwClient`
   --> HOME/.cargo/git/checkouts/aw-server-rust-880bcc5747287dac/1b56e03/aw-client-rust/src/lib.rs:150:5
    |
150 | /     pub async fn heartbeat(
151 | |         &self,
152 | |         bucketname: &str,
153 | |         event: &Event,
154 | |         pulsetime: f64,
155 | |     ) -> Result<(), reqwest::Error> {
    | |___________________________________^
help: consider using `Result::expect` to unwrap the `aw_client_rust::AwClient` value, panicking if the value is a `Result::Err`
    |
164 |                             if client.expect("REASON").heartbeat(&window_bucket, &window_event, HEARTBEAT_INTERVAL_MARGIN_S).is_err() {
    |                                      +++++++++++++++++

error[E0599]: no method named `heartbeat` found for enum `Result` in the current scope
   --> src/main.rs:176:31
    |
176 |                     if client.heartbeat(&afk_bucket, &afk_event, HEARTBEAT_INTERVAL_MARGIN_S).is_err() {
    |                               ^^^^^^^^^ method not found in `Result<AwClient, Box<dyn Error>>`
    |
note: the method `heartbeat` exists on the type `aw_client_rust::AwClient`
   --> HOME/.cargo/git/checkouts/aw-server-rust-880bcc5747287dac/1b56e03/aw-client-rust/src/lib.rs:150:5
    |
150 | /     pub async fn heartbeat(
151 | |         &self,
152 | |         bucketname: &str,
153 | |         event: &Event,
154 | |         pulsetime: f64,
155 | |     ) -> Result<(), reqwest::Error> {
    | |___________________________________^
help: consider using `Result::expect` to unwrap the `aw_client_rust::AwClient` value, panicking if the value is a `Result::Err`
    |
176 |                     if client.expect("REASON").heartbeat(&afk_bucket, &afk_event, HEARTBEAT_INTERVAL_MARGIN_S).is_err() {
    |                              +++++++++++++++++

error[E0599]: no method named `heartbeat` found for enum `Result` in the current scope
   --> src/main.rs:187:35
    |
187 |                         if client.heartbeat(&window_bucket, &window_event, HEARTBEAT_INTERVAL_MARGIN_S).is_err() {
    |                                   ^^^^^^^^^ method not found in `Result<AwClient, Box<dyn Error>>`
    |
note: the method `heartbeat` exists on the type `aw_client_rust::AwClient`
   --> HOME/.cargo/git/checkouts/aw-server-rust-880bcc5747287dac/1b56e03/aw-client-rust/src/lib.rs:150:5
    |
150 | /     pub async fn heartbeat(
151 | |         &self,
152 | |         bucketname: &str,
153 | |         event: &Event,
154 | |         pulsetime: f64,
155 | |     ) -> Result<(), reqwest::Error> {
    | |___________________________________^
help: consider using `Result::expect` to unwrap the `aw_client_rust::AwClient` value, panicking if the value is a `Result::Err`
    |
187 |                         if client.expect("REASON").heartbeat(&window_bucket, &window_event, HEARTBEAT_INTERVAL_MARGIN_S).is_err() {
    |                                  +++++++++++++++++

error[E0599]: no method named `heartbeat` found for enum `Result` in the current scope
   --> src/main.rs:194:31
    |
194 |                     if client.heartbeat(&afk_bucket, &afk_event, HEARTBEAT_INTERVAL_MARGIN_S).is_err() {
    |                               ^^^^^^^^^ method not found in `Result<AwClient, Box<dyn Error>>`
    |
note: the method `heartbeat` exists on the type `aw_client_rust::AwClient`
   --> HOME/.cargo/git/checkouts/aw-server-rust-880bcc5747287dac/1b56e03/aw-client-rust/src/lib.rs:150:5
    |
150 | /     pub async fn heartbeat(
151 | |         &self,
152 | |         bucketname: &str,
153 | |         event: &Event,
154 | |         pulsetime: f64,
155 | |     ) -> Result<(), reqwest::Error> {
    | |___________________________________^
help: consider using `Result::expect` to unwrap the `aw_client_rust::AwClient` value, panicking if the value is a `Result::Err`
    |
194 |                     if client.expect("REASON").heartbeat(&afk_bucket, &afk_event, HEARTBEAT_INTERVAL_MARGIN_S).is_err() {
    |                              +++++++++++++++++

Some errors have detailed explanations: E0308, E0599.
For more information about an error, try `rustc --explain E0308`.
warning: `aw-watcher-window-wayland` (bin "aw-watcher-window-wayland") generated 44 warnings
error: could not compile `aw-watcher-window-wayland` (bin "aw-watcher-window-wayland") due to 8 previous errors; 44 warnings emitted

For reference, Cargo.lock updated to Cargo.lock.txt

I am running on rustc 1.77.0 with rustup 1.27.0.

moreheadm commented 2 months ago

I've made it so the watcher will run without the idle functionality (i.e. window titles supported) on sway in #39.