diff options
| author | Fuwn <[email protected]> | 2024-08-29 21:31:09 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-08-29 21:31:09 -0700 |
| commit | 653f81eec07eb3e33c380810676a7feb45e1df43 (patch) | |
| tree | 00d43c8f1b2cb2cf8ebaf1b7c1a4c026718033bb /home/ebisu/fortune/scripts | |
| parent | some stuff (diff) | |
| download | nixos-config-653f81eec07eb3e33c380810676a7feb45e1df43.tar.xz nixos-config-653f81eec07eb3e33c380810676a7feb45e1df43.zip | |
some stuff
Diffstat (limited to 'home/ebisu/fortune/scripts')
22 files changed, 620 insertions, 0 deletions
diff --git a/home/ebisu/fortune/scripts/default.nix b/home/ebisu/fortune/scripts/default.nix new file mode 100644 index 0000000..58851ea --- /dev/null +++ b/home/ebisu/fortune/scripts/default.nix @@ -0,0 +1,13 @@ +{ pkgs, ... }: +let + scriptDir = ./scripts; + generateScripts = builtins.listToAttrs (builtins.map + (name: { + name = name; + value = pkgs.writeShellScriptBin name (builtins.readFile "${scriptDir}/${name}"); + }) + (builtins.attrNames (builtins.readDir scriptDir))); +in +{ + home.packages = builtins.attrValues generateScripts; +} diff --git a/home/ebisu/fortune/scripts/scripts/.gitignore b/home/ebisu/fortune/scripts/scripts/.gitignore new file mode 100644 index 0000000..2ea4e67 --- /dev/null +++ b/home/ebisu/fortune/scripts/scripts/.gitignore @@ -0,0 +1,8 @@ +know +hime +mirrors +pok +bt +counter +rinny +suzuri
\ No newline at end of file diff --git a/home/ebisu/fortune/scripts/scripts/altserver b/home/ebisu/fortune/scripts/scripts/altserver new file mode 100755 index 0000000..0a0d5f9 --- /dev/null +++ b/home/ebisu/fortune/scripts/scripts/altserver @@ -0,0 +1,12 @@ +# Wrapper around AltServer for usage on *nix + +# doas usbmuxd & + +# export USBMUXD_SOCKET_ADDRESS=127.0.0.1:27015 + +# doas netmuxd --disable-unix --host 127.0.0.1 & + +docker run -d -v lib_cache:/opt/lib/ --restart=always -p 6969:6969 --name anisette dadoum/anisette-server:latest + +# Not very Nix .... +ALTSERVER_ANISETTE_SERVER=http://127.0.0.1:6969 python3 ~/.local/src/AltServer-Linux/main.py diff --git a/home/ebisu/fortune/scripts/scripts/anidub b/home/ebisu/fortune/scripts/scripts/anidub new file mode 100755 index 0000000..aacf84f --- /dev/null +++ b/home/ebisu/fortune/scripts/scripts/anidub @@ -0,0 +1,3 @@ +# Wrapper around ani-cli (dubbed) for Rofi + +ANI_CLI_PLAYER=clapper ani-cli --dub --rofi "${1}" diff --git a/home/ebisu/fortune/scripts/scripts/anime b/home/ebisu/fortune/scripts/scripts/anime new file mode 100755 index 0000000..60b143b --- /dev/null +++ b/home/ebisu/fortune/scripts/scripts/anime @@ -0,0 +1,3 @@ +# Wrapper around ani-cli for Rofi + +ANI_CLI_PLAYER=mpv ani-cli --rofi "${1}" diff --git a/home/ebisu/fortune/scripts/scripts/apod b/home/ebisu/fortune/scripts/scripts/apod new file mode 100755 index 0000000..a8814a9 --- /dev/null +++ b/home/ebisu/fortune/scripts/scripts/apod @@ -0,0 +1,6 @@ +# Get today's Astronomy Picture of the Day (APOD) from NASA + +printf \ + "https://apod.nasa.gov/apod/%s\\n" \ + "$(curl --silent "https://apod.nasa.gov/apod/" | + grep -Po 'SRC="\K[^"]+')" diff --git a/home/ebisu/fortune/scripts/scripts/catboy b/home/ebisu/fortune/scripts/scripts/catboy new file mode 100755 index 0000000..cc75e52 --- /dev/null +++ b/home/ebisu/fortune/scripts/scripts/catboy @@ -0,0 +1,8 @@ +# VPN wrapper around catgirl + +vpn_ip="$(piactl get vpnip)" + +BIND_INTERFACE=wgpia0 \ + LD_PRELOAD=/usr/lib/bindtointerface.so \ + BIND_SOURCE_IP=${vpn_ip} \ + catgirl "${1}" diff --git a/home/ebisu/fortune/scripts/scripts/chan2 b/home/ebisu/fortune/scripts/scripts/chan2 new file mode 100755 index 0000000..525d5f1 --- /dev/null +++ b/home/ebisu/fortune/scripts/scripts/chan2 @@ -0,0 +1,3 @@ +# Tiny wrapper around chan-downloader + +chan-downloader -c 10 --thread "${1}" -o "${2}" diff --git a/home/ebisu/fortune/scripts/scripts/fim b/home/ebisu/fortune/scripts/scripts/fim new file mode 100755 index 0000000..d1be1c5 --- /dev/null +++ b/home/ebisu/fortune/scripts/scripts/fim @@ -0,0 +1,20 @@ +# Finger "blog" updater + +HOST="sina" + +while getopts "f" opt; do + case ${opt} in + f) FORMAT=true ;; + *) FORMAT=false ;; + esac +done + +shift $((OPTIND - 1)) + +PROFILE="/var/lib/docker/volumes/gigi-data/_data/${1:-fuwn}" + +if [ -n "${FORMAT}" ]; then + ssh -t "${HOST}" "vim -c 'autocmd BufWritePost * !fmt -w 80 % > %.tmp && mv %.tmp %' '${PROFILE}'" +else + ssh -t "${HOST}" "vim '${PROFILE}'" +fi diff --git a/home/ebisu/fortune/scripts/scripts/gmiwatch b/home/ebisu/fortune/scripts/scripts/gmiwatch new file mode 100755 index 0000000..cf3e52a --- /dev/null +++ b/home/ebisu/fortune/scripts/scripts/gmiwatch @@ -0,0 +1,24 @@ +# Gemini capsule watcher, used for development + +usage() { + echo "usage: ${0} [-n interval] <url>" + + exit 1 +} + +while getopts "n:" opt; do + case ${opt} in + n) + interval=${OPTARG} + + shift 2 + ;; + *) usage ;; + esac +done + +if [ -z "${1}" ]; then + usage +fi + +watch -n "${interval:-5}" -t gmni -j always "gemini://${1}" diff --git a/home/ebisu/fortune/scripts/scripts/hon b/home/ebisu/fortune/scripts/scripts/hon new file mode 100755 index 0000000..b4436ec --- /dev/null +++ b/home/ebisu/fortune/scripts/scripts/hon @@ -0,0 +1,11 @@ +# Personal manga feed wrapper around Suzuri + +SUZURI_MINIMAL=1 \ + SUZURI_REVERSE=1 \ + suzuri \ + AXHJex1ZiWcQFSzUKhQ5uW \ + Anime | + grep -iF manga | + sed -E 's|http[s]?://[^ ]+||g' | + sed 's/^/* /' | + tac # | glow -w 2048 diff --git a/home/ebisu/fortune/scripts/scripts/locs b/home/ebisu/fortune/scripts/scripts/locs new file mode 100755 index 0000000..7b0ea19 --- /dev/null +++ b/home/ebisu/fortune/scripts/scripts/locs @@ -0,0 +1,102 @@ +# Silly lines-of-code counter + +DEFAULT_COMMENT_STYLES='(//|#|/\*|\*|<!--|-->)' +FILE_MAX_LENGTH=5 + +count_non_empty_lines() { + local file="${1}" + grep -cve '^\s*$' "${file}" +} + +process_files() { + for file in "$@"; do + if [ -f "${file}" ]; then + if [ ${#file} -gt "${longest_filename}" ]; then + longest_filename=${#file} + fi + fi + done + + for file in "$@"; do + if [ -f "${file}" ]; then + lines=$(count_non_empty_lines "${file}") + total_lines=$((total_lines + lines)) + + case "${file}" in + *.gleam) COMMENT_STYLE='(//)' ;; + *.cc | *.hh | *.cpp | *.hpp | *.c | *.h) COMMENT_STYLE='(//|/\*)' ;; + *) COMMENT_STYLE=${DEFAULT_COMMENT_STYLES} ;; + esac + + comments=$(grep -E "^\s*${COMMENT_STYLE}\s*.*\s*$" "${file}" | grep -v '^\s*$' | wc -l) + total_comments=$((total_comments + comments)) + + printf "%-${longest_filename}s %-${FILE_MAX_LENGTH}s %s\n" "${file}" "$((lines - comments))" "${comments}" + + if [ "${LOCS_PRINT_COMMENTS:-0}" = 1 ]; then + grep -n -E "^\s*${COMMENT_STYLE}\s*.*\s*$" "${file}" | grep -v '^\s*$' | sed 's/^/ /' | sed 's/\s*\/\///' | sed 's/\([0-9]\+\): /\1 | /' + + if [ "${comments}" -gt 0 ]; then + echo + fi + fi + fi + done +} + +main() { + local total_lines=0 + local total_comments=0 + local longest_filename=0 + + if [ -z "$1" ]; then + cat <<EOF +usage: ${0} <glob_pattern> + +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢲⢄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⠄⠂⢉⠤⠐⠋⠈⠡⡈⠉⠐⠠⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ +⠀⠀⠀⠀⢀⡀⢠⣤⠔⠁⢀⠀⠀⠀⠀⠀⠀⠀⠈⢢⠀⠀⠈⠱⡤⣤⠄⣀⠀⠀⠀⠀⠀ +⠀⠀⠰⠁⠀⣰⣿⠃⠀⢠⠃⢸⠀⠀⠀⠀⠀⠀⠀⠀⠁⠀⠀⠀⠈⢞⣦⡀⠈⡇⠀⠀⠀ +⠀⠀⠀⢇⣠⡿⠁⠀⢀⡃⠀⣈⠀⠀⠀⠀⢰⡀⠀⠀⠀⠀⢢⠰⠀⠀⢺⣧⢰⠀⠀⠀⠀ +⠀⠀⠀⠈⣿⠁⡘⠀⡌⡇⠀⡿⠸⠀⠀⠀⠈⡕⡄⠀⠐⡀⠈⠀⢃⠀⠀⠾⠇⠀⠀⠀⠀ +⠀⠀⠀⠀⠇⡇⠃⢠⠀⠶⡀⡇⢃⠡⡀⠀⠀⠡⠈⢂⡀⢁⠀⡁⠸⠀⡆⠘⡀⠀⠀⠀⠀ +⠀⠀⠀⠸⠀⢸⠀⠘⡜⠀⣑⢴⣀⠑⠯⡂⠄⣀⣣⢀⣈⢺⡜⢣⠀⡆⡇⠀⢣⠀⠀⠀⠀ +⠀⠀⠀⠇⠀⢸⠀⡗⣰⡿⡻⠿⡳⡅⠀⠀⠀⠀⠈⡵⠿⠿⡻⣷⡡⡇⡇⠀⢸⣇⠀⠀⠀ +⠀⠀⢰⠀⠀⡆⡄⣧⡏⠸⢠⢲⢸⠁⠀⠀⠀⠀⠐⢙⢰⠂⢡⠘⣇⡇⠃⠀⠀⢹⡄⠀⠀ +⠀⠀⠟⠀⠀⢰⢁⡇⠇⠰⣀⢁⡜⠀⠀⠀⠀⠀⠀⠘⣀⣁⠌⠀⠃⠰⠀⠀⠀⠈⠰⠀⠀ +⠀⡘⠀⠀⠀⠀⢊⣤⠀⠀⠤⠄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠤⠄⠀⢸⠃⠀⠀⠀⠀⠀⠃⠀ +⢠⠁⢀⠀⠀⠀⠈⢿⡀⠀⠀⠀⠀⠀⠀⢀⡀⠀⠀⠀⠀⠀⠀⢀⠏⠀⠀⠀⠀⠀⠀⠸⠀ +⠘⠸⠘⡀⠀⠀⠀⠀⢣⠀⠀⠀⠀⠀⠀⠁⠀⠃⠀⠀⠀⠀⢀⠎⠀⠀⠀⠀⠀⢠⠀⠀⡇ +⠀⠇⢆⢃⠀⠀⠀⠀⠀⡏⢲⢤⢀⡀⠀⠀⠀⠀⠀⢀⣠⠄⡚⠀⠀⠀⠀⠀⠀⣾⠀⠀⠀ +⢰⠈⢌⢎⢆⠀⠀⠀⠀⠁⣌⠆⡰⡁⠉⠉⠀⠉⠁⡱⡘⡼⠇⠀⠀⠀⠀⢀⢬⠃⢠⠀⡆ +⠀⢢⠀⠑⢵⣧⡀⠀⠀⡿⠳⠂⠉⠀⠀⠀⠀⠀⠀⠀⠁⢺⡀⠀⠀⢀⢠⣮⠃⢀⠆⡰⠀ +⠀⠀⠑⠄⣀⠙⡭⠢⢀⡀⠀⠁⠄⣀⣀⠀⢀⣀⣀⣀⡠⠂⢃⡀⠔⠱⡞⢁⠄⣁⠔⠁⠀ +⠀⠀⠀⠀⠀⢠⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠸⠉⠁⠀⠀⠀⠀ +⠀⠀⠀⠀⠀⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀ + +EOF + + exit 1 + fi + + local files + + files=$(find "${@}" -type f) + + process_files ${files} >/tmp/lines + + if [ "${LOCS_HEADER:-1}" = 1 ]; then + printf "%-${longest_filename}s %-${FILE_MAX_LENGTH}s %s\n" "filename" "lines" "comments" + fi + + if [ "${LOCS_PRINT_COMMENTS:-0}" = 1 ] || [ "${LOCS_SORT:-1}" = 0 ]; then + cat /tmp/lines + else + sort -k2nr </tmp/lines + fi + + printf "%-${longest_filename}s %-${FILE_MAX_LENGTH}s %s\n" "total" "$((total_lines - total_comments))" "${total_comments}" +} + +main "$@" diff --git a/home/ebisu/fortune/scripts/scripts/neovide-lunarvim b/home/ebisu/fortune/scripts/scripts/neovide-lunarvim new file mode 100644 index 0000000..502a3f1 --- /dev/null +++ b/home/ebisu/fortune/scripts/scripts/neovide-lunarvim @@ -0,0 +1,7 @@ +# ref: https://aur.archlinux.org/cgit/aur.git/tree/script.sh?h=neovide-lunarvim + +export LUNARVIM_CONFIG_DIR="${LUNARVIM_CONFIG_DIR:-$HOME/.config/lvim}" +export LUNARVIM_RUNTIME_DIR="${LUNARVIM_RUNTIME_DIR:-$HOME/.local/share/lunarvim}" +export LUNARVIM_CACHE_DIR="${LUNARVIM_CACHE_DIR:-$HOME/.cache/lvim}" + +exec neovide -- -u "$LUNARVIM_RUNTIME_DIR/lvim/init.lua" "$@" diff --git a/home/ebisu/fortune/scripts/scripts/reco b/home/ebisu/fortune/scripts/scripts/reco new file mode 100755 index 0000000..9402a1a --- /dev/null +++ b/home/ebisu/fortune/scripts/scripts/reco @@ -0,0 +1,58 @@ +# COBOL line number incrementer + +if [ "$#" -lt 1 ]; then + echo "usage: $0 [-i x] filename" + + exit 1 +fi + +increment=10 +start_value=10 +filename="" + +while getopts "i:s:" opt; do + case ${opt} in + i) + increment=1 + start_value=${OPTARG} + ;; + s) + start_value=${OPTARG} + ;; + \?) + echo "invalid option: -${OPTARG}" + echo "usage: $0 [-i x] filename" + exit 1 + ;; + :) + echo "option -${OPTARG} requires an argument." + echo "usage: $0 [-i x] filename" + exit 1 + ;; + *) ;; + esac +done + +shift $((OPTIND - 1)) + +if [ -z "$1" ]; then + echo "usage: $0 [-i x] filename" + + exit 1 +fi + +filename="$1" +tmpfile1=$(mktemp) +# tmpfile2=$(mktemp) + +awk -v inc="${increment}" -v start="${start_value}" '{ + new_line_number = sprintf("%06d", start + (NR - 1) * inc); + print new_line_number substr($0, 7); +}' "${filename}" >"${tmpfile1}" + +# awk '{ +# print substr($0, 1, 74) sprintf("%06d", NR) substr($0, 81); +# }' "${tmpfile1}" >"${tmpfile2}" + +# mv "${tmpfile2}" "${filename}" +mv "${tmpfile1}" "${filename}" diff --git a/home/ebisu/fortune/scripts/scripts/setbg b/home/ebisu/fortune/scripts/scripts/setbg new file mode 100755 index 0000000..a399344 --- /dev/null +++ b/home/ebisu/fortune/scripts/scripts/setbg @@ -0,0 +1,75 @@ +background_location="${XDG_DATA_HOME:-${HOME}/.local/share}/bg" +dunst_configuration_file="${XDG_CONFIG_HOME:-${HOME}/.config}/dunst/dunstrc" +zathura_configuration_file="${XDG_CONFIG_HOME:-${HOME}/.config}/zathura/zathurarc" + +while getopts "s" o; do case "${o}" in + s) silent='1' ;; + *) ;; + esac done + +shift $((OPTIND - 1)) + +true_background_location="$(readlink -f "$1")" && + case "$(file --mime-type -b "${true_background_location}")" in + image/*) + ln -sf "${true_background_location}" "${background_location}" && + [ -z "${silent}" ] && + notify-send -i "${background_location}" "Changing wallpaper ..." + ;; + inode/directory) + link=$(find "${true_background_location}" -iregex '.*.\(jpg\|jpeg\|png\|gif\)' -type f | shuf -n 1) + + ln -sf "${link}" "${background_location}" && [ -z "${silent}" ] && notify-send -i "${background_location}" "Random wallpaper chosen." + ;; + *) + [ -z "${silent}" ] && + notify-send "Error" "Invalid image or directory found." + + exit 1 + ;; + esac + +if command -v wal >/dev/null 2>&1; then + link=$(readlink -f "${background_location}") + + wal -n -i "${link}" -o "${XDG_CONFIG_HOME:-${HOME}/.config}/wal/postrun" >/dev/null 2>&1 +else + [ -f "${dunst_configuration_file}.bak" ] && + unlink "${dunst_configuration_file}" && + mv "${dunst_configuration_file}.bak" "${dunst_configuration_file}" + + [ -f "${zathura_configuration_file}.bak" ] && + unlink "${zathura_configuration_file}" && + mv "${zathura_configuration_file}.bak" "${zathura_configuration_file}" +fi + +case "$(loginctl show-session 1 -p Type)" in +*"wayland") + hyprpaper_configuration_file="${HOME}/.config/hypr/hyprpaper.conf" + + cp "${HOME}/.cache/wal/colors-waybar.css" "${HOME}/.config/waybar/colors-waybar.css" + cp "${hyprpaper_configuration_file}" "${hyprpaper_configuration_file}.bak" + + if pidof hyprpaper >/dev/null; then + awk -v newpath="${true_background_location}" ' +BEGIN { FS = OFS = "=" } +/^preload/ { + $2 = " " newpath +} +/^wallpaper/ { + split($2, a, ","); + $2 = a[1] "," newpath +} +{ print } +' "${hyprpaper_configuration_file}.bak" >"${hyprpaper_configuration_file}" + killall -9 hyprpaper >/dev/null + hyprpaper >/dev/null & + elif pidof swww-daemon >/dev/null; then + swww img "${true_background_location}" & + fi + ;; +*) + xwallpaper --zoom "${background_location}" + pidof sei >/dev/null && xdotool key super+F5 + ;; +esac diff --git a/home/ebisu/fortune/scripts/scripts/shiori b/home/ebisu/fortune/scripts/scripts/shiori new file mode 100755 index 0000000..5f825e7 --- /dev/null +++ b/home/ebisu/fortune/scripts/scripts/shiori @@ -0,0 +1,49 @@ +# Random ASCII art + +# https://zh.moegirl.org.cn/Shift_JIS%E8%89%BA%E6%9C%AF +art=() + +# http://aa.en.utf8art.com/node/52/txtcaa +read -r -d '' art['0'] <<EOF + / ̄ヽ + / ヽ / r'il +. / ハ/ ハlヽ、 + _/ /´ /\`ーイヽ ヽ ヽ + { _/// 斗‐ト l‐十-、', i +  ̄ l l |´f iヽ |ィTヽ、 .l l + lハ. |.hj ` ヒ_リ iヽ! .l あけおめ + ヽト、" ' _, ""ノ l l + l >r,、┐.l l l + l l 〈〉V l ハ l + _ ヽ.l 〈o'7 l/ l l + ll ヽ. l ll l、 \l + ll 〉、_i⌒iiヽ_ll_∠´ \/"゙ミ; + ll _l_l_ll l/ヽ_| r/'ゞ, ン +  ̄ }_{ l / `´ + l_jl_ノ´ +EOF + +read -r -d '' art['1'] <<EOF + ,. -‐- 、 + / _...._ i + ,.-- 、 , ´/.::::::..゙i ,' + / .: ヽ ._p_ / ,.'..:::::::::::,.'/ + ! ヾ 、 丶 (::::::) ,' /..:::::::::::/ + l l::..ヽ γ''' ̄ ̄'''ヽ/ ,':::::::::./ + | l:::::::..ヽ |_____| l.';.::, '/ + ! lヽ::::::;.:.〉: : : :.:.:.:|: : : :'‐'"<_ + ! / ゙7 /: :.,イ: :./|:.!: \: .: : : : :<⌒ヽ + ! /: :/: :./___/ !: / .|:.|l: .:__ヽ: :.\:.:ヽ\ \ + `‐'"イ: :/: :./´:./` |/ |:.||ヽ: :`ヽ: : :.ヽ: :} \{ + /: :.': :.:i: :./ | Ⅵ \: :|: : : :.∨ / +. ': : { : : |:./ ,_ _, ヽ!:.:: :.|:.:|ィ´ + |: :/|: : :|イ ィ=ミ ィ=ミ } : : ト、!:| + |;イ: ! :./\`| ム : : |:/: | あけまして + |:|.:V:l\`ri^ixx 、__, xxrvィヘ : |: : :| + |:|: : :l: :〉、\`ー-、 .___ ,.-‐' /:.:.:V: : : | + |:|: : :l:/ `ァ 〉r‐┤ r‐':./}:!: : : :| + |:|: : :l{. / /:.:l ./| |: :/ |:l:.:. :.:.| + |:|: : :l| / ∧:.:|/:.l |:/ .!:l: : :.:.| +EOF + +echo "\`\`\`${art[$((RANDOM % ${#art[@]}))]}\`\`\`" | glow diff --git a/home/ebisu/fortune/scripts/scripts/skyla b/home/ebisu/fortune/scripts/scripts/skyla new file mode 100755 index 0000000..a0d9030 --- /dev/null +++ b/home/ebisu/fortune/scripts/scripts/skyla @@ -0,0 +1,53 @@ +# yt-dlp wrapper for Crunchyroll + +if [[ "$2" = "dl" ]]; then + START=$(date +%s) + + yt-dlp \ + --all-subs \ + --cookies-from-browser firefox \ + --embed-subs \ + --external-downloader=aria2c \ + --external-downloader-args \ + '--min-split-size=1M --max-connection-per-server=16 --max-concurrent-downloads=16 --split=16' \ + -f 'best[height=1080]' \ + --remux mkv \ + --merge mkv \ + --verbose \ + --user-agent "Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20100101 Firefox/10.0" \ + "${1}" + + printf "\ntook %s seconds\n" $(($(date +%s || true) - START)) +else + # mpv "$(yt-dlp \ + # --cookies-from-browser firefox \ + # --extractor-args crunchyrollbeta:hardsub=en-US \ + # -f 'best[height=1080]' \ + # -g \ + # --verbose \ + # "${1}")" + + yt-dlp \ + --cookies-from-browser firefox \ + --no-download \ + -o /tmp/skyla_subtitles \ + --sub-lang en-US \ + --write-subs \ + --user-agent "Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20100101 Firefox/10.0" \ + "${1}" + + if [[ "$2" = "fix" ]]; then + sed -i 's/{an\d*}//g' /tmp/skyla_subtitles.*.ass + fi + + mplayer \ + -sub /tmp/skyla_subtitles.*.ass \ + "$(yt-dlp \ + --cookies-from-browser firefox \ + -f 'best[height=1080]' \ + -g \ + --user-agent "Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20100101 Firefox/10.0" \ + "${1}")" + + rm /tmp/skyla_subtitles.*.ass +fi diff --git a/home/ebisu/fortune/scripts/scripts/start-vm b/home/ebisu/fortune/scripts/scripts/start-vm new file mode 100755 index 0000000..df372c1 --- /dev/null +++ b/home/ebisu/fortune/scripts/scripts/start-vm @@ -0,0 +1,21 @@ +# Virtual machine start script + +# ref: https://askubuntu.com/questions/425754/how-do-i-run-a-sudo-command-inside-a-script +USER_ID=$(id -u) + +# ref: https://askubuntu.com/a/30157/8698 +if ! [[ ${USER_ID} = 0 ]]; then + echo "The script need to be run as root. >:)" >&2 + + exit 1 +fi + +# if [ "${SUDO_USER}" ]; then +# real_user=$SUDO_USER +# else +# real_user=$(whoami) +# fi + +systemctl start libvirtd >/dev/null && echo "libvirtd started" + +virsh net-start default >/dev/null && echo "default network started" diff --git a/home/ebisu/fortune/scripts/scripts/tup-init b/home/ebisu/fortune/scripts/scripts/tup-init new file mode 100644 index 0000000..387fa53 --- /dev/null +++ b/home/ebisu/fortune/scripts/scripts/tup-init @@ -0,0 +1,25 @@ +tup init >/dev/null + +cat <<EOF >Tupfile +# Input & Output Directories +SOURCE_DIRECTORY = . +INCLUDE_DIRECTORY = . +BUILD_DIRECTORY = build + +# Compiler Configuration +CC = clang++ +CC_EXTENSION = cc +CC_FLAGS = -std=c++23 -I \$(INCLUDE_DIRECTORY) -Weverything -Wno-padded -Wno-c++98-compat -MMD -Wno-c++98-compat-pedantic + +# Clang-tidy Configuration +CLANG_TIDY_CHECKS = '-*,bugprone-*,clang-analyzer-*,concurrency-*,cppcoreguildelines-*,llvm-*,misc-*,modernize-*,performance-*,portability-*,readability-*,-readability-magic-numbers,-llvm-header-guard,-bugprone-suspicious-include,-readability-function-cognitive-complexity,-bugprone-exception-escape' +CLANG_TIDY_FLAGS = -checks=\$(CLANG_TIDY_CHECKS) -warnings-as-errors=* -quiet + +NAME = $(basename "$(pwd)") + +: foreach \$(SOURCE_DIRECTORY)/*.\$(CC_EXTENSION) \$(INCLUDE_DIRECTORY)/*.hh |> clang-format -i %f |> +: foreach \$(SOURCE_DIRECTORY)/*.\$(CC_EXTENSION) |> clang-tidy \$(CLANG_TIDY_FLAGS) %f -- \$(CC_FLAGS) |> +: foreach \$(SOURCE_DIRECTORY)/*.\$(CC_EXTENSION) |> ^j^ \$(CC) \$(CC_FLAGS) -MF \$(BUILD_DIRECTORY)/%B.d -c %f -o %o |> \$(BUILD_DIRECTORY)/%B.o | \$(BUILD_DIRECTORY)/%B.d +: \$(BUILD_DIRECTORY)/*.o ^test.o |> \$(CC) %f -o %o |> \$(BUILD_DIRECTORY)/\$(NAME) +: \$(BUILD_DIRECTORY)/*.o ^main.o |> \$(CC) %f -o %o |> \$(BUILD_DIRECTORY)/\$(NAME)_test +EOF diff --git a/home/ebisu/fortune/scripts/scripts/vivwal b/home/ebisu/fortune/scripts/scripts/vivwal new file mode 100755 index 0000000..995359e --- /dev/null +++ b/home/ebisu/fortune/scripts/scripts/vivwal @@ -0,0 +1,59 @@ +# Sets Vivaldi's theme colors to those generated by Wal. +# Source: https://forum.vivaldi.net/topic/34521/linux-changing-theme-via-command-line/22?_=1597433612704 +# Author: Vivaldi Forum user Wismut + +logfile=~/.log/vivwal.log + +text_color="#eeeeee" +if [[ "$1" && "$1" == "-l" ]]; then + text_color="#111111" +fi + +# Source Wal colors (replace this path with the path where the colors generated by wal are stored) +source ~/.cache/wal/colors.sh + +# testing if vivaldi is running +PROCESS1=vivaldi +PROCESS2=crconsole +PIDS_Vivaldi=$(ps cax | grep $PROCESS1 | grep -o '^[ ]*[0-9]*') +PIDS_crconsole=$(ps cax | grep $PROCESS2 | grep -o '^[ ]*[0-9]*') +if [ -z "$PIDS_Vivaldi" ]; then + # Vivaldi is not running + if [ -z "$PIDS_crconsole" ]; then + echo "All is fine. Neither Vivaldi nor crconsole are running." 1>&2 + else + # kill crconsole + pkill -f "node /usr/bin/crconsole" + fi +else + # Vivaldi is running + # let's start using crconsole + # find all open tabs + tablist=$( + echo .tabs | crconsole & + sleep 1 + pkill -f "node /usr/bin/crconsole" + ) + # read each tab + while read -r line; do + echo "... $line ..." + # find /browser.html tab + if [[ $line == *"/browser.html"* ]]; then + tabnumber=$(echo "$line" | grep -o '[0-9]\+') + # change Vivaldi accent background colors + var=$( + ( + echo ".switch $tabnumber" + sleep 1 + echo "chrome.storage.local.set({'BROWSER_COLOR_BG':'$background', 'BROWSER_COLOR_FG':'$text_color', 'BROWSER_COLOR_ACCENT_BG':'$color5', 'BROWSER_COLOR_HIGHLIGHT_BG':'$color1'})" + ) | crconsole & + sleep 1 + pkill -f "node /usr/bin/crconsole" + ) + echo "$var" >$logfile + fi + done <<<"$tablist" + sleep 1 + pkill -f "node /usr/bin/crconsole" +fi +exit diff --git a/home/ebisu/fortune/scripts/scripts/wal_mako b/home/ebisu/fortune/scripts/scripts/wal_mako new file mode 100755 index 0000000..5cf4b1f --- /dev/null +++ b/home/ebisu/fortune/scripts/scripts/wal_mako @@ -0,0 +1,45 @@ +# Mako colourscheme setter for use with pywal + +MAKO_CTL="/usr/bin/makoctl" +MAKO_CONFIG="${HOME}/.config/mako/config" +MAKO_CONFIG_TEMPLATE="${MAKO_CONFIG}.template" +WAL_COLOURS="${HOME}/.cache/wal/colors" + +cp "${MAKO_CONFIG_TEMPLATE}" "${MAKO_CONFIG}" + +colour_iteration=0 + +while IFS= read -r line; do + eval "COLOR${colour_iteration}=\"${line}\"" + + colour_iteration=$((colour_iteration + 1)) +done <"${WAL_COLOURS}" + +unset colour_iteration + +cat <<EOF >>"${MAKO_CONFIG}" +background-color=${COLOR0} +text-color=${COLOR15} + +# [urgency=low] +# border-color=${COLOR2} +# background-color=${COLOR4} +# text-color=${COLOR6} + +# [urgency=normal] +# border-color=${COLOR1} +# background-color=${COLOR3} +# text-color=${COLOR5} +# default-timeout=10000 +# ignore-timeout=1 + +# [urgency=high] +# font=Sauce Code Pro 16 +# border-color=${COLOR1} +# background-color=${COLOR2} +# text-color=${COLOR6} +# default-timeout=0 +# ignore-timeout=1 +EOF + +${MAKO_CTL} reload diff --git a/home/ebisu/fortune/scripts/scripts/worlds b/home/ebisu/fortune/scripts/scripts/worlds new file mode 100755 index 0000000..834079a --- /dev/null +++ b/home/ebisu/fortune/scripts/scripts/worlds @@ -0,0 +1,15 @@ +# WorldsPlayer runner for use in Bottles + +NAMESPACE=worlds + +# kitty -e doas termshark -i worlds_vo & +wireshark -k -i "${NAMESPACE}_vo" & + +doas runnet \ + --publish-all-ports \ + --user=fuwn \ + --netns=${NAMESPACE} \ + --internet \ + bottles-cli run \ + -p WorldsPlayer \ + -b 'WorldsPlayer' |