diff --git a/README.md b/README.md index cf60575..bef6354 100644 --- a/README.md +++ b/README.md @@ -60,9 +60,9 @@ Pass the wildcard "_" as the only argument and it will follow all monitors and o ``` ./hyprland-activewindow _ ``` -The output will be a json array of each monitors name and active window title. +The output will be a json array of each monitors name and the active window's title & initial title. ```json -[{"name":"eDP-1","title":"Alacritty"},{"name":"DP-1","title":"main.rs - hyprland-activewindow (Workspace) - VSCodium"}] +[{"initial_title":"Alacritty","name":"eDP-1","title":"~/hyprland-activewindow"},{"initial_title":"VSCodium","name":"DP-1","title":"main.rs - hyprland-activewindow (Workspace) - VSCodium"}] ``` This allows simplified Eww config similar to this: ```yuck diff --git a/src/main.rs b/src/main.rs index 3fa41e9..803e145 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,4 @@ -use hyprland::data::{Monitors, Workspaces}; +use hyprland::data::{Clients, Monitors, Workspaces}; use hyprland::event_listener::EventListenerMutable as EventListener; use hyprland::shared::HyprData; use hyprland::Result; @@ -25,6 +25,7 @@ ARGS: struct MonitorCustom { pub name: String, pub title: String, + pub initial_title: String, } struct WindowPrinter { @@ -63,14 +64,19 @@ impl WindowPrinter { let monitors = Monitors::get().expect("unable to get monitors"); let mut out_monitors: Vec = Vec::new(); for monitor in monitors { - let title = Workspaces::get() + let workspace = Workspaces::get() .expect("unable to get workspaces") .find(|w| w.id == monitor.active_workspace.id) - .unwrap() - .last_window_title; + .unwrap(); + let client = Clients::get() + .expect("unable to get clients") + .find(|c| c.address == workspace.last_window) + .unwrap(); + //.last_window_title;title let mc: MonitorCustom = MonitorCustom { name: monitor.name, - title, + title: client.title, + initial_title: client.initial_title, }; out_monitors.push(mc); }