Skip to content

Commit

Permalink
include initial title in advanced output
Browse files Browse the repository at this point in the history
  • Loading branch information
FieldofClay committed Feb 17, 2024
1 parent 6cab36c commit 39c2c81
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 11 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -25,6 +25,7 @@ ARGS:
struct MonitorCustom {
pub name: String,
pub title: String,
pub initial_title: String,
}

struct WindowPrinter {
Expand Down Expand Up @@ -63,14 +64,19 @@ impl WindowPrinter {
let monitors = Monitors::get().expect("unable to get monitors");
let mut out_monitors: Vec<MonitorCustom> = 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);
}
Expand Down

0 comments on commit 39c2c81

Please sign in to comment.