Drop walker + elephant
This commit is contained in:
+45
-3
@@ -1,9 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy:summary=Prompt for text input with Walker
|
||||
# omarchy:summary=Prompt for text input from a menu
|
||||
# omarchy:group=menu
|
||||
# omarchy:name=input
|
||||
# omarchy:args=prompt [walker args...]
|
||||
# omarchy:args=prompt [menu args...]
|
||||
# omarchy:examples=omarchy menu input Reminder|omarchy-menu-input "Reminder in minutes" --width 400
|
||||
|
||||
set -euo pipefail
|
||||
@@ -13,4 +13,46 @@ if (( $# > 0 )); then
|
||||
shift
|
||||
fi
|
||||
|
||||
omarchy-launch-walker --dmenu --inputonly --width 295 --minheight 1 --maxheight 1 -p "$prompt…" "$@" 2>/dev/null
|
||||
menu_width=""
|
||||
|
||||
while (( $# > 0 )); do
|
||||
case "$1" in
|
||||
--width)
|
||||
shift
|
||||
if (( $# == 0 )); then
|
||||
echo "omarchy-menu-input: --width requires a value" >&2
|
||||
exit 1
|
||||
fi
|
||||
menu_width="$1"
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
selection_file=$(mktemp)
|
||||
done_file=$(mktemp)
|
||||
rm -f "$done_file"
|
||||
trap 'rm -f "$selection_file" "$done_file"' EXIT
|
||||
|
||||
payload=$(perl -MEncode=decode -MJSON::PP=encode_json -e '
|
||||
my $payload = {
|
||||
mode => "input",
|
||||
prompt => decode("UTF-8", $ARGV[0]),
|
||||
selectionFile => decode("UTF-8", $ARGV[1]),
|
||||
doneFile => decode("UTF-8", $ARGV[2])
|
||||
};
|
||||
$payload->{width} = int($ARGV[3]) if length($ARGV[3] // "");
|
||||
print encode_json($payload)
|
||||
' "$prompt" "$selection_file" "$done_file" "$menu_width")
|
||||
|
||||
omarchy-shell shell summon omarchy.menu "$payload" >/dev/null
|
||||
|
||||
while [[ ! -e $done_file ]]; do
|
||||
sleep 0.05
|
||||
done
|
||||
|
||||
if [[ -s $selection_file ]]; then
|
||||
cat "$selection_file"
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user