From 33fe558b164c7de6aae7dc85382d8404f274b952 Mon Sep 17 00:00:00 2001 From: tdro Date: Mon, 23 Nov 2020 02:31:56 -0500 Subject: .local/bin/plumber-dmenu: Reduce start up time Go back to predefining options --- .local/bin/plumber | 18 ++++-------------- .local/bin/plumber-dmenu | 9 +++++++-- 2 files changed, 11 insertions(+), 16 deletions(-) (limited to '.local') diff --git a/.local/bin/plumber b/.local/bin/plumber index 71a19ad..74a51b1 100755 --- a/.local/bin/plumber +++ b/.local/bin/plumber @@ -6,31 +6,21 @@ defmodule ArgParser do System.argv() |> OptionParser.parse!(strict: [option: :string, text: :string]) - options = [ - "First letter of each word in sentence", #0 - "Single line of text", #1 - "Thesaurus", #2 - "KJV Verse Lookup" #3 - ] - cond do - opts[:option] == options |> Enum.at(0) -> + opts[:option] == "First letter of each word in sentence" -> TextPlumber.firstLetterOfWordsIn(opts[:text]) |> IO.binwrite() - opts[:option] == options |> Enum.at(1) -> + opts[:option] == "Single line of text" -> TextPlumber.singleLineOf(opts[:text]) |> IO.binwrite() - opts[:option] == options |> Enum.at(2) -> + opts[:option] == "Thesaurus" -> TextPlumber.synonymOfFirstWordIn(opts[:text]) TextPlumber.firstWordOf(opts[:text]) |> IO.binwrite() - opts[:option] == options |> Enum.at(3) -> + opts[:option] == "KJV Verse Lookup" -> System.cmd("urxvt", ["-e", "sh", "-c", "kjv #{TextPlumber.singleLineOf(opts[:text])}"]) TextPlumber.singleLineOf(opts[:text]) |> IO.binwrite() - opts[:option] == "list" -> - Enum.map(options, fn option -> IO.puts(option) end) - true -> "No plumber #{opts[:option] || "specified"}." |> IO.puts() end diff --git a/.local/bin/plumber-dmenu b/.local/bin/plumber-dmenu index 46dae74..d7ece41 100755 --- a/.local/bin/plumber-dmenu +++ b/.local/bin/plumber-dmenu @@ -1,6 +1,11 @@ #!/bin/sh -eu -plumber --option list \ - | dmenu -i -b \ +options="First letter of each word in sentence +Single line of text +Thesaurus +KJV Verse Lookup +" +printf "%s" "$options" \ + | dmenu -i -b -p Plumb \ | while read -r option do text=$(plumber --option "$option" --text "$(xsel -o)") -- cgit v1.2.3