add workspace monitor to bottom bar and remove waybar
This commit is contained in:
parent
089740ffaf
commit
a9525ec467
7 changed files with 144 additions and 22 deletions
63
Cargo.lock
generated
63
Cargo.lock
generated
|
@ -109,6 +109,15 @@ version = "1.2.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80"
|
||||
|
||||
[[package]]
|
||||
name = "bar-ws-monitor"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_json",
|
||||
"swayipc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.3.2"
|
||||
|
@ -782,6 +791,38 @@ version = "1.2.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.209"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "99fce0ffe7310761ca6bf9faf5115afbc19688edd00171d81b1bb1b116c63e09"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.209"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.127"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8043c06d9f82bd7271361ed64f415fe5e12a77fdb52e573e7f06a516dea329ad"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"memchr",
|
||||
"ryu",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "signal-hook"
|
||||
version = "0.3.17"
|
||||
|
@ -862,6 +903,28 @@ dependencies = [
|
|||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "swayipc"
|
||||
version = "3.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "daa5d19f881f372e225095e297072e2e3ee1c4e9e3a46cafe5f5cf70f1313f29"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_json",
|
||||
"swayipc-types",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "swayipc-types"
|
||||
version = "1.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e487a656336f74341c70a73a289f68d9ba3cab579ba776352ea0c6cdf603fcda"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_json",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.60"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[workspace]
|
||||
resolver = "2"
|
||||
members = [
|
||||
members = [ "programs/bar-ws-monitor",
|
||||
"programs/jrnl"
|
||||
]
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
(centerbox
|
||||
(box
|
||||
:halign "start"
|
||||
(label :text "left")
|
||||
(workspaceWidget)
|
||||
)
|
||||
(box
|
||||
:halign "center"
|
||||
|
@ -39,3 +39,19 @@
|
|||
)
|
||||
)
|
||||
)
|
||||
|
||||
(defwidget workspaceWidget []
|
||||
(box
|
||||
:class "workspaces"
|
||||
(for workspace in workspaces
|
||||
(button
|
||||
(label :markup "<span foreground=\"${workspace.urgent ? "#ff0000" : "#ffffff"}\" background=\"${workspace.focused ? "#383838" : "#282828"}\">${workspace.name}</span>")
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(deflisten workspaces
|
||||
:initial "[]"
|
||||
"bar-ws-monitor"
|
||||
)
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
def main [] {
|
||||
mut workspaces = waymsg -rt get_workspaces | from json | select name focused urgent;
|
||||
}
|
|
@ -26,22 +26,6 @@
|
|||
];
|
||||
};
|
||||
|
||||
programs.waybar = {
|
||||
enable = true;
|
||||
systemd = {
|
||||
enable = true;
|
||||
target = "sway-session.target";
|
||||
};
|
||||
settings = {
|
||||
interactiveBar = {
|
||||
layer = "top";
|
||||
position = "bottom";
|
||||
modules-left = ["sway/workspaces" "sway/mode"];
|
||||
modules-right = ["wlr/taskbar"];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
wayland.windowManager.sway = {
|
||||
enable = true;
|
||||
systemd = {
|
||||
|
@ -80,7 +64,7 @@
|
|||
};
|
||||
startup = [
|
||||
{
|
||||
command = "eww open topBar";
|
||||
command = "eww open topBar; eww open bottomBar";
|
||||
}
|
||||
{
|
||||
command = "pkill nm-applet; sleep 1 && nm-applet";
|
||||
|
|
9
programs/bar-ws-monitor/Cargo.toml
Normal file
9
programs/bar-ws-monitor/Cargo.toml
Normal file
|
@ -0,0 +1,9 @@
|
|||
[package]
|
||||
name = "bar-ws-monitor"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
serde = { version = "1.0.209", features = [ "derive" ] }
|
||||
serde_json = "1.0.127"
|
||||
swayipc = "3.0.2"
|
53
programs/bar-ws-monitor/src/main.rs
Normal file
53
programs/bar-ws-monitor/src/main.rs
Normal file
|
@ -0,0 +1,53 @@
|
|||
use core::panic;
|
||||
|
||||
use serde::Serialize;
|
||||
use swayipc::{Connection, Event, EventType, Fallible, Workspace, WorkspaceChange};
|
||||
|
||||
fn main() -> Fallible<()> {
|
||||
let mut con = Connection::new()?;
|
||||
let mut workspaces: Vec<WsData> = con
|
||||
.get_workspaces()?
|
||||
.into_iter()
|
||||
.map(|ws| ws.into())
|
||||
.collect();
|
||||
println!("{}", serde_json::ser::to_string(&workspaces).unwrap());
|
||||
|
||||
for ev in con.subscribe([EventType::Workspace])? {
|
||||
// the lazy/ugly solution!
|
||||
// we create a new connection and request workspaces again and again and again
|
||||
// TODO: properly handle events one by one
|
||||
let mut con = Connection::new()?;
|
||||
workspaces = con
|
||||
.get_workspaces()?
|
||||
.into_iter()
|
||||
.map(|ws| ws.into())
|
||||
.collect();
|
||||
println!("{}", serde_json::ser::to_string(&workspaces).unwrap());
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
struct WsData {
|
||||
name: String,
|
||||
focused: bool,
|
||||
urgent: bool,
|
||||
}
|
||||
|
||||
impl From<Workspace> for WsData {
|
||||
fn from(
|
||||
Workspace {
|
||||
name,
|
||||
focused,
|
||||
urgent,
|
||||
..
|
||||
}: Workspace,
|
||||
) -> Self {
|
||||
WsData {
|
||||
name,
|
||||
focused,
|
||||
urgent,
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue