# window.Window.last_activity

- **Module:** window.Window
- **Package:** libtmux
- **Language:** Rust
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-rs/blob/f0e37052c232636b61d095817046e6bfc8f2ca40/crates/libtmux/src/window.rs#L294
- **Page:** https://libtmux.org/en/rs/latest/reference/window-window-last_activity/

```
window.Window.last_activity(self) -> SystemTime
```

Return when the window last produced output.

tmux stamps this on every byte a pane in the window writes, whatever
the window options say. That is what separates it from
[`Self::has_activity`], which is an alert and stays false unless
`monitor-activity` was turned on -- and it is off by default.

tmux keeps whole seconds. `WindowFields::window_activity` filters and
reads the same field as the `i64` of Unix seconds tmux reports, because
the query grammar compares integers.

## Example

```rust
use std::time::{Duration, SystemTime};

let guard = libtmux::test::TestServer::new().await?;
let session = guard.server().new_session("busy").await?;
let window = session.active_window().await?.expect("a window");

// A window that has just been made has already produced output.
let idle = SystemTime::now().duration_since(window.last_activity())?;
assert!(idle < Duration::from_secs(3600));

guard.shutdown().await?;
```
