]> git.armaanb.net Git - bin.git/commitdiff
Fix indentation on all programs
authorArmaan Bhojwani <me@armaanb.net>
Sun, 30 May 2021 16:20:04 +0000 (12:20 -0400)
committerArmaan Bhojwani <me@armaanb.net>
Sun, 30 May 2021 16:20:04 +0000 (12:20 -0400)
chrooter
fix-flatpak-theme
fmt-music
fortune
git-mirror
lolcat-gen [deleted file]
morse.c
passmenu
scoop-cgi
setter
tweet-grab

index 64403d640979d39490a709f5a24d4b424a5c53e3..49d74fd12398c591531f0359d346644c54b2e570 100755 (executable)
--- 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
 }
index 3dc7ff920596f900598c0d41bfab760eb91ab872..2b0ab776c7ef7ffebbae735bde6ec4c54a09225b 100755 (executable)
@@ -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
index e578a0330e948050985899b35268893b369a9cc6..90457aa653bb4148174a3f5e445dac86731ae2a3 100755 (executable)
--- 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 fde90857a6d61e6d17080364c1c9a470158f888a..afb967c5833679af35705ec5e21b64a63731ff39 100755 (executable)
--- 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 || len<minlen ) {
-    fortunes[f] = ""
-  } else {
-    f++
-  }
+       len = length(fortunes[f])
+       if ( len>maxlen || len<minlen ) {
+               fortunes[f] = ""
+       } else {
+               f++
+       }
 }
 
 {
-  sub("%", "")
-  fortunes[f] = fortunes[f] (length(fortunes[f])?"\n":"") $0
+       sub("%", "")
+       fortunes[f] = fortunes[f] (length(fortunes[f])?"\n":"") $0
 }
 
 END {
-  "od -A n -t d -N 3 /dev/urandom" | getline seed
-  srand(seed)
-  print fortunes[int(rand() * (f - 2)) + 1]
+       "od -A n -t d -N 3 /dev/urandom" | getline seed
+       srand(seed)
+       print fortunes[int(rand() * (f - 2)) + 1]
 }' $FILE
index 6d3f00cad6a7e6810d7b72deefd9834796909630..a6eaa6b8b84bcbec73d7fe1e220280da70d3f4b0 100755 (executable)
@@ -2,7 +2,7 @@
 # Mirror some Git repos
 
 usage() {
-  echo 'Usage: git-mirror [command] [arguments]
+               echo 'Usage: git-mirror [command] [arguments]
   git-mirror run [path to repos] [path to log file] [html directory]
       optional: [sleep duration]
   git-mirror gen-url [path to repo] -- generate url file in repo
@@ -13,59 +13,59 @@ usage() {
 }
 
 run() {
-  [ -z ${3} ] && echo "not enough arguments" && exit 1
-  [ -z $(which stagit) ] && echo "please install stagit" && exit 1
-  [ -z $(which minify) ] && echo "please install minify" && exit 1
+               [ -z ${3} ] && echo "not enough arguments" && exit 1
+               [ -z $(which stagit) ] && echo "please install stagit" && exit 1
+               [ -z $(which minify) ] && echo "please install minify" && exit 1
 
-  cd ${1}
+               cd ${1}
 
-  [ -d ${3} ] || mkdir ${3}
-  cd ${3}
+               [ -d ${3} ] || mkdir ${3}
+               cd ${3}
 
-  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
+               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 (executable)
index 333bf73..0000000
+++ /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 5f3f58941b3d13377ef7539adf2ade624a63747a..e535e6f3f6302fee55712d7240acae4828b8c252 100644 (file)
--- a/morse.c
+++ b/morse.c
@@ -7,14 +7,17 @@
 #include <stdlib.h>
 #include <unistd.h>
 
-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)
index 44681efce03b9fcccc174b3867885de69cca1735..e54439a617d38de402938bae61c8cfde5b6db698 100755 (executable)
--- 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
index 00241c4667c53fd7718f883f2bec9ecf9bd920e1..b7531ecb7df6192252ccb70709ccb01f9040593d 100755 (executable)
--- 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 abdffd589178b7bce2da77511623952c5f2788ea..b13adfbfffa5328a91a6383dafffeb461015803f 100755 (executable)
--- 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
index b6e7fc091da43fc04eecbbb932acbe6b8b93b2c5..b711bb15c99545dd1a5db345050e9b19e65a06f9 100755 (executable)
@@ -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