add retrieval of current workspace profile information

This commit is contained in:
Penelope Gwen 2026-01-22 12:05:02 -08:00
parent f3ec8c769e
commit 1d5202e818
7 changed files with 31 additions and 8 deletions

2
Cargo.lock generated
View file

@ -1827,7 +1827,7 @@ dependencies = [
[[package]]
name = "sway-de-utils"
version = "0.1.4"
version = "0.1.5"
dependencies = [
"clap",
"confy",

View file

@ -1,6 +1,6 @@
[package]
name = "sway-de-utils"
version = "0.1.4"
version = "0.1.5"
authors = ["Penelope Gwen <support@pogmom.me>"]
edition = "2024"
license-file = "LICENSE.md"

6
debian/changelog vendored
View file

@ -1,3 +1,9 @@
sway-de-utils (0.1.5-1) unstable; urgency=medium
* add retrieval of current workspace profile information
-- Penelope Gwen <support@pogmom.me> Thu, 22 Jan 2026 12:03:40 -0800
sway-de-utils (0.1.4-1) unstable; urgency=medium
* finish scratchpad implementation for real

View file

@ -106,7 +106,7 @@ pub enum SwayCommand {
}
#[derive(Subcommand)]
pub enum SwayGetCommand {
/// Get Workspace Information
/// Get Workspaces Information
#[clap(alias = "ws")]
Workspaces,
/// Get Window Information
@ -115,6 +115,9 @@ pub enum SwayGetCommand {
/// Get Scratchpad Information
#[clap(alias = "s")]
Scratchpad,
/// Get Active Workspace Profile
#[clap(alias = "p")]
WorkspaceProfile,
/// Get Window and Workspace Information in one JSON output
#[clap(alias = "f")]
Full,

View file

@ -42,7 +42,6 @@ fn node_finder(mut node: Node) -> Option<Vec<Node>> {
node.nodes.append(&mut node.floating_nodes);
for node in node.nodes {
if let Some(mut nodes) = node_finder(node) {
node_list.append(&mut nodes);
}
}
@ -80,7 +79,7 @@ pub fn get_scratchpad_info() -> Value {
.iter()
.filter_map(|x| node_finder(x.clone()))
.flatten()
.map(|node| scratchpad_strip(node))
.map(scratchpad_strip)
.collect();
scratchpad_windows.sort_by(|x, y| x.window_id.cmp(&y.window_id));
debug!(

View file

@ -4,10 +4,12 @@ use {
lib::{
cli::{SwayCommand, SwayGetCommand},
get_scratchpad_info, get_window_info, get_workspace_info,
profile::{active_profile_index, profile_from_index},
sway_ipc::{self, get_sway_info},
},
utils::SDUError,
},
serde_json::json,
swayipc::EventType,
};
@ -28,11 +30,17 @@ pub fn sway_fn(
SwayGetCommand::Window => get_window_info(window_icons),
SwayGetCommand::Full => get_sway_info(window_icons, profile_list.clone(), kb_order),
SwayGetCommand::Scratchpad => get_scratchpad_info(),
SwayGetCommand::WorkspaceProfile => json!(profile_from_index(
profile_list.clone(),
active_profile_index()
)),
};
println!("{}", sway_json);
let _: () = if monitor.unwrap_or_default() {
let event_monitors = match requested_info {
SwayGetCommand::Workspaces => vec![EventType::Workspace],
SwayGetCommand::Workspaces | SwayGetCommand::WorkspaceProfile => {
vec![EventType::Workspace]
}
SwayGetCommand::Scratchpad => vec![EventType::Window],
SwayGetCommand::Window | SwayGetCommand::Full => {
vec![EventType::Window, EventType::Workspace]

View file

@ -2,7 +2,10 @@ use {
crate::{
config::{Profile, WindowIcon},
lib::{
cli::SwayGetCommand, get_scratchpad_info, windows::get_window_info,
cli::SwayGetCommand,
get_scratchpad_info,
profile::{active_profile_index, profile_from_index},
windows::get_window_info,
workspaces::get_workspace_info,
},
utils::SDUError,
@ -18,6 +21,7 @@ pub struct SwayInfo {
window_info: Value,
workspace_info: Value,
scratchpad_info: Value,
workspace_profile: Value,
}
pub fn get_sway_connection() -> Connection {
@ -43,12 +47,14 @@ pub fn get_sway_info(
kb_order: bool,
) -> Value {
let window_info = get_window_info(window_icons);
let workspace_info = get_workspace_info(profile_list, kb_order);
let workspace_info = get_workspace_info(profile_list.clone(), kb_order);
let scratchpad_info = get_scratchpad_info();
let workspace_profile = json!(profile_from_index(profile_list, active_profile_index()));
let full_info = SwayInfo {
window_info,
workspace_info,
scratchpad_info,
workspace_profile,
};
json!(full_info)
}
@ -72,6 +78,7 @@ pub fn monitor_events(
SwayGetCommand::Workspaces => get_workspace_info(profile_list.clone(), kb_order),
SwayGetCommand::Full => get_sway_info(window_icons, profile_list.clone(), kb_order),
SwayGetCommand::Scratchpad => get_scratchpad_info(),
SwayGetCommand::WorkspaceProfile => todo!(),
},
_ => unreachable!(),
};