diff options
Diffstat (limited to 'unused')
| -rwxr-xr-x | unused/dmenu-mail-aliases | 29 | ||||
| -rwxr-xr-x | unused/dmenu-websearch | 8 | ||||
| -rwxr-xr-x | unused/practice | 170 | ||||
| -rwxr-xr-x | unused/translate | 11 | ||||
| -rwxr-xr-x | unused/websearch | 11 | ||||
| -rwxr-xr-x | unused/xplumb | 65 |
6 files changed, 294 insertions, 0 deletions
diff --git a/unused/dmenu-mail-aliases b/unused/dmenu-mail-aliases new file mode 100755 index 0000000..76999de --- /dev/null +++ b/unused/dmenu-mail-aliases | |||
| @@ -0,0 +1,29 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # Select mail alias via dmenu | ||
| 4 | # The email address must be the second word in a line of $aliasfile | ||
| 5 | # Requires: dmenu (or similar) | ||
| 6 | |||
| 7 | # Usage: dmenu-mail-aliases [-m menu] | ||
| 8 | |||
| 9 | usage() { | ||
| 10 | echo "Usage: dmenu-mail-aliases [-m MENU]" | ||
| 11 | } | ||
| 12 | |||
| 13 | menu="dmenu -l 20" | ||
| 14 | aliasfile="$HOME/.mblaze/aliases" | ||
| 15 | |||
| 16 | while getopts "m:" opt; do | ||
| 17 | case "$opt" in | ||
| 18 | m) | ||
| 19 | menu="$OPTARG" | ||
| 20 | ;; | ||
| 21 | *) | ||
| 22 | usage | ||
| 23 | exit 1 | ||
| 24 | ;; | ||
| 25 | esac | ||
| 26 | done | ||
| 27 | shift $((OPTIND - 1)) | ||
| 28 | |||
| 29 | $menu <"$aliasfile" | awk '{print $NF}' | ||
diff --git a/unused/dmenu-websearch b/unused/dmenu-websearch new file mode 100755 index 0000000..a8e6a50 --- /dev/null +++ b/unused/dmenu-websearch | |||
| @@ -0,0 +1,8 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # dmenu prompt for websearch | ||
| 4 | # Requires: dmenu (or similar), websearch | ||
| 5 | |||
| 6 | menu=${MENU:-dmenu} | ||
| 7 | |||
| 8 | websearch "$(echo "" | $menu -p "websearch:")" | ||
diff --git a/unused/practice b/unused/practice new file mode 100755 index 0000000..628f15b --- /dev/null +++ b/unused/practice | |||
| @@ -0,0 +1,170 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # Script based on nissy (see https://nissy.tronto.net) to practice FMC | ||
| 4 | |||
| 5 | # Usage: practice [eo|dr|htr|slice] | ||
| 6 | |||
| 7 | nissy="nissy" | ||
| 8 | prompt="Press enter for a new scramble, Ctr+C (or Ctrl+Z) to quit:" | ||
| 9 | |||
| 10 | usage() { | ||
| 11 | echo "Usage: practice [eo|dr|htr|fin]" | ||
| 12 | exit 1 | ||
| 13 | } | ||
| 14 | |||
| 15 | practice_eo() { | ||
| 16 | nextscr="$(${nissy} scramble fmc)" | ||
| 17 | while true; do | ||
| 18 | scr="$nextscr" | ||
| 19 | echo "Scramble: $scr" | ||
| 20 | nextscr="$(${nissy} scramble fmc)" | ||
| 21 | eofb="$(${nissy} solve -N -M 4 eofb -p "$scr")" | ||
| 22 | eorl="$(${nissy} solve -N -M 4 eorl -p "$scr")" | ||
| 23 | eoud="$(${nissy} solve -N -M 4 eoud -p "$scr")" | ||
| 24 | nfbn="$(echo "$eofb" | grep -v '^$' | grep -Fv '(' | wc -l)" | ||
| 25 | nrln="$(echo "$eorl" | grep -v '^$' | grep -Fv '(' | wc -l)" | ||
| 26 | nudn="$(echo "$eoud" | grep -v '^$' | grep -Fv '(' | wc -l)" | ||
| 27 | nfbi="$(echo "$eofb" | grep '^(' | wc -l)" | ||
| 28 | nrli="$(echo "$eorl" | grep '^(' | wc -l)" | ||
| 29 | nudi="$(echo "$eoud" | grep '^(' | wc -l)" | ||
| 30 | nfbniss="$(echo "$eofb" | grep -v '^(' | grep '(' | wc -l)" | ||
| 31 | nrlniss="$(echo "$eorl" | grep -v '^(' | grep '(' | wc -l)" | ||
| 32 | nudniss="$(echo "$eoud" | grep -v '^(' | grep '(' | wc -l)" | ||
| 33 | nfb="$((nfbn + nfbi + nfbniss))" | ||
| 34 | nrl="$((nrln + nrli + nrlniss))" | ||
| 35 | nud="$((nudn + nudi + nudniss))" | ||
| 36 | n5linear="$(${nissy} solve -L -m 5 -M 5 eo -c "$scr")" | ||
| 37 | n5niss="$(${nissy} solve -N -m 5 -M 5 eo -c "$scr")" | ||
| 38 | n5nonlinear="$((n5niss - n5linear))" | ||
| 39 | read -r x | ||
| 40 | echo "FB: $nfb ($nfbn normal, $nfbi inverse, $nfbniss niss)" | ||
| 41 | echo "RL: $nrl ($nrln normal, $nrli inverse, $nrlniss niss)" | ||
| 42 | echo "UD: $nud ($nudn normal, $nudi inverse, $nudniss niss)" | ||
| 43 | echo "5 movers: $n5linear linear, $n5nonlinear NISS'd" | ||
| 44 | read -r x | ||
| 45 | echo "$eofb" | ||
| 46 | echo "---" | ||
| 47 | echo "$eorl" | ||
| 48 | echo "---" | ||
| 49 | echo "$eoud" | ||
| 50 | printf '\n%s' "$prompt" | ||
| 51 | read -r x | ||
| 52 | done | ||
| 53 | } | ||
| 54 | |||
| 55 | practice_dr() { | ||
| 56 | nextscr="$(${nissy} scramble eo)" | ||
| 57 | while true; do | ||
| 58 | scr="$nextscr" | ||
| 59 | echo "Scramble: $scr" | ||
| 60 | nextscr="$(${nissy} scramble eo)" | ||
| 61 | soleo="$(${nissy} solve -o -p drud-eofb "$scr")" | ||
| 62 | neo="$(echo "$soleo" | grep -v '^$' | wc -l)" | ||
| 63 | leo="$(echo "$soleo" | head -n 1 | wc -w)" | ||
| 64 | solht="$(${nissy} solve -o -p drud "$scr")" | ||
| 65 | nht="$(echo "$solht" | grep -v '^$' | wc -l)" | ||
| 66 | lht="$(echo "$solht" | head -n 1 | wc -w)" | ||
| 67 | soleolr="$(${nissy} solve -o -p drrl-eofb "$scr")" | ||
| 68 | neolr="$(echo "$soleolr" | grep -v '^$' | wc -l)" | ||
| 69 | leolr="$(echo "$soleolr" | head -n 1 | wc -w)" | ||
| 70 | solhtlr="$(${nissy} solve -o -p drrl "$scr")" | ||
| 71 | nhtlr="$(echo "$solhtlr" | grep -v '^$' | wc -l)" | ||
| 72 | lhtlr="$(echo "$solhtlr" | head -n 1 | wc -w)" | ||
| 73 | read -r x | ||
| 74 | echo "DR on U/D: $leo moves ($neo solutions)" | ||
| 75 | if [ "$nht" != "$neo" ]; then | ||
| 76 | echo "Breaking EO: $lht moves ($nht solutions)" | ||
| 77 | fi | ||
| 78 | echo "DR on R/L: $leolr moves ($neolr solutions)" | ||
| 79 | if [ "$nhtlr" != "$neolr" ]; then | ||
| 80 | echo "Breaking EO: $lhtlr moves ($nhtlr solutions)" | ||
| 81 | fi | ||
| 82 | read -r x | ||
| 83 | echo "On U/D:" | ||
| 84 | echo "$soleo" | ||
| 85 | echo "" | ||
| 86 | if [ "$nht" != "$neo" ] || [ "$lht" != "$leo" ]; then | ||
| 87 | echo "Breaking EO:" | ||
| 88 | echo "$solht" | ||
| 89 | echo "" | ||
| 90 | fi | ||
| 91 | echo "On R/L:" | ||
| 92 | echo "$soleolr" | ||
| 93 | echo "" | ||
| 94 | if [ "$nhtlr" != "$neolr" ] || [ "$lhtlr" != "$leolr" ]; then | ||
| 95 | echo "Breaking EO:" | ||
| 96 | echo "$solhtlr" | ||
| 97 | echo "" | ||
| 98 | fi | ||
| 99 | printf '\n%s' "$prompt" | ||
| 100 | read -r x | ||
| 101 | done | ||
| 102 | } | ||
| 103 | |||
| 104 | practice_htr() { | ||
| 105 | nextscr="$(${nissy} scramble dr)" | ||
| 106 | while true; do | ||
| 107 | scr="$nextscr" | ||
| 108 | echo "Scramble: $scr" | ||
| 109 | nextscr="$(${nissy} scramble dr)" | ||
| 110 | sol="$(${nissy} solve -o -p htr "$scr")" | ||
| 111 | nsol="$(echo "$sol" | grep -v '^$' | wc -l)" | ||
| 112 | len="$(echo "$sol" | head -n 1 | wc -w)" | ||
| 113 | fin="$(${nissy} solve -o -p drfin "$scr")" | ||
| 114 | lenf="$(echo "$fin" | head -n 1 | wc -w)" | ||
| 115 | slice="$(${nissy} solve -o -p drslice "$scr")" | ||
| 116 | lens="$(echo "$slice" | head -n 1 | wc -w)" | ||
| 117 | read -r x | ||
| 118 | echo "$len moves ($nsol solutions)" | ||
| 119 | read -r x | ||
| 120 | echo "$sol" | ||
| 121 | if [ "$lenf" != "$lens" ]; then | ||
| 122 | echo "" | ||
| 123 | echo "Optimal leave slice ($lens):" | ||
| 124 | echo "$slice" | ||
| 125 | fi | ||
| 126 | echo "" | ||
| 127 | echo "Optimal DR finish ($lenf):" | ||
| 128 | echo "$fin" | ||
| 129 | printf '\n%s' "$prompt" | ||
| 130 | read -r x | ||
| 131 | done | ||
| 132 | } | ||
| 133 | |||
| 134 | practice_fin() { | ||
| 135 | nextscr="$(${nissy} scramble htr)" | ||
| 136 | while true; do | ||
| 137 | scr="$nextscr" | ||
| 138 | echo "Scramble: $scr" | ||
| 139 | nextscr="$(${nissy} scramble htr)" | ||
| 140 | sol="$(${nissy} solve -o -p drudslice "$scr")" | ||
| 141 | nsol="$(echo "$sol" | grep -v '^$' | wc -l)" | ||
| 142 | len="$(echo "$sol" | head -n 1 | wc -w)" | ||
| 143 | fin="$(${nissy} solve -o -p drudfin "$scr")" | ||
| 144 | nfin="$(echo "$fin" | grep -v '^$' | wc -l)" | ||
| 145 | lenf="$(echo "$fin" | head -n 1 | wc -w)" | ||
| 146 | opt="$(${nissy} solve -o -p "$scr")" | ||
| 147 | leno="$(echo "$opt" | head -n 1 | wc -w)" | ||
| 148 | read -r x | ||
| 149 | echo "Leave slice: $len moves ($nsol solutions)" | ||
| 150 | if [ "$lenf" != "$len" ]; then | ||
| 151 | echo "DR finish: $lenf moves" | ||
| 152 | fi | ||
| 153 | read -r x | ||
| 154 | echo "$sol" | ||
| 155 | if [ "$lenf" != "$len" ]; then | ||
| 156 | echo "" | ||
| 157 | echo "Optimal DR finish ($lenf):" | ||
| 158 | echo "$fin" | ||
| 159 | fi | ||
| 160 | if [ "$leno" != "$lenf" ]; then | ||
| 161 | echo "" | ||
| 162 | echo "Optimal DR-breaking ($leno):" | ||
| 163 | echo "$opt" | ||
| 164 | fi | ||
| 165 | printf '\n%s' "$prompt" | ||
| 166 | read -r x | ||
| 167 | done | ||
| 168 | } | ||
| 169 | |||
| 170 | "practice_$1" || usage | ||
diff --git a/unused/translate b/unused/translate new file mode 100755 index 0000000..9442844 --- /dev/null +++ b/unused/translate | |||
| @@ -0,0 +1,11 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # Opens google translate | ||
| 4 | |||
| 5 | translator="https://translate.google.com/" | ||
| 6 | from=$1 | ||
| 7 | to=$2 | ||
| 8 | |||
| 9 | shift 2 | ||
| 10 | text=$(echo "$@" | sed 's/ /\%20/g') | ||
| 11 | open-url "${translator}?sl=${from}&tl=${to}&text=${text}&op=translate" | ||
diff --git a/unused/websearch b/unused/websearch new file mode 100755 index 0000000..dddcc20 --- /dev/null +++ b/unused/websearch | |||
| @@ -0,0 +1,11 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # Perform a web search | ||
| 4 | |||
| 5 | browser=${BROWSER:-firefox} | ||
| 6 | searchengine="https://www.startpage.com/sp/search?query=" | ||
| 7 | #searchengine="https://duckduckgo.com/?q=" | ||
| 8 | #searchendinge="https://www.google.com/search?q=" | ||
| 9 | |||
| 10 | arg=$(echo "$@" | sed 's/ /\+/g') | ||
| 11 | [ -n "$arg" ] && spawn "$browser" "${searchengine}$arg" | ||
diff --git a/unused/xplumb b/unused/xplumb new file mode 100755 index 0000000..1d89796 --- /dev/null +++ b/unused/xplumb | |||
| @@ -0,0 +1,65 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # My interpretation of a plumber (plan9 style). | ||
| 4 | # It scans the selected text (xsel) and decides what to do with it among | ||
| 5 | # some possibilities (open file, open url, man page...). If none is matched, | ||
| 6 | # a choice is prompted. | ||
| 7 | |||
| 8 | # Requires: dmenu (or similar), mail-compose, open-file, terminal, websearch, | ||
| 9 | # xedit, xsel | ||
| 10 | |||
| 11 | # TODO: | ||
| 12 | # send mail to email address; | ||
| 13 | # calendar if it is a date | ||
| 14 | # choice: pipe to another program | ||
| 15 | |||
| 16 | browser=${BROWSER:-firefox} | ||
| 17 | menu=${MENU:-dmenu} | ||
| 18 | menuopts="-l 10" | ||
| 19 | |||
| 20 | text=$(xsel | sed 's/\n/ /g') | ||
| 21 | if [ "${#text}" -ge 11 ]; then | ||
| 22 | shorttext=$(echo "$text" | cut -b 1-10)... | ||
| 23 | else | ||
| 24 | shorttext="$text" | ||
| 25 | fi | ||
| 26 | |||
| 27 | choice() { | ||
| 28 | chosen=$(printf "websearch\nedit" | \ | ||
| 29 | $menu $menuopts -p "What to do with \"$shorttext\"?") | ||
| 30 | |||
| 31 | if [ "$chosen" = "websearch" ]; then | ||
| 32 | websearch "$text" | ||
| 33 | elif [ "$chosen" = "edit" ]; then | ||
| 34 | f=$(mktemp) | ||
| 35 | xsel > "$f" | ||
| 36 | xedit "$f" | ||
| 37 | fi | ||
| 38 | } | ||
| 39 | |||
| 40 | trymail() { | ||
| 41 | addr=$(echo "$1" | addressgrep) | ||
| 42 | ( [ -n "$addr" ] && mail-compose "$addr" ) || return 1 | ||
| 43 | } | ||
| 44 | |||
| 45 | tryman() { | ||
| 46 | number=$(echo "$1" | sed 's/[^1-8]//g') | ||
| 47 | name=$(echo "$1" | sed 's/([1-8])//g' | sed 's/ //g') | ||
| 48 | if [ "$(man -w "$number" "$name" | wc -l)" = 1 ]; then | ||
| 49 | terminal -e man "$number" "$name" | ||
| 50 | return 0 | ||
| 51 | else | ||
| 52 | return 1 | ||
| 53 | fi | ||
| 54 | } | ||
| 55 | |||
| 56 | tryurl() { | ||
| 57 | url=$(echo "$1" | urlgrep) | ||
| 58 | ( [ -n "$url" ] && "$browser" "$url" ) || return 1 | ||
| 59 | } | ||
| 60 | |||
| 61 | #open-file -s spawn "$text" || \ | ||
| 62 | tryurl "$text" || \ | ||
| 63 | trymail "$text" || \ | ||
| 64 | tryman "$text" || \ | ||
| 65 | choice | ||
