diff options
| author | Fuwn <[email protected]> | 2024-06-26 23:19:41 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-06-26 23:19:41 -0700 |
| commit | 7409da970efd8b2d44053786cbddc0fb980a0792 (patch) | |
| tree | 7f9d94a3778bcdeb129e847a9d4839546fbc077d /home | |
| parent | up (diff) | |
| download | home-manager-config-7409da970efd8b2d44053786cbddc0fb980a0792.tar.xz home-manager-config-7409da970efd8b2d44053786cbddc0fb980a0792.zip | |
scripts
Diffstat (limited to 'home')
| -rw-r--r-- | home/fuwn/meta/default.nix | 1 | ||||
| -rw-r--r-- | home/fuwn/meta/desktop/wayland/waybar/default.nix | 1 | ||||
| -rw-r--r-- | home/fuwn/meta/scripts/scripts/.gitignore | 4 | ||||
| -rwxr-xr-x | home/fuwn/meta/scripts/scripts/altserver | 9 | ||||
| -rwxr-xr-x | home/fuwn/meta/scripts/scripts/anidub | 1 | ||||
| -rwxr-xr-x | home/fuwn/meta/scripts/scripts/anime | 1 | ||||
| -rwxr-xr-x | home/fuwn/meta/scripts/scripts/apod | 4 | ||||
| -rwxr-xr-x | home/fuwn/meta/scripts/scripts/bt | 16 | ||||
| -rwxr-xr-x | home/fuwn/meta/scripts/scripts/catboy | 6 | ||||
| -rwxr-xr-x | home/fuwn/meta/scripts/scripts/chan2 | 1 | ||||
| -rwxr-xr-x | home/fuwn/meta/scripts/scripts/counter | 3 | ||||
| -rwxr-xr-x | home/fuwn/meta/scripts/scripts/hon | 9 | ||||
| -rwxr-xr-x | home/fuwn/meta/scripts/scripts/reco | 56 | ||||
| -rwxr-xr-x | home/fuwn/meta/scripts/scripts/rinny | 27 | ||||
| -rwxr-xr-x | home/fuwn/meta/scripts/scripts/shiori | 47 | ||||
| -rwxr-xr-x | home/fuwn/meta/scripts/scripts/skyla | 51 | ||||
| -rwxr-xr-x | home/fuwn/meta/scripts/scripts/start-vm | 19 | ||||
| -rwxr-xr-x | home/fuwn/meta/scripts/scripts/vivwal | 59 | ||||
| -rwxr-xr-x | home/fuwn/meta/scripts/scripts/wal_mako | 43 |
19 files changed, 358 insertions, 0 deletions
diff --git a/home/fuwn/meta/default.nix b/home/fuwn/meta/default.nix index 8205e71..db9b929 100644 --- a/home/fuwn/meta/default.nix +++ b/home/fuwn/meta/default.nix @@ -9,6 +9,7 @@ _: { ./image ./language ./rice + ./scripts ./spotify ./steam ./tools diff --git a/home/fuwn/meta/desktop/wayland/waybar/default.nix b/home/fuwn/meta/desktop/wayland/waybar/default.nix index 9d3d691..401efa8 100644 --- a/home/fuwn/meta/desktop/wayland/waybar/default.nix +++ b/home/fuwn/meta/desktop/wayland/waybar/default.nix @@ -71,6 +71,7 @@ ] ); }; + xdg.configFile = ( let scripts = [ diff --git a/home/fuwn/meta/scripts/scripts/.gitignore b/home/fuwn/meta/scripts/scripts/.gitignore new file mode 100644 index 0000000..bc90cf1 --- /dev/null +++ b/home/fuwn/meta/scripts/scripts/.gitignore @@ -0,0 +1,4 @@ +know +hime +mirrors +pok
\ No newline at end of file diff --git a/home/fuwn/meta/scripts/scripts/altserver b/home/fuwn/meta/scripts/scripts/altserver new file mode 100755 index 0000000..732a973 --- /dev/null +++ b/home/fuwn/meta/scripts/scripts/altserver @@ -0,0 +1,9 @@ +# 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 + +ALTSERVER_ANISETTE_SERVER=http://127.0.0.1:6969 python3 ~/.local/src/AltServer-Linux/main.py diff --git a/home/fuwn/meta/scripts/scripts/anidub b/home/fuwn/meta/scripts/scripts/anidub new file mode 100755 index 0000000..7a581b1 --- /dev/null +++ b/home/fuwn/meta/scripts/scripts/anidub @@ -0,0 +1 @@ +ANI_CLI_PLAYER=clapper ani-cli --dub --rofi "${1}" diff --git a/home/fuwn/meta/scripts/scripts/anime b/home/fuwn/meta/scripts/scripts/anime new file mode 100755 index 0000000..73e9f4f --- /dev/null +++ b/home/fuwn/meta/scripts/scripts/anime @@ -0,0 +1 @@ +ANI_CLI_PLAYER=mpv ani-cli --rofi "${1}" diff --git a/home/fuwn/meta/scripts/scripts/apod b/home/fuwn/meta/scripts/scripts/apod new file mode 100755 index 0000000..f0f38cd --- /dev/null +++ b/home/fuwn/meta/scripts/scripts/apod @@ -0,0 +1,4 @@ +printf \ + "https://apod.nasa.gov/apod/%s\\n" \ + "$(curl --silent "https://apod.nasa.gov/apod/" | + grep -Po 'SRC="\K[^"]+')" diff --git a/home/fuwn/meta/scripts/scripts/bt b/home/fuwn/meta/scripts/scripts/bt new file mode 100755 index 0000000..5760c27 --- /dev/null +++ b/home/fuwn/meta/scripts/scripts/bt @@ -0,0 +1,16 @@ +ctl=bluetoothctl + +connect() { + ${ctl} power on + ${ctl} connect "${1}" +} + +if [[ "${1}" == "ap" ]]; then + connect 0A:E1:61:05:31:FA +elif [[ "${1}" == "pro" ]]; then + connect C4:14:11:45:CF:60 +elif [[ "${1}" == "ctl" ]]; then + ${ctl} +else + ${ctl} +fi diff --git a/home/fuwn/meta/scripts/scripts/catboy b/home/fuwn/meta/scripts/scripts/catboy new file mode 100755 index 0000000..d94c233 --- /dev/null +++ b/home/fuwn/meta/scripts/scripts/catboy @@ -0,0 +1,6 @@ +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/fuwn/meta/scripts/scripts/chan2 b/home/fuwn/meta/scripts/scripts/chan2 new file mode 100755 index 0000000..9145fd8 --- /dev/null +++ b/home/fuwn/meta/scripts/scripts/chan2 @@ -0,0 +1 @@ +chan-downloader -c 10 --thread "${1}" -o "${2}" diff --git a/home/fuwn/meta/scripts/scripts/counter b/home/fuwn/meta/scripts/scripts/counter new file mode 100755 index 0000000..830b658 --- /dev/null +++ b/home/fuwn/meta/scripts/scripts/counter @@ -0,0 +1,3 @@ +gum spin -- ssh sina 'sqlite3 /var/lib/docker/volumes/counter/_data/count.db "select * from tb_count;"' | + awk -F\| '{printf "%-5s %s\n", $3, $2}' | + sort -n diff --git a/home/fuwn/meta/scripts/scripts/hon b/home/fuwn/meta/scripts/scripts/hon new file mode 100755 index 0000000..d0bd2ad --- /dev/null +++ b/home/fuwn/meta/scripts/scripts/hon @@ -0,0 +1,9 @@ +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/fuwn/meta/scripts/scripts/reco b/home/fuwn/meta/scripts/scripts/reco new file mode 100755 index 0000000..0aba038 --- /dev/null +++ b/home/fuwn/meta/scripts/scripts/reco @@ -0,0 +1,56 @@ +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/fuwn/meta/scripts/scripts/rinny b/home/fuwn/meta/scripts/scripts/rinny new file mode 100755 index 0000000..7d81fe4 --- /dev/null +++ b/home/fuwn/meta/scripts/scripts/rinny @@ -0,0 +1,27 @@ +DAYS=("Monday" "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday" "Sunday") +DAY="${1:-$(date +'%A')}" +CACHE="/tmp/rin_${DAY}" + +is_day_of_week() { + for day in "${DAYS[@]}"; do + if [[ ${1} == "${day}" ]]; then + return 0 + fi + done + + return 1 +} + +if ! is_day_of_week "${DAY}"; then + DAY="" +fi + +source "/home/fuwn/Documents/Code/Loose/Python/rin/venv/bin/activate" + +if [ ! -e "${CACHE}" ] || [ -n "${CACHE_BUST}" ]; then + python ~/Documents/Code/Loose/Python/rin/rin.py "${DAY}" >"${CACHE}" +fi + +echo +mdcat "${CACHE}" | sed 's/^/ /' +echo diff --git a/home/fuwn/meta/scripts/scripts/shiori b/home/fuwn/meta/scripts/scripts/shiori new file mode 100755 index 0000000..7430745 --- /dev/null +++ b/home/fuwn/meta/scripts/scripts/shiori @@ -0,0 +1,47 @@ +# 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/fuwn/meta/scripts/scripts/skyla b/home/fuwn/meta/scripts/scripts/skyla new file mode 100755 index 0000000..2434f08 --- /dev/null +++ b/home/fuwn/meta/scripts/scripts/skyla @@ -0,0 +1,51 @@ +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/fuwn/meta/scripts/scripts/start-vm b/home/fuwn/meta/scripts/scripts/start-vm new file mode 100755 index 0000000..37081f0 --- /dev/null +++ b/home/fuwn/meta/scripts/scripts/start-vm @@ -0,0 +1,19 @@ +# 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/fuwn/meta/scripts/scripts/vivwal b/home/fuwn/meta/scripts/scripts/vivwal new file mode 100755 index 0000000..995359e --- /dev/null +++ b/home/fuwn/meta/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/fuwn/meta/scripts/scripts/wal_mako b/home/fuwn/meta/scripts/scripts/wal_mako new file mode 100755 index 0000000..757cd5d --- /dev/null +++ b/home/fuwn/meta/scripts/scripts/wal_mako @@ -0,0 +1,43 @@ +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 |