From 7409da970efd8b2d44053786cbddc0fb980a0792 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Wed, 26 Jun 2024 23:19:41 -0700 Subject: scripts --- home/fuwn/meta/default.nix | 1 + home/fuwn/meta/desktop/wayland/waybar/default.nix | 1 + home/fuwn/meta/scripts/scripts/.gitignore | 4 ++ home/fuwn/meta/scripts/scripts/altserver | 9 ++++ home/fuwn/meta/scripts/scripts/anidub | 1 + home/fuwn/meta/scripts/scripts/anime | 1 + home/fuwn/meta/scripts/scripts/apod | 4 ++ home/fuwn/meta/scripts/scripts/bt | 16 ++++++ home/fuwn/meta/scripts/scripts/catboy | 6 +++ home/fuwn/meta/scripts/scripts/chan2 | 1 + home/fuwn/meta/scripts/scripts/counter | 3 ++ home/fuwn/meta/scripts/scripts/hon | 9 ++++ home/fuwn/meta/scripts/scripts/reco | 56 +++++++++++++++++++++ home/fuwn/meta/scripts/scripts/rinny | 27 +++++++++++ home/fuwn/meta/scripts/scripts/shiori | 47 ++++++++++++++++++ home/fuwn/meta/scripts/scripts/skyla | 51 ++++++++++++++++++++ home/fuwn/meta/scripts/scripts/start-vm | 19 ++++++++ home/fuwn/meta/scripts/scripts/vivwal | 59 +++++++++++++++++++++++ home/fuwn/meta/scripts/scripts/wal_mako | 43 +++++++++++++++++ 19 files changed, 358 insertions(+) create mode 100644 home/fuwn/meta/scripts/scripts/.gitignore create mode 100755 home/fuwn/meta/scripts/scripts/altserver create mode 100755 home/fuwn/meta/scripts/scripts/anidub create mode 100755 home/fuwn/meta/scripts/scripts/anime create mode 100755 home/fuwn/meta/scripts/scripts/apod create mode 100755 home/fuwn/meta/scripts/scripts/bt create mode 100755 home/fuwn/meta/scripts/scripts/catboy create mode 100755 home/fuwn/meta/scripts/scripts/chan2 create mode 100755 home/fuwn/meta/scripts/scripts/counter create mode 100755 home/fuwn/meta/scripts/scripts/hon create mode 100755 home/fuwn/meta/scripts/scripts/reco create mode 100755 home/fuwn/meta/scripts/scripts/rinny create mode 100755 home/fuwn/meta/scripts/scripts/shiori create mode 100755 home/fuwn/meta/scripts/scripts/skyla create mode 100755 home/fuwn/meta/scripts/scripts/start-vm create mode 100755 home/fuwn/meta/scripts/scripts/vivwal create mode 100755 home/fuwn/meta/scripts/scripts/wal_mako 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'] <:)" >&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 <>"${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 -- cgit v1.2.3