fix sdu launch logic

This commit is contained in:
Penelope Gwen 2026-01-26 16:26:24 -08:00
parent 416ee4b5d3
commit 4e2716cb46
5 changed files with 21 additions and 19 deletions

2
Cargo.lock generated
View file

@ -1852,7 +1852,7 @@ dependencies = [
[[package]] [[package]]
name = "sway-de-utils" name = "sway-de-utils"
version = "0.1.7" version = "0.1.8"
dependencies = [ dependencies = [
"clap", "clap",
"clap_complete", "clap_complete",

View file

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

7
debian/changelog vendored
View file

@ -1,3 +1,10 @@
sway-de-utils (0.1.8-1) unstable; urgency=medium
* (slightly) better error handling for power dialog absence
* fix logic behind sdu launch profile detection
-- Penelope Gwen <support@pogmom.me> Sat, 24 Jan 2026 12:48:02 -0800
sway-de-utils (0.1.7-1) unstable; urgency=medium sway-de-utils (0.1.7-1) unstable; urgency=medium
* implement shell completions for bash, fish, zsh * implement shell completions for bash, fish, zsh

View file

@ -4,7 +4,7 @@ use log::debug;
use crate::{ use crate::{
config::{Profile, Programs}, config::{Profile, Programs},
lib::{SDUError, get_sway_connection, profile::active_profile, run_sway_command}, lib::{SDUError, get_sway_connection, run_sway_command, sway::focused_workspace_profile},
}; };
pub fn launch( pub fn launch(
@ -38,22 +38,17 @@ pub fn profile_launch(
Some(p) => { Some(p) => {
let mut swaymsg_command = format!("exec {}", p.1.command); let mut swaymsg_command = format!("exec {}", p.1.command);
swaymsg_command = append_arguments(swaymsg_command, p.1.arguments.clone()); swaymsg_command = append_arguments(swaymsg_command, p.1.arguments.clone());
match active_profile(profiles) { let profile = focused_workspace_profile(profiles);
Ok(profile) => { debug!("{:#?}", profile);
println!("{:#?}", profile); if let Some(profile_args) = profile
if let Some(profile_args) = profile .program_args
.program_args .unwrap_or_default()
.unwrap_or_default() .iter()
.iter() .find(|x| x.0.eq(p.0))
.find(|x| x.0.eq(p.0)) {
{ swaymsg_command = append_arguments(swaymsg_command, profile_args.1.to_owned());
swaymsg_command =
append_arguments(swaymsg_command, profile_args.1.to_owned());
}
Ok(swaymsg_command)
}
Err(e) => Err(e),
} }
Ok(swaymsg_command)
} }
None => Err(SDUError { None => Err(SDUError {
message: String::from("No matching program found"), message: String::from("No matching program found"),

View file

@ -273,7 +273,7 @@ pub fn active_profile_index() -> usize {
} }
} }
pub fn active_profile(profiles: Vec<Profile>) -> Result<Profile, SDUError> { pub fn _active_profile(profiles: Vec<Profile>) -> Result<Profile, SDUError> {
match profiles.get(active_profile_index()) { match profiles.get(active_profile_index()) {
Some(p) => Ok(p.clone()), Some(p) => Ok(p.clone()),
None => Err(SDUError { None => Err(SDUError {