aboutsummaryrefslogtreecommitdiff
path: root/.local
diff options
context:
space:
mode:
authortdro <tdro@users.noreply.github.com>2020-11-19 22:28:03 -0500
committertdro <tdro@users.noreply.github.com>2020-11-19 22:48:37 -0500
commit6050c129bc7a1d87de51dde1e3c44c4e5f01d159 (patch)
treeda7a5e49d8d71a3f7f45b89976b7944438585f08 /.local
parent48b5b89dbe0d0ae68fafb3b38e5a3f90ed3cab76 (diff)
downloaddotfiles-6050c129bc7a1d87de51dde1e3c44c4e5f01d159.tar.gz
dotfiles-6050c129bc7a1d87de51dde1e3c44c4e5f01d159.tar.bz2
dotfiles-6050c129bc7a1d87de51dde1e3c44c4e5f01d159.zip
.local/bin/plumber: Add crude text plumber
Diffstat (limited to '.local')
-rwxr-xr-x.local/bin/plumber34
-rwxr-xr-x.local/bin/plumber-dmenu11
2 files changed, 45 insertions, 0 deletions
diff --git a/.local/bin/plumber b/.local/bin/plumber
new file mode 100755
index 0000000..0c575b9
--- /dev/null
+++ b/.local/bin/plumber
@@ -0,0 +1,34 @@
+#! /usr/bin/env elixir
+
+defmodule ArgParser do
+ def parse do
+ {opts, _} =
+ System.argv()
+ |> OptionParser.parse!(strict: [option: :string, text: :string])
+
+ cond do
+ opts[:option] == "First letter of each word in sentence" ->
+ TextPlumber.firstLetterOfWordsIn(opts[:text])
+
+ opts[:option] == "Single line of text" ->
+ TextPlumber.singleLineOf(opts[:text])
+
+ true ->
+ "No plumber specified #{opts[:option]}" |> IO.puts()
+ end
+ end
+end
+
+defmodule TextPlumber do
+ def firstLetterOfWordsIn(text) do
+ String.replace(text, ~r/(\w)\w*/, "\\1", global: true)
+ |> String.replace(~r/\s\s+/, " ", global: true)
+ |> IO.puts()
+ end
+
+ def singleLineOf(text) do
+ String.replace(text, "\n", "") |> IO.puts()
+ end
+end
+
+ArgParser.parse()
diff --git a/.local/bin/plumber-dmenu b/.local/bin/plumber-dmenu
new file mode 100755
index 0000000..431bbb7
--- /dev/null
+++ b/.local/bin/plumber-dmenu
@@ -0,0 +1,11 @@
+#!/bin/sh -eu
+options="First letter of each word in sentence
+Single line of text
+"
+printf "%s" "$options" \
+ | dmenu -i -b \
+ | while read -r option
+ do
+ text=$(plumber --option "$option" --text "$(xsel -o)")
+ notify-send "$text" && printf "%s" "$text" | xsel -ib
+ done