diff options
author | Timmy Keller <tjk@tjkeller.xyz> | 2022-03-16 23:37:09 -0500 |
---|---|---|
committer | Timmy Keller <tjk@tjkeller.xyz> | 2022-03-16 23:37:09 -0500 |
commit | 3d3d79a57fb6d0a5728e0070475f05d1699f0818 (patch) | |
tree | b141cba678d6bb9821bb33b0dd7c7f1ca31b2c6a /misc | |
parent | d51fa1bdda79b8589ddf0002fc4b54aac6ce8354 (diff) | |
download | scripts-3d3d79a57fb6d0a5728e0070475f05d1699f0818.tar.xz scripts-3d3d79a57fb6d0a5728e0070475f05d1699f0818.zip |
move a lot of scripts around and make a bunch of minor changes. once again i am too lazy to document the changes properly since im never going to read these commit messages anyways
Diffstat (limited to 'misc')
-rwxr-xr-x | misc/hwtexedit | 49 | ||||
-rwxr-xr-x | misc/lipsum | 90 | ||||
-rwxr-xr-x | misc/lsdu | 2 | ||||
-rwxr-xr-x | misc/mksh | 6 | ||||
-rwxr-xr-x | misc/seasonalwallpaper | 13 | ||||
-rwxr-xr-x | misc/setup | 76 | ||||
-rwxr-xr-x | misc/verify | 16 |
7 files changed, 19 insertions, 233 deletions
diff --git a/misc/hwtexedit b/misc/hwtexedit deleted file mode 100755 index 262d10b..0000000 --- a/misc/hwtexedit +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/sh -dir=~/docs/school - -files="$(find $dir -name \*.tex -printf "%T@ %p\n" | sort -nr | cut -d' ' -f 2-)" - -echo "$files" | awk ' -function printcol(c1, c2, c3) { printf "%-12s %-32s %s\n", c1, c2, c3 } -BEGIN { - printcol(" class:", "containing dir:", "file:") - fn = 1 -} -{ - tf = c = cf = $0 - sub(/.*\//, "", tf) - sub("'$dir'/", "", c) - sub(/\/.*/, "", c) - sub("'$dir'/"c"/", "", cf) - sub("/"tf, "", cf) - printcol(fn": "c, cf, tf) - fn++ -} -' -read -p "Choose file number: " filenum -file="$(echo "$files" | head -$filenum | tail -1)" -dir="$(echo "$file" | sed 's/\(\/.*\)\/.*/\1/')" - -cd "$dir" - -st -e $EDITOR "$file" & -echo "$file" | entr pdflatex -output-directory "$dir" "$file" || echo "entr or LaTeX is not installed!" & -zathura "$(echo "$file" | sed 's/.tex$/.pdf/')" & - -#listfiles() { -# pids=$(xdotool search --class "Vim") -# for pid in $pids; do -# names="$(xdotool getwindowname $pid | grep '\.tex')\n$names" -# #$openfiles="$(echo "$name" | cut -d' ' -f1)\n$openfiles" -# #$openfilepaths="$(echo "$name" | awk -F'[()]' '{ print $2 }')\n$openfiles" -# done -# #file="$(echo $openfiles | grep "^$1")" -# [ -z "$file" ] \ -# && interactiveopt "$(echo $openfiles | sort -bu | tail +2)" "Which file to autocompile? " 1 \ -# && file="$opt" -#} -# -#[ -e "$1" ] && file="$1" || listfiles -# -#echo "$file" | entr pdflatex "$file" || echo "entr or LaTeX is not installed!" - diff --git a/misc/lipsum b/misc/lipsum deleted file mode 100755 index efa71b5..0000000 --- a/misc/lipsum +++ /dev/null @@ -1,90 +0,0 @@ -#!/usr/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(word) { - sub(/./, toupper(substr(word, 0, 1)), word) - print word -} - -function isint(arg) { - return arg ~ /^[0-9]+$/ -} - -function randrange(min, max) { - return int((rand() * (max - min)) + min) -} - -function genword() { - wc++ # There's gotta be a more efficient way of doing this - return (wc > 5 || !litextout) ? word[randrange(0, dictlen)] : litext[wc - 1] -} - -function genwords(words) { - if (words > 0) { - capitalize(genword()) - for (i = 1; i < words; i++) - print " " genword() - print "\n" - } -} - -function gensentences(sentences, delim, min, max) { - for (; sentences > 0; sentences--) { - capitalize(genword()) - words = randrange(min, max) # Isn't possible to initialize or increment multiple variables in awk for loops - for (i = 1; i < words; i++) - print (rand() < 0.10 ? ", " : " ") genword() - print delim - } -} - -function genparagraphs(paragraphs, min, max) { - for (; paragraphs > 0; paragraphs--) { - print "\t" - gensentences(randrange(6, 10), ". ", min, max) - print "\n" - } -} - -BEGIN { - dictionary = "/home/timmy/.local/share/lorem-ipsum-dictionary" # List of lorem ipsum words separated by newlines - litext[0] = "lorem"; litext[1] = "ipsum"; litext[2] = "dolor"; litext[3] = "sit"; litext[4] = "amet" - - ORS = "" - srand() - - for (dictlen = 0; getline < dictionary; dictlen++) - word[dictlen] = $0 - - # Parse Arguments - !isint(ARGV[1]) && ARGV[1] && printusage() - numof = ARGC > 1 ? ARGV[1] : 5 - mode = ARGC > 2 ? ARGV[2] : "p" - litextout = 1 - if (ARGV[3]) - switch (ARGV[3]) { - case /^1$|^t$|^true$/: litextout = 1; break - case /^0$|^f$|^false$/: litextout = 0; break - default: printusage() - } - min = isint(ARGV[4]) ? ARGV[4] : 5 - max = isint(ARGV[5]) ? ARGV[5] : 12 - - switch (mode) { - case /^w$|^words$/: - genwords(numof) - break - case /^s$|^sentences$/: - gensentences(numof, ".\n", min, max) - break - case /^p$|^paragraphs$/: - genparagraphs(numof, min, max) - break - default: - printusage() - } -} @@ -1,5 +1,5 @@ #!/bin/sh -du -ah -d1 "$@" 2>/dev/null | sed 's/\.\///' | sort -h +du -ahd1 "$@" 2>/dev/null | sed 's/\.\///' | sort -h #for file in $(ls -a $1); do # ([ "$file" = "." ] || [ "$file" = ".." ]) && continue # files="${files:+$files\n}$(du -h $1/"$file" 2>/dev/null | tail -1)" @@ -3,7 +3,7 @@ newname() { defname="script"; name=$defname`ls | grep "^$defname[0-9]*" | wc -l | tr -d '[:blank:]'`; } # Remove blank space in certain non-GNU implementations of wc [ -z "$1" ] && newname || name="$1" [ -e "$name" ] && echo "File $name exists!" && exit 1 -[ -z "$2" ] && shebang="#!/bin/sh" || shebang="$2" -echo "$shebang" > "$name" && chmod +x "$name" && $EDITOR "$name" -# Delete file if it is just exited w/o being changed +[ -z "$2" ] && shebang="#!/bin/sh" || shebang="#!$2" +echo "$shebang" > "$name" && chmod +x "$name" && ${EDITOR:-vi} "$name" +# Delete file if it is empty [ "`cat "$name"`" = "$shebang" ] && rm "$name" && echo "Removed empty script \"$name\"" || echo "Saved script \"$name\"" diff --git a/misc/seasonalwallpaper b/misc/seasonalwallpaper index 1b5bf4a..525bfb0 100755 --- a/misc/seasonalwallpaper +++ b/misc/seasonalwallpaper @@ -1,13 +1,12 @@ #!/bin/sh case $1 in - spring|summer|fall|winter) dir=~/.local/share/wallpaper/$1/ ; xwallpaper --zoom "$dir`ls $dir | sort --random-sort | head -1`" ;; + spring|summer|fall|winter) dir=~/.local/share/wallpaper/$1/ ; xwallpaper --zoom "$dir`ls $dir | shuf -n1`" ;; *) - case "`date +%b`" in - Dec|Jan|Feb) season=winter ;; - Mar|Apr|May) season=spring ;; - Jun|Jul|Aug) season=summer ;; - Sep|Oct|Nov) season=fall ;; + case `date +%b` in + Dec|Jan|Feb) $0 winter ;; + Mar|Apr|May) $0 spring ;; + Jun|Jul|Aug) $0 summer ;; + Sep|Oct|Nov) $0 fall ;; esac - $0 $season ;; esac diff --git a/misc/setup b/misc/setup deleted file mode 100755 index eaeec39..0000000 --- a/misc/setup +++ /dev/null @@ -1,76 +0,0 @@ -#!/bin/sh - -#interactiveopt() { -# # Usage: interactiveopt "options" "prompt" -# echo "$1" | nl -s': ' 1>&2 -# # Parse user input -# read -p "$2" choices 1>&2 \ -# && choices="$(echo $choices | cut -d' ' -f1-)" -# for choice in $choices; do -# case "$choice" in -# [0-9]*) opt="$opt $(echo "$1" | head -"$(echo $choice | tr -cd '[:digit:]')" | tail -1)";; -# *) echo "Invalid option \"$opt\"" 1>&2 ;; -# esac -# done -# echo "$opt" -#} - -# Open as root in pcmanfm -pcmanfmconf() { - pcmanfmroot=~/.local/share/file-manager/actions - mkdir -p $pcmanfmroot - echo " [Desktop Entry] -Type=Action -Tooltip=Open Folder As Root -Name=Open Folder As Root -Profiles=profile-zero; -Icon=gtk-dialog-authentication - -[X-Action-Profile profile-zero] -MimeTypes=inode/directory; -Exec=/home/timmy/.local/bin/x11/xsudo /usr/bin/pcmanfm %u -Name=Default profile" > $pcmanfmroot/root.desktop -} - -minticons() { - gitdir="/tmp/mint-y-icons" - iconsdir="$gitdir/usr/share/icons" - git clone https://github.com/linuxmint/mint-y-icons.git "$gitdir" - #iconsets="$(interactiveopt "$(ls "$iconsdir")" "Choose icon sets (if using dark theme, COPY THE NON-DARK THEME TOO): ")" - #iconsets="$iconset Mint-Y" - #for iconset in $iconsets; do - # mv "$iconsdir/$iconset" $iconsdestdir - #done - mv $iconsdir/* $iconsdestdir - gtk-update-icon-cache -} - -mintthemes() { - gitdir="/tmp/mint-themes" - themesdir="$gitdir/usr/share/themes" - #iconsdir="$gitdir/usr/share/icons" - git clone https://github.com/linuxmint/mint-themes.git "$gitdir" - curdir="$(pwd)" - cd $gitdir - make - #themes="$(interactiveopt "$(ls "$themesdir")" "Choose themes: ")" - ##iconset="$iconset Mint-Y" - #for theme in $themes; do - # mv "$themesdir/$theme" $themesdestdir - #done - #iconsets="$(interactiveopt "$(ls "$iconsdir")" "Choose icon set (if using dark theme, COPY THE NON-DARK THEME TOO): ")" - #iconset="$iconset Mint-Y" - #for iconset in $iconsets; do - # mv "$iconsdir/$iconset" $iconsdestdir - #done - #gtk-update-icon-cache - mv $themesdir/* $themesdestdir -} - -iconsdestdir=/usr/share/icons -themesdestdir=/usr/share/themes -mkdir -p $iconsdestdir $themesdestdir - -pcmanfmconf -minticons -mintthemes diff --git a/misc/verify b/misc/verify index 0d17085..5f0430c 100755 --- a/misc/verify +++ b/misc/verify @@ -3,19 +3,21 @@ NORM="\033[0m" CYN="\033[0;36m" GRN="\033[0;32m" RED="\033[0;31m" + printhelp() { -echo "\ +cat << HELPDOC Usage: $(basename "$0") [options] [file/directory]... OPTIONS: -m, --md5 Create/verify md5 checksum - -s[alg], --sha[alg] Create/verify sha checksum - -x[alg], --xxh[alg] Create/verify xxh checksum - -c [alg], --crypt [alg] Create/verify [alg] checksum (uses [alg]sum) + -s[mode], --sha[mode] Create/verify sha[mode] checksum + -x[mode], --xxh[mode] Create/verify xxh[mode] checksum (default) + -c [alg], --crypt [alg] Create/verify [alg] checksum (uses [alg]sum program; e.g. '-c sha256' uses sha256sum) -v, --verify Verify files with existing checksums - -h, --help Print help \ -"; + -h, --help Print help +HELPDOC } + crypt=xxh while true; do case "$1" in @@ -30,7 +32,7 @@ while true; do esac shift done -hashalg=${crypt}sum # Works for current algs +hashalg=${crypt}sum command -v $hashalg >/dev/null || (echo "Hashing algorithm '$hashalg' does not exist!" && exit 2) while [ -n "$1" ]; do |