Initial pass at getting all the scripts and menus working with the new everything in home setup. Also unify speech settings. Not sure why I thought separate speech settings for all menus was a good idea lol.
This commit is contained in:
@@ -5,15 +5,13 @@
|
||||
|
||||
# The next line has been commented because if there's nothing in clipboard the script breaks.
|
||||
# set -Eeuo pipefail # https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/#:~:text=set%20%2Du,is%20often%20highly%20desirable%20behavior.
|
||||
shopt -s expand_aliases
|
||||
|
||||
if [[ $# -ne 2 ]]; then
|
||||
echo "Usage: $0 \"application name\" \"file name\"."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Wait for the application to start
|
||||
while ! pgrep -u "$USER" ^$1 &> /dev/null ; do
|
||||
while ! pgrep -u "$USER" "^$1" &> /dev/null ; do
|
||||
sleep 0.05
|
||||
done
|
||||
|
||||
@@ -56,7 +54,7 @@ insert_database() {
|
||||
}
|
||||
|
||||
# Read so long as the application is running
|
||||
while pgrep -u "$USER" ^$1 &> /dev/null ; do
|
||||
while pgrep -u "$USER" "^$1" &> /dev/null ; do
|
||||
sleep 0.05
|
||||
text="$(xclip -d "${DISPLAY:-:0}" -selection clipboard -o 2> /dev/null)"
|
||||
if [[ -f ~/.agmsilent ]]; then
|
||||
@@ -73,12 +71,19 @@ while pgrep -u "$USER" ^$1 &> /dev/null ; do
|
||||
|
||||
# https://en.wikipedia.org/wiki/Unicode_equivalence#Combining_and_precomposed_characters
|
||||
# https://www.effectiveperlprogramming.com/2011/09/normalize-your-perl-source/
|
||||
alias nfc="perl -MUnicode::Normalize -CS -ne 'print NFC(\$_)'" # composed characters
|
||||
nfc() {
|
||||
perl -MUnicode::Normalize -CS -ne 'print NFC($_)'
|
||||
}
|
||||
|
||||
# Normalize different unicode space characters to the same space
|
||||
# https://stackoverflow.com/a/43640405
|
||||
alias normalize_spaces="perl -CSDA -plE 's/[^\\S\\t]/ /g'"
|
||||
alias normalize_unicode="normalize_spaces | nfc"
|
||||
normalize_spaces() {
|
||||
perl -CSDA -plE 's/[^\S\t]/ /g'
|
||||
}
|
||||
|
||||
normalize_unicode() {
|
||||
normalize_spaces | nfc
|
||||
}
|
||||
|
||||
# Normalize text
|
||||
normalized_text="$(echo "$text" | normalize_unicode)"
|
||||
|
||||
Reference in New Issue
Block a user