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"
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
}
# 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
#!/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
# 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/"}
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
# 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
}
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
+++ /dev/null
-#!/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
#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)
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
#!/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
# 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
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