Compare commits
2 commits
4e2716cb46
...
fe6094b770
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fe6094b770 | ||
|
|
0b7b681e86 |
6 changed files with 42 additions and 10 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -1852,7 +1852,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "sway-de-utils"
|
name = "sway-de-utils"
|
||||||
version = "0.1.8"
|
version = "0.1.9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap",
|
"clap",
|
||||||
"clap_complete",
|
"clap_complete",
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "sway-de-utils"
|
name = "sway-de-utils"
|
||||||
version = "0.1.8"
|
version = "0.1.9"
|
||||||
authors = ["Penelope Gwen <support@pogmom.me>"]
|
authors = ["Penelope Gwen <support@pogmom.me>"]
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
license-file = "LICENSE.md"
|
license-file = "LICENSE.md"
|
||||||
|
|
|
||||||
6
debian/changelog
vendored
6
debian/changelog
vendored
|
|
@ -1,3 +1,9 @@
|
||||||
|
sway-de-utils (0.1.9-1) unstable; urgency=medium
|
||||||
|
|
||||||
|
* implement sdu profile list with json and dmenu modes
|
||||||
|
|
||||||
|
-- Penelope Gwen <support@pogmom.me> Tue, 27 Jan 2026 10:47:13 -0800
|
||||||
|
|
||||||
sway-de-utils (0.1.8-1) unstable; urgency=medium
|
sway-de-utils (0.1.8-1) unstable; urgency=medium
|
||||||
|
|
||||||
* (slightly) better error handling for power dialog absence
|
* (slightly) better error handling for power dialog absence
|
||||||
|
|
|
||||||
|
|
@ -56,12 +56,12 @@ pub enum ShortcutCommand {
|
||||||
#[clap(alias = "g")]
|
#[clap(alias = "g")]
|
||||||
Get {
|
Get {
|
||||||
#[arg(short, long)]
|
#[arg(short, long)]
|
||||||
mode: Option<ShortcutMode>,
|
mode: Option<DisplayMode>,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, ValueEnum, Subcommand)]
|
#[derive(Clone, Copy, ValueEnum, Subcommand)]
|
||||||
pub enum ShortcutMode {
|
pub enum DisplayMode {
|
||||||
/// Print formatted for dmenu/wofi
|
/// Print formatted for dmenu/wofi
|
||||||
#[clap(alias = "d")]
|
#[clap(alias = "d")]
|
||||||
Dmenu,
|
Dmenu,
|
||||||
|
|
@ -147,6 +147,12 @@ pub enum ProfileCommand {
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
shortcut_command: ShortcutCommand,
|
shortcut_command: ShortcutCommand,
|
||||||
},
|
},
|
||||||
|
/// List Profiles
|
||||||
|
#[clap(alias = "l")]
|
||||||
|
List {
|
||||||
|
#[arg(short, long)]
|
||||||
|
mode: Option<DisplayMode>,
|
||||||
|
},
|
||||||
/// Initialize Sway-DE-Utils
|
/// Initialize Sway-DE-Utils
|
||||||
#[clap(alias = "i")]
|
#[clap(alias = "i")]
|
||||||
Init,
|
Init,
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ use {
|
||||||
get_xdg_dirs,
|
get_xdg_dirs,
|
||||||
lib::{
|
lib::{
|
||||||
SDUError,
|
SDUError,
|
||||||
cli::{ProfileCommand, ProfileGetCommand, ProfileSwitchCommand},
|
cli::{DisplayMode, ProfileCommand, ProfileGetCommand, ProfileSwitchCommand},
|
||||||
get, get_sway_connection, run_sway_command, shortcuts_fn,
|
get, get_sway_connection, run_sway_command, shortcuts_fn,
|
||||||
sway::focused_workspace_profile,
|
sway::focused_workspace_profile,
|
||||||
},
|
},
|
||||||
|
|
@ -130,9 +130,28 @@ pub fn profile_fn(
|
||||||
.expect("could not find scripts for profile"),
|
.expect("could not find scripts for profile"),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
ProfileCommand::List { mode } => {
|
||||||
|
list_profiles(mode.unwrap_or(DisplayMode::Json), profiles_config)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO: Consolidate this function with print_shortcuts in shortcuts.rs
|
||||||
|
fn list_profiles(mode: DisplayMode, profiles: Vec<Profile>) -> Result<(), SDUError> {
|
||||||
|
let output = match mode {
|
||||||
|
DisplayMode::Dmenu => {
|
||||||
|
let mut dmenu_entries = Vec::<String>::new();
|
||||||
|
for profile in profiles {
|
||||||
|
dmenu_entries.push(format!("{} {}", profile.icon, profile.name));
|
||||||
|
}
|
||||||
|
dmenu_entries.join("\n")
|
||||||
|
}
|
||||||
|
DisplayMode::Json => json!(profiles).to_string(),
|
||||||
|
};
|
||||||
|
println!("{}", output);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
fn initialize(
|
fn initialize(
|
||||||
mut sway_connection: Connection,
|
mut sway_connection: Connection,
|
||||||
profile: Profile,
|
profile: Profile,
|
||||||
|
|
|
||||||
|
|
@ -5,21 +5,22 @@ use crate::{
|
||||||
config::ScriptConf,
|
config::ScriptConf,
|
||||||
lib::{
|
lib::{
|
||||||
SDUError,
|
SDUError,
|
||||||
cli::{ShortcutCommand, ShortcutMode},
|
cli::{DisplayMode, ShortcutCommand},
|
||||||
sway_ipc::{get_sway_connection, run_sway_command},
|
sway_ipc::{get_sway_connection, run_sway_command},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
fn print_shortcuts(mode: &ShortcutMode, shortcuts: Vec<ScriptConf>) -> String {
|
fn print_shortcuts(mode: &DisplayMode, shortcuts: Vec<ScriptConf>) -> String {
|
||||||
match mode {
|
match mode {
|
||||||
ShortcutMode::Dmenu => {
|
DisplayMode::Dmenu => {
|
||||||
let mut dmenu_entries = Vec::<String>::new();
|
let mut dmenu_entries = Vec::<String>::new();
|
||||||
for shortcut in shortcuts {
|
for shortcut in shortcuts {
|
||||||
dmenu_entries.push(format!("{} {}", shortcut.icon, shortcut.name));
|
dmenu_entries.push(format!("{} {}", shortcut.icon, shortcut.name));
|
||||||
}
|
}
|
||||||
|
//TODO: collect active profile information before returning it here?
|
||||||
dmenu_entries.join("\n")
|
dmenu_entries.join("\n")
|
||||||
}
|
}
|
||||||
ShortcutMode::Json => json!(shortcuts).to_string(),
|
DisplayMode::Json => json!(shortcuts).to_string(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -44,7 +45,7 @@ pub fn shortcuts_fn(
|
||||||
exec_shortcut(shortcut_name.to_string(), shortcuts)
|
exec_shortcut(shortcut_name.to_string(), shortcuts)
|
||||||
}
|
}
|
||||||
ShortcutCommand::Get { mode } => {
|
ShortcutCommand::Get { mode } => {
|
||||||
let shortcuts_string = print_shortcuts(&mode.unwrap_or(ShortcutMode::Json), shortcuts);
|
let shortcuts_string = print_shortcuts(&mode.unwrap_or(DisplayMode::Json), shortcuts);
|
||||||
println!("{}", shortcuts_string);
|
println!("{}", shortcuts_string);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue