From: Armaan Bhojwani Date: Sun, 30 May 2021 16:20:04 +0000 (-0400) Subject: Fix indentation on all programs X-Git-Url: https://git.armaanb.net/?p=bin.git;a=commitdiff_plain;h=c95e95333f93130886fa49231679a02256cfdcef Fix indentation on all programs --- diff --git a/chrooter b/chrooter index 64403d6..49d74fd 100755 --- a/chrooter +++ b/chrooter @@ -13,11 +13,11 @@ die() { clean() { log Unmounting /dev, /proc and /sys from chroot; { - umount "$1/sys/firmware/efi/efivars" 2>/dev/null ||: - umount "$1/dev" ||: - umount "$1/proc" ||: - umount "$1/sys" ||: - } + umount "$1/sys/firmware/efi/efivars" 2>/dev/null ||: + umount "$1/dev" ||: + umount "$1/proc" ||: + umount "$1/sys" ||: +} log Cleaning leftover host files; { rm -f "$1/root/.ash_history" @@ -60,15 +60,15 @@ log Copying /etc/resolv.conf from host; { NEWSHELL=${2:-"/bin/sh"} \ -log Entering chroot; { + log Entering chroot; { chroot "$1" /usr/bin/env -i \ - HOME=/root \ - TERM="$TERM" \ - SHELL=${NEWSHELL} \ - USER=root \ - CFLAGS="${CFLAGS:--march=x86-64 -mtune=generic -pipe -Os}" \ - CXXFLAGS="${CXXFLAGS:--march=x86-64 -mtune=generic -pipe -Os}" \ - MAKEFLAGS="${MAKEFLAGS:--j$(nproc 2>/dev/null || echo 1)}" \ - DISPLAY="$DISPLAY" \ - "$NEWSHELL" -l + HOME=/root \ + TERM="$TERM" \ + SHELL=${NEWSHELL} \ + USER=root \ + CFLAGS="${CFLAGS:--march=x86-64 -mtune=generic -pipe -Os}" \ + CXXFLAGS="${CXXFLAGS:--march=x86-64 -mtune=generic -pipe -Os}" \ + MAKEFLAGS="${MAKEFLAGS:--j$(nproc 2>/dev/null || echo 1)}" \ + DISPLAY="$DISPLAY" \ + "$NEWSHELL" -l } diff --git a/fix-flatpak-theme b/fix-flatpak-theme index 3dc7ff9..2b0ab77 100755 --- a/fix-flatpak-theme +++ b/fix-flatpak-theme @@ -3,7 +3,7 @@ # From https://github.com/abiosoft/dotfiles/blob/master/flatpak/fixflatpaktheme.sh for dir in "$HOME"/.var/app/*; do - confdir="${dir}/config/gtk-3.0" - mkdir -p ${confdir} - cp "${HOME}/.config/gtk-3.0/settings.ini" "${confdir}/settings.ini" + confdir="${dir}/config/gtk-3.0" + mkdir -p ${confdir} + cp "${HOME}/.config/gtk-3.0/settings.ini" "${confdir}/settings.ini" done diff --git a/fmt-music b/fmt-music index e578a03..90457aa 100755 --- a/fmt-music +++ b/fmt-music @@ -1,21 +1,21 @@ #!/usr/bin/sh -e find "${1:-.}" -regex '.*\.\(mp3\|ogg\|wav\|aac\|wma\|flac\|alac\)' -type f | \ - while read line; do - newline=$(echo $line | sed -E -e 's|[[:space:]]?-[[:space:]]?|_|g' \ - -e 's/ */ /g') + while read line; do + newline=$(echo $line | sed -E -e 's|[[:space:]]?-[[:space:]]?|_|g' \ + -e 's/ */ /g') - o=$(echo -n $(dirname "$newline") | sed -e 's|\./||g' -e 's|/| - |g') + o=$(echo -n $(dirname "$newline") | sed -e 's|\./||g' -e 's|/| - |g') - first=$(echo -n $(basename "$newline") | cut -d " " -f 1) - if $(echo $first | grep -Eq '^[0-9]+$'); then - o="$o $(echo -n "- $first -")" - num=2 - else - o="$o -" - num=1 - fi + first=$(echo -n $(basename "$newline") | cut -d " " -f 1) + if $(echo $first | grep -Eq '^[0-9]+$'); then + o="$o $(echo -n "- $first -")" + num=2 + else + o="$o -" + num=1 + fi - o="$o $(echo -n $(basename "$newline") | cut -d " " -f ${num}-)" - cp -v "$line" "${2:-.}/$o" - done + o="$o $(echo -n $(basename "$newline") | cut -d " " -f ${num}-)" + cp -v "$line" "${2:-.}/$o" + done diff --git a/fortune b/fortune index fde9085..afb967c 100755 --- a/fortune +++ b/fortune @@ -2,28 +2,28 @@ # Fortune implementation in POSIX sh/awk usage() { - echo 'Usage: fortune [OPTIONS] + echo 'Usage: fortune [OPTIONS] a simple POSIX sh/awk implementation of fortune - -h, --help show this help message - -l, --list list installed cookie files - -c FILE, --cookie FILE specify cookie file - -n LENGTH, --min LENGTH specify min fortune length - -N LENGTH, --max LENGTH specify max fortune length + -h, --help show this help message + -l, --list list installed cookie files + -c FILE, --cookie FILE specify cookie file + -n LENGTH, --min LENGTH specify min fortune length + -N LENGTH, --max LENGTH specify max fortune length - fortune looks for fortunes in $FORTUNEDIR, which defaults to - /usr/share/fortune. + fortune looks for fortunes in $FORTUNEDIR, which defaults to + /usr/share/fortune. Exit codes: - 0 success - 1 generic error - 2 argument parsing error' + 0 success + 1 generic error + 2 argument parsing error' } parse_err() { - echo "$1" - $2 - exit 2 + echo "$1" + $2 + exit 2 } DIR=${FORTUNEDIR:-"/usr/share/fortune/"} @@ -32,64 +32,64 @@ MAXLENGTH=1000000000000 MINLENGTH=0 while [ "$1" != "" ]; do - case $1 in - -h | --help) - usage - exit - ;; - -c | --cookie) - FILE=$DIR/$2 - ;; - -n | --min) - MINLENGTH=$2 - ;; - -N | --max) - MAXLENGTH=$2 - ;; - -l | --list) - ls -1 $DIR - exit - ;; - *) - parse_err "ERROR: unknown option \"$1\"" usage - ;; - esac - shift 2 + case $1 in + -h | --help) + usage + exit + ;; + -c | --cookie) + FILE=$DIR/$2 + ;; + -n | --min) + MINLENGTH=$2 + ;; + -N | --max) + MAXLENGTH=$2 + ;; + -l | --list) + ls -1 $DIR + exit + ;; + *) + parse_err "ERROR: unknown option \"$1\"" usage + ;; + esac + shift 2 done [ "$MAXLENGTH" -lt "$MINLENGTH" ] && { - parse_err "ERROR: maximum length is less than minimum length" + parse_err "ERROR: maximum length is less than minimum length" } [ -d "$FILE" ] && { - parse_err "ERROR: directory given, please provide a file or glob of files" + parse_err "ERROR: directory given, please provide a file or glob of files" } [ "$(find $FILE -maxdepth 1 -print -quit 2> /dev/null)" ] || { - parse_err "ERROR: no such file or directory" + parse_err "ERROR: no such file or directory" } awk -v maxlen=$MAXLENGTH -v minlen=$MINLENGTH \ -'BEGIN { - f++ + 'BEGIN { + f++ } $1 == "%" { - len = length(fortunes[f]) - if ( len>maxlen || lenmaxlen || len ${i}.tmp - mv ${i}.tmp ${i} - done - git -C ${dir} fetch --tags - echo $(date -Iseconds) ' | ' ${dir} | tee -a ${2} - echo $(tail -n 1500 ${2}) > ${2} - done + while :; do + stagit-index ${1}/* + find "$1" -name '*.git' -type d | \ + while read dir; do + newdir=${3}/$(basename ${dir} .git) + [ -d ${newdir} ] || mkdir ${newdir} + cd ${newdir} + stagit ${dir} + cp "$1/logo.png" . + ln -s logo.png favicon.png + find . -type f \( -name '*.html' -or -name '*.xml' \) | \ + while read i ; do + minify ${i} > ${i}.tmp + mv ${i}.tmp ${i} + done + git -C ${dir} fetch --tags + echo $(date -Iseconds) ' | ' ${dir} | tee -a ${2} + echo $(tail -n 1500 ${2}) > ${2} + done sleep ${4:-600} - done - } + done +} - gen_url() { +gen_url() { find ${1} -maxdepth 2 -name '*.git' | \ - while read dir; do - $(git -C $dir remote get-url origin) > $dir/url - done - } + while read dir; do + $(git -C $dir remote get-url origin) > $dir/url + done +} - case ${1} in +case ${1} in -h | --help | help) - usage - ;; + usage + ;; run) - shift 1 - run $@ - ;; + shift 1 + run $@ + ;; gen-url) - shift 1 - gen_url $@ - ;; + shift 1 + gen_url $@ + ;; *) - usage - exit 1 - ;; - esac + usage + exit 1 + ;; +esac diff --git a/lolcat-gen b/lolcat-gen deleted file mode 100755 index 333bf73..0000000 --- a/lolcat-gen +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env bash -# Generates lolcated logo for my shell rc - -if [[ ${2} ]]; then - FILE=${2} -else - FILE="~/Code/personal-logo/square/unicode/small" -fi - -if [[ ${1} ]]; then - NUM=${1} -else - NUM="100" -fi - -[[ -d ~/.local/share/zsh/lolcat/ ]] || mkdir -p ~/.local/share/zsh/lolcat - -rm ~/.local/share/zsh/lolcat/* - -for (( i = 0; i < ${NUM} ; i++ )); do - cat $FILE | lolcat --force > ~/.local/share/zsh/lolcat/$i - echo -ne "$i/$1 done" \\r -done diff --git a/morse.c b/morse.c index 5f3f589..e535e6f 100644 --- a/morse.c +++ b/morse.c @@ -7,14 +7,17 @@ #include #include -const char *aa[] = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", - "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "1", - "2", "3", "4", "5", "6", "7", "8", "9", "0", " "}; +const char *aa[] = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", + "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", + "u", "v", "w", "x", "y", "z", "1", "2", "3", "4", + "5", "6", "7", "8", "9", "0", " "}; -const char *ma[] = {"•-", "-•••", "-•-•", "-••", "•", "••-•", "--•", "••••", - "••", "•---", "-•-", "•-••", "--", "-•", "---", "•--•", "--•-", "•-•", "•••", - "-", "•--", "•••-", "•--", "-••-", "-•--", "--••", "•----", "••---", "•••--", - "••••-", "•••••", "-••••", "--•••", "---••", "----•", "-----", " "}; +const char *ma[] = {"•-", "-•••", "-•-•", "-••", "•", "••-•", "--•", + "••••", "••", "•---", "-•-", "•-••", "--", "-•", + "---", "•--•", "--•-", "•-•", "•••", "-", "•--", + "•••-", "•--", "-••-", "-•--", "--••", "•----", + "••---", "•••--", "••••-", "•••••", "-••••", + "--•••", "---••", "----•", "-----", " "}; void convert(char *c) diff --git a/passmenu b/passmenu index 44681ef..e54439a 100755 --- a/passmenu +++ b/passmenu @@ -4,20 +4,21 @@ typeit=0 if [ "$1" = "--type" ]; then - typeit=1 - shift + typeit=1 + shift fi prefix=${PASH_DIR-~/.local/share/pash} -password=$(find "$prefix" -name '*.gpg' | awk -v prefix="$prefix" \ - '{len = length(prefix) + 2; print substr($0, len, length($0) - len - 3)}' \ - | dmenu "$@") +password=$(find "$prefix" -name '*.gpg' \ + | awk -v prefix="$prefix" \ + '{len = length(prefix) + 2; print substr($0, len, length($0) - len - 3)}' \ + | dmenu "$@") [ -n "$password" ] || exit if [ $typeit -eq 0 ]; then - pash show "$password" | head -n 1 | xclip -sel c + pash show "$password" | head -n 1 | xclip -sel c else - pash show "$password" | { IFS= read -r pass; printf %s "$pass"; } | - xdotool type --clearmodifiers --file - + pash show "$password" | { IFS= read -r pass; printf %s "$pass"; } | + xdotool type --clearmodifiers --file - fi diff --git a/scoop-cgi b/scoop-cgi index 00241c4..b7531ec 100755 --- a/scoop-cgi +++ b/scoop-cgi @@ -1,5 +1,5 @@ #!/usr/bin/env sh -# CGI script to get irc logs from scoop. Powers https://logs.armaanb.net. +# CGI script to get irc logs from scoop. Powers https://irclogs.armaanb.net. channel=$(echo "$PATH_INFO" | awk -F / '{print $2}') if [ -z "$channel" ]; then diff --git a/setter b/setter index abdffd5..b13adfb 100755 --- a/setter +++ b/setter @@ -2,34 +2,34 @@ # Sends a notification with the time, battery level, and volume if [[ ${1} == "status" || -z ${1} ]]; then - dunstify -h string:x-canonical-private-synchronous:status \ - "$(date "+%A %Y-%m-%d, %r")"\ - "$(acpi | tail -c +12)\n$(amixer sget Master | tail -n 1 \ - | cut -d " " -f 7-)" \ - -t 2000 + dunstify -h string:x-canonical-private-synchronous:status \ + "$(date "+%A %Y-%m-%d, %r")"\ + "$(acpi | tail -c +12)\n$(amixer sget Master | tail -n 1 \ + | cut -d " " -f 7-)" \ + -t 2000 elif [[ ${1} == "audio" ]]; then - if [[ ${2} ]]; then - [[ $(amixer sget Master | tail -n 1 | grep "off") ]] && - pactl set-sink-mute 0 toggle - pactl set-sink-volume 0 ${2}% - else - pactl set-sink-mute 0 toggle - fi + if [[ ${2} ]]; then + [[ $(amixer sget Master | tail -n 1 | grep "off") ]] && + pactl set-sink-mute 0 toggle + pactl set-sink-volume 0 ${2}% + else + pactl set-sink-mute 0 toggle + fi - mutes="Unmuted" - [[ $(amixer sget Master | tail -n 1 | grep "off") ]] && mutes="Muted" + mutes="Unmuted" + [[ $(amixer sget Master | tail -n 1 | grep "off") ]] && mutes="Muted" - dunstify -h string:x-canonical-private-synchronous:audio \ - "Volume" "${mutes}" \ - -h int:value:"$(amixer sget Master | tail -n 1 | cut -d '[' -f 2 | \ - head -c +2)" \ - -t 1000 + dunstify -h string:x-canonical-private-synchronous:audio \ + "Volume" "${mutes}" \ + -h int:value:"$(amixer sget Master | tail -n 1 | cut -d '[' -f 2 | \ + head -c +2)" \ + -t 1000 elif [[ ${1} == "brightness" ]]; then - brightnessctl set ${2} - dunstify -h string:x-canonical-private-synchronous:brightness \ - "Brightness" "$(brightnessctl | grep % | tail -c +22)" \ - -h int:value:"$(brightnessctl | grep % | cut -d '(' -f 2 | head -c +3)" \ - -t 1000 + brightnessctl set ${2} + dunstify -h string:x-canonical-private-synchronous:brightness \ + "Brightness" "$(brightnessctl | grep % | tail -c +22)" \ + -h int:value:"$(brightnessctl | grep % | cut -d '(' -f 2 | head -c +3)" \ + -t 1000 fi diff --git a/tweet-grab b/tweet-grab index b6e7fc0..b711bb1 100755 --- a/tweet-grab +++ b/tweet-grab @@ -9,5 +9,5 @@ LOGFILE=/root/tweets/cron.log INSTANCE=https://nitter.fdn.fr curl $INSTANCE/keshinko | grep tweet-content | head -n 1 \ - | sed -e 's/<[^>]*>//g' -e 's/^[ \t]*\(.*$\)/\1/' > $FILE + | sed -e 's/<[^>]*>//g' -e 's/^[ \t]*\(.*$\)/\1/' > $FILE date -R > $LOGFILE