diff options
author | Timmy Keller <tjk@tjkeller.xyz> | 2021-09-11 00:36:13 -0500 |
---|---|---|
committer | Timmy Keller <tjk@tjkeller.xyz> | 2021-09-11 00:36:13 -0500 |
commit | 0a9053c2902adab8b94eaacdb15390441143078c (patch) | |
tree | 1f1a38272dbd554cde8cdec263187112b9c6a7e8 /old | |
download | scripts-0a9053c2902adab8b94eaacdb15390441143078c.tar.xz scripts-0a9053c2902adab8b94eaacdb15390441143078c.zip |
redid repo cus of fucking chromium rip old commit messages
Diffstat (limited to 'old')
-rwxr-xr-x | old/lipsum | 87 | ||||
-rwxr-xr-x | old/lipsumsh | 72 | ||||
-rwxr-xr-x | old/setwindowtitle | 10 | ||||
-rwxr-xr-x | old/shblr | 14 |
4 files changed, 183 insertions, 0 deletions
diff --git a/old/lipsum b/old/lipsum new file mode 100755 index 0000000..7ae9b7e --- /dev/null +++ b/old/lipsum @@ -0,0 +1,87 @@ +#!/bin/awk -f + +function printusage() { + print "Usage: lipsum [# of] [w/words|s/sentences|p/paragraphs] [1/t/true|0/f/false output 'lorem ipsum' in first entry] [min words] [max words]\n" + exit 1 +} + +function capitalize() { + sub(/./, toupper(substr($0, 0, 1))) +} + +function randrange(min, max) { + return int((rand() * (max - min)) + min) +} + +function isint(arg) { + return arg ~ /^[0-9]+$/ +} + +function genwords(words, cmd) { + if (words > 0 && cmd | getline) { + capitalize(); print + for (i = 1; cmd | getline && i < words; i++) + print " "$0 + print "\n" + } +} + +function gensentences(sentences, delim, cmd, min, max) { + for (; sentences > 0 && cmd | getline; sentences--) { + capitalize(); print + words = randrange(min, max) # Isn't possible to initialize or increment multiple variables in awk for loops + for (i = 1; cmd | getline && i < words; i++) + print (rand() < 0.10 ? ", " : " ")$0 + print delim + } +} + +function genparagraphs(paragraphs, cmd, min, max) { + for (; paragraphs > 0; paragraphs--) { + print "\t" + gensentences(randrange(6, 10), ". ", cmd, min, max) + print "\n" + } +} + +BEGIN { + dictionary = "/home/timmy/.local/share/lorem-ipsum-dictionary" # List of lorem ipsum words separated by newlines + cmd = "< "dictionary" shuf -r -n" # Command to generate random permutations of words from dictionary separated by newlines + echolorem = "echo -n 'lorem\nipsum\ndolor\nsit\namet\n'" + + ORS = "" + srand() + + # Parse Arguments + !isint(ARGV[1]) && ARGV[1] && printusage() + numof = ARGC > 1 ? ARGV[1] : 5 + mode = ARGC > 2 ? ARGV[2] : "p" + litext = 1 + if (ARGV[3]) + switch (ARGV[3]) { + case /^1$|^t$|^true$/: litext = 1; break + case /^0$|^f$|^false$/: litext = 0; break + default: printusage() + } + litext && cmd = echolorem "&&" cmd + min = isint(ARGV[4]) ? ARGV[4] : 5 + max = isint(ARGV[5]) ? ARGV[5] : 12 + + switch (mode) { + case /^w$|^words$/: + cmd = cmd numof + genwords(numof, cmd) + break + case /^s$|^sentences$/: + cmd = cmd (max * numof) + gensentences(numof, ".\n", cmd, min, max) + break + case /^p$|^paragraphs$/: + cmd = cmd (max * 10 * numof) + genparagraphs(numof, cmd, min, max) + break + default: + printusage() + } + close(cmd) +} diff --git a/old/lipsumsh b/old/lipsumsh new file mode 100755 index 0000000..d229877 --- /dev/null +++ b/old/lipsumsh @@ -0,0 +1,72 @@ +#!/bin/sh + +dictionary=/home/timmy/.local/share/lorem-ipsum-dictionary + +shuf -r -n$1 $dictionary | awk -f- hi hello yolo <<'AWKSCRIPT' +BEGIN { for(i = 1; i < ARGC; i++) print ARGV[i] } +AWKSCRIPT +echo +#shuf -r -n$1 $dictionary | tr '\n' ' ' + + + + + +exit + +#genipsums() { shuf -r -n$1 $dictionary | tr '\n' ' ' | sed 's/.$//'; } +genipsums() { shuf -r -n$1 $dictionary; } +gensentence() { genipsums $1 | sed ':a;N;$!ba; s/\n/ /g; s/.$//; s/\(^\| \)\([a-z]\)/\1\u\2/'; } + +genparagraph() { + sentences=`shuf -n1 -i 4-12` + echo -n '\t' + + for i in `seq $sentences`; do + words=`shuf -n1 -i 1-10` + [ "$loremipsumtext" = '1' ] && echo -n "Lorem ipsum " && genipsums $words && loremipsumtext=0 || gensentence $words + [ "$words" -le 4 ] || [ `shuf -n1 -i 0-2` = 1 ] && echo -n ', ' && genipsums `shuf -n1 -i 3-10` # make more complex + echo -n '. ' + done + echo +} + +loremipsumtext=1 + +genparagraph + + + +#exit +# +#dictionary=/home/timmy/.local/share/lorem-ipsum-dictionary +# +#ipsums=$1 +# +##set -- `tr '\n' ' ' < $dictionary` +#set -- `cat $dictionary` +# +##rand=`od -An -N$ipsums /dev/urandom` +# +#shuf -r -n$ipsums -i 1-$# | while read line; do +# eval echo -n \${$line} +# echo -n ' ' +#done +# +#echo +# +#exit +# +# +# +#words=`wc -w $dictionary | cut -d' ' -f1` +# +#echo -n '\tLorem ipsum ' +# +#shuf -r -n$1 -i 1-$words | while read line; do +# #cut -z -d' ' -f$line $dictionary && echo -n ' ' +# head -n$line $dictionary | tail -n1 | tr -d '\n' +# num=`shuf -n1 -i 1-100` +# ([ "$num" -lt 10 ] && echo -n '. ') || ([ "$num" -gt 90 ] && echo -n ', ') || ([ "$num" = '50' ] && echo -n '.\n\t') || echo -n ' ' +#done +#echo diff --git a/old/setwindowtitle b/old/setwindowtitle new file mode 100755 index 0000000..a2b9218 --- /dev/null +++ b/old/setwindowtitle @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +#windowname="$(dmenu -p 'Enter New Window Name. Then, Select the Window to Change' <&-)" +#xdotool selectwindow set_window --class "$windowname" +##if [ -z "$1" ]; +##then +##else +## xdotool getactivewindow set_window --class "$1" +##fi +#if [ -z "$2" ]; then echo -en "\e]0;$2\a"; fi +#xsetroot -name "" diff --git a/old/shblr b/old/shblr new file mode 100755 index 0000000..4570afc --- /dev/null +++ b/old/shblr @@ -0,0 +1,14 @@ +#!/bin/sh +energy_now_total=0 +energy_full_total=0 +for bat in /sys/class/power_supply/BAT?*; do + echo "`basename $bat`: \n" \ + "├─Capacity:\t\t`cat $bat/capacity`% \n" \ + "├─Energy Now:\t\t`cat $bat/energy_now` \n" \ + "├─Energy Full:\t\t`cat $bat/energy_full` \n" \ + "├─Energy Full Design:\t`cat $bat/energy_full_design` \n" \ + "└─Health:\t\t$(( (`cat $bat/energy_full` * 100) / `cat $bat/energy_full_design` ))% " + energy_now_total=$(( energy_now_total + `cat $bat/energy_now` )) + energy_full_total=$(( energy_full_total + `cat $bat/energy_full` )) +done +echo "\nTotal Capacity:\t$(( (energy_now_total * 100) / energy_full_total ))%" |