From 7b840fa8572c64f4a75ecf6bb70a2d868de782f5 Mon Sep 17 00:00:00 2001 From: tdro Date: Mon, 23 Nov 2020 00:09:25 -0500 Subject: .local/bin/plumber-dmenu: Get options from plumber --- .local/bin/plumber | 20 +++++++++++++++----- .local/bin/plumber-dmenu | 7 +------ 2 files changed, 16 insertions(+), 11 deletions(-) (limited to '.local') diff --git a/.local/bin/plumber b/.local/bin/plumber index 0fbae36..71a19ad 100755 --- a/.local/bin/plumber +++ b/.local/bin/plumber @@ -6,23 +6,33 @@ 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] == "First letter of each word in sentence" -> + opts[:option] == options |> Enum.at(0) -> TextPlumber.firstLetterOfWordsIn(opts[:text]) |> IO.binwrite() - opts[:option] == "Single line of text" -> + opts[:option] == options |> Enum.at(1) -> TextPlumber.singleLineOf(opts[:text]) |> IO.binwrite() - opts[:option] == "Thesaurus" -> + opts[:option] == options |> Enum.at(2) -> TextPlumber.synonymOfFirstWordIn(opts[:text]) TextPlumber.firstWordOf(opts[:text]) |> IO.binwrite() - opts[:option] == "KJV Verse Lookup" -> + opts[:option] == options |> Enum.at(3) -> 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 specified #{opts[:option]}" |> IO.puts() + "No plumber #{opts[:option] || "specified"}." |> IO.puts() end end end diff --git a/.local/bin/plumber-dmenu b/.local/bin/plumber-dmenu index a4eda59..46dae74 100755 --- a/.local/bin/plumber-dmenu +++ b/.local/bin/plumber-dmenu @@ -1,10 +1,5 @@ #!/bin/sh -eu -options="First letter of each word in sentence -Single line of text -Thesaurus -KJV Verse Lookup -" -printf "%s" "$options" \ +plumber --option list \ | dmenu -i -b \ | while read -r option do -- cgit v1.2.3