From 8cd4674c15cbc22eae5a147f19d9399664863960 Mon Sep 17 00:00:00 2001 From: Tassilo Horn Date: Thu, 21 Jan 2021 21:48:56 +0100 Subject: [PATCH] Add command line options --- src/bin/swayr.rs | 26 +++++++++++++++++++++++++- src/util.rs | 1 + 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/bin/swayr.rs b/src/bin/swayr.rs index 8bad2f7..ae5aa85 100644 --- a/src/bin/swayr.rs +++ b/src/bin/swayr.rs @@ -1,5 +1,29 @@ +extern crate clap; +use clap::Clap; use swayr::client; +/// Windows are sorted so that urgent windows come first, then windows in +/// last-recently-used order, and the focused window last. +#[derive(Clap)] +#[clap( + name = "swayr -- a window switcher for sway", + version = option_env!("CARGO_PKG_VERSION").unwrap_or(""), + author = "Tassilo Horn " +)] +struct Opts { + #[clap(subcommand)] + command: SwayrCommand, +} + +#[derive(Clap)] +enum SwayrCommand { + /// Switch window using wofi (urgent first, then LRU order, focused last) + SwitchWindow, +} + fn main() { - client::switch_window(); + let opts: Opts = Opts::parse(); + match opts.command { + SwayrCommand::SwitchWindow => client::switch_window(), + } } diff --git a/src/util.rs b/src/util.rs index 7d7867d..433480b 100644 --- a/src/util.rs +++ b/src/util.rs @@ -52,6 +52,7 @@ where .arg("--allow-markup") .arg("--allow-images") .arg("--insensitive") + .arg("--cache-file=/dev/null") .arg("--prompt") .arg(prompt) .stdin(proc::Stdio::piped())