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]]
|
||||
name = "sway-de-utils"
|
||||
version = "0.1.8"
|
||||
version = "0.1.9"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"clap_complete",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "sway-de-utils"
|
||||
version = "0.1.8"
|
||||
version = "0.1.9"
|
||||
authors = ["Penelope Gwen <support@pogmom.me>"]
|
||||
edition = "2024"
|
||||
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
|
||||
|
||||
* (slightly) better error handling for power dialog absence
|
||||
|
|
|
|||
|
|
@ -56,12 +56,12 @@ pub enum ShortcutCommand {
|
|||
#[clap(alias = "g")]
|
||||
Get {
|
||||
#[arg(short, long)]
|
||||
mode: Option<ShortcutMode>,
|
||||
mode: Option<DisplayMode>,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, ValueEnum, Subcommand)]
|
||||
pub enum ShortcutMode {
|
||||
pub enum DisplayMode {
|
||||
/// Print formatted for dmenu/wofi
|
||||
#[clap(alias = "d")]
|
||||
Dmenu,
|
||||
|
|
@ -147,6 +147,12 @@ pub enum ProfileCommand {
|
|||
#[command(subcommand)]
|
||||
shortcut_command: ShortcutCommand,
|
||||
},
|
||||
/// List Profiles
|
||||
#[clap(alias = "l")]
|
||||
List {
|
||||
#[arg(short, long)]
|
||||
mode: Option<DisplayMode>,
|
||||
},
|
||||
/// Initialize Sway-DE-Utils
|
||||
#[clap(alias = "i")]
|
||||
Init,
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use {
|
|||
get_xdg_dirs,
|
||||
lib::{
|
||||
SDUError,
|
||||
cli::{ProfileCommand, ProfileGetCommand, ProfileSwitchCommand},
|
||||
cli::{DisplayMode, ProfileCommand, ProfileGetCommand, ProfileSwitchCommand},
|
||||
get, get_sway_connection, run_sway_command, shortcuts_fn,
|
||||
sway::focused_workspace_profile,
|
||||
},
|
||||
|
|
@ -130,8 +130,27 @@ pub fn profile_fn(
|
|||
.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(
|
||||
mut sway_connection: Connection,
|
||||
|
|
|
|||
|
|
@ -5,21 +5,22 @@ use crate::{
|
|||
config::ScriptConf,
|
||||
lib::{
|
||||
SDUError,
|
||||
cli::{ShortcutCommand, ShortcutMode},
|
||||
cli::{DisplayMode, ShortcutCommand},
|
||||
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 {
|
||||
ShortcutMode::Dmenu => {
|
||||
DisplayMode::Dmenu => {
|
||||
let mut dmenu_entries = Vec::<String>::new();
|
||||
for shortcut in shortcuts {
|
||||
dmenu_entries.push(format!("{} {}", shortcut.icon, shortcut.name));
|
||||
}
|
||||
//TODO: collect active profile information before returning it here?
|
||||
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)
|
||||
}
|
||||
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);
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue