I should test my code before releases

This commit is contained in:
Penelope Gwen 2026-01-22 12:36:29 -08:00
parent 1d5202e818
commit 2d630af082
2 changed files with 25 additions and 13 deletions

View file

@ -3,16 +3,30 @@ use {
config::{Profile, WindowIcon},
lib::{
cli::{SwayCommand, SwayGetCommand},
get_scratchpad_info, get_window_info, get_workspace_info,
profile::{active_profile_index, profile_from_index},
get_scratchpad_info, get_sway_connection, get_window_info, get_workspace_info,
profile::profile_from_index,
sway_ipc::{self, get_sway_info},
},
utils::SDUError,
},
log::debug,
serde_json::json,
swayipc::EventType,
};
pub fn focused_workspace_profile(profiles: Vec<Profile>) -> Profile {
let focused_ws_index = get_sway_connection()
.get_workspaces()
.expect("unable to parse workspaces")
.iter()
.find(|w| w.focused)
.map(|w| w.num)
.unwrap_or_default() as usize
/ 10;
debug!("found profile {:?} for focused workspace", focused_ws_index);
profile_from_index(profiles, focused_ws_index)
}
pub fn sway_fn(
sway_command: &SwayCommand,
window_icons: &[WindowIcon],
@ -30,10 +44,9 @@ 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()
)),
SwayGetCommand::WorkspaceProfile => {
json!(focused_workspace_profile(profile_list.clone()))
}
};
println!("{}", sway_json);
let _: () = if monitor.unwrap_or_default() {

View file

@ -2,11 +2,8 @@ use {
crate::{
config::{Profile, WindowIcon},
lib::{
cli::SwayGetCommand,
get_scratchpad_info,
profile::{active_profile_index, profile_from_index},
windows::get_window_info,
workspaces::get_workspace_info,
cli::SwayGetCommand, get_scratchpad_info, sway::focused_workspace_profile,
windows::get_window_info, workspaces::get_workspace_info,
},
utils::SDUError,
},
@ -49,7 +46,7 @@ pub fn get_sway_info(
let window_info = get_window_info(window_icons);
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 workspace_profile = json!(focused_workspace_profile(profile_list.clone()));
let full_info = SwayInfo {
window_info,
workspace_info,
@ -78,7 +75,9 @@ 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!(),
SwayGetCommand::WorkspaceProfile => {
json!(focused_workspace_profile(profile_list.clone()))
}
},
_ => unreachable!(),
};