README 🪵

⎗
✓
# JAYA

* はじめに
これらのスクリプトは、軽量で幅広いLinux環境で動作する、
隔離・匿名化・メディアに特化した、POSIX準拠のシェルスクリプトです。

* ライセンス
すべては、The Unlicense、パブリックドメインで全世界に公開されています。

* 論理的匿名化
持論ですが、一般的なファイアウォールや市販のVPNキルスイッチでは不十分です。

* ネットワーク名前空間
そこで、ネットワーク名前空間を使った論理的な匿名化を実現します。簡単に言うと、
FIBやRPDBやFORWARDを制御し、Tor以外の通信が、名前空間外へ漏れないようにします。

* 軽量メディアスクリプト
当初の目的は、RaspberryPi3BでYouTubeを再生することでした。様々な理由から自作。
広告もない、おすすめもない、自分の見たい動画を誰にも邪魔されずに見ることができます。

* 思いやり、優しさ、選択
しかしこの世には、論理だけでは片付けられないこともあります。大切なものを、大切に。後悔のないように。

FAQFAQ 🥚

⎗
✓
# FAQ

# kiite[.]app[/]oresha

Q. Qubesでよくね?
A. ハードウェア依存が大きいです。ラズパイで動きません。
単純に低スペック環境では動かないのです。キューブ型隔離に関しては魅力的です。

Q. Whonixでよくね?
A. Whonixの匿名性はWhonixGatewayに依存しています。
2つもVMを起動させないといけないのは重すぎます。でもJAYAと似ている点もあり、境界がホストかVMかの違いです。

Q. Tailsじゃ駄目なの?
A. Tailsの匿名化モデルは論理的ではありません。FWがリセットされればIPアドレスは漏洩します。WebRTCリーク確認済み。痕跡を残さないという点では有用です。

CONFIG 🐣

⎗
✓
# yt-dlp

pipx install yt-dlp

nvim ~/.config/yt-dlp/config

-S res:480
--js-runtimes node
--remote-components ejs:github
-f 'bv+ba[language=ja]/bestvideo+bestaudio/best'

# sudoers

su -c 'gpasswd -a "$USER" wheel'

su -c 'nvim /etc/sudoers.d/jaya'

%wheel ALL=(ALL:ALL) NOPASSWD: /usr/local/bin/jayaraw
%wheel ALL=(ALL:ALL) NOPASSWD: /usr/local/bin/jayator

METHOD 🪹

⎗
✓
# *.desktop

## Raw TVer
> sudo jayaraw env NET=1 jayauns sh -c 'while :; do jayatvd; done'
## Raw Twitch
> sudo jayaraw env NET=1 jayauns sh -c 'while :; do jayatwd; done'
## Raw YouTube
> sudo jayaraw env NET=1 jayauns sh -c 'while :; do jayaytd 100; done'
## Raw Firefox
> sudo jayaraw dbus-run-session env NET=1 jayauns sh -c 'home="$HOME/.jaraw"; mkdir -p "$home"; [ -f "$HOME/.Xauthority" ] && cp "$HOME/.Xauthority" "$home"; mount --bind "$home" "$HOME"; cd; firefox'
## Tor Firefox
> sudo jayator dbus-run-session env NET=1 jayauns sh -c 'home="$HOME/.jator"; mkdir -p "$home"; [ -f "$HOME/.Xauthority" ] && cp "$HOME/.Xauthority" "$home"; mount --bind "$home" "$HOME"; cd; firefox'
## Tor Browser
> sudo jayator dbus-run-session env NET=1 jayauns sh -c 'home="$HOME/tor-browser"; mkdir -p "$home"; [ -f "$HOME/.Xauthority" ] && cp "$HOME/.Xauthority" "$home"; mount --bind "$home" "$HOME"; cd; Browser/firefox'

JAYACHK 🪶

⎗
✓
#!/bin/sh

# PROJECT: Jayachk
# UPDATES: 2026-10-09 16:19:57 JST
# LICENSE: The Unlicense (unlicense.org)

PATH='/usr/sbin:/usr/bin:/sbin:/bin'; BIN='/usr/local/bin'
[ "$(id -u)" -ne 0 ] || exit 1; type shellcheck || exit 2; cd ~/ドキュメント || exit 3

for f in jaya*
do
  [ -f "$f" ] || exit 4; shellcheck "$f" || exit 5
  [ -f "$BIN/$f" ] || exit 6; diff -u "$BIN/$f" "$f"; case $? in 0|1) ;; *) exit 7 ;; esac
done

JAYAKIT 🪽

⎗
✓
1
2
3
4
5
6
7
8
9
#!/bin/sh

# PROJECT: Jayakit
# UPDATES: 2026-10-19 07:03:22 JST
# LICENSE: The Unlicense (unlicense.org)

PATH='/usr/sbin:/usr/bin:/sbin:/bin'; export TMPDIR='/var/tmp'
[ "$(id -u)" -eq 0 ] || exit 1; type lynis trivy rkhunter chkrootkit || exit 2; install -v -m 1777 -d /var/tmp || exit 3
lynis audit system; trivy rootfs / --scanners vuln; rkhunter --update; rkhunter --sk --check; chkrootkit | grep --color='always' -E 'Warning|INFECTED'

JAYAMAC 🦉

⎗
✓
#!/bin/sh

# PROJECT: Jayamac
# UPDATES: 2026-10-17 13:18:19 JST
# LICENSE: The Unlicense (unlicense.org)

PATH='/usr/sbin:/usr/bin:/sbin:/bin'
[ "$(id -u)" -eq 0 ] || exit 1; type macchanger || exit 2
rm -rfv -- /var/db/dhcp* /var/lib/dhcp* /var/lib/NetworkManager || exit 3

for f in /sys/class/net/*; do
  i="${f##*/}"
  [ "$i" != "lo" ] || continue
  [ -e "$f/device" ] || continue
  ip link set dev "$i" down || continue

  {
    ip addr flush dev "$i" &&
    ip neigh flush dev "$i"
  } || echo "fail: ip: $i" >&2

  macchanger -A "$i" || echo "fail: mac: $i" >&2
  ip link set dev "$i" up && echo "good: up: $i" || echo "fail: up: $i" >&2
done

JAYANTA 🐦‍⬛

⎗
✓
#!/bin/sh

# PROJECT: Jayanta
# UPDATES: 2026-10-18 17:58:24 JST
# LICENSE: The Unlicense (unlicense.org)

PATH='/usr/sbin:/usr/bin:/sbin:/bin'
TOR="${1:-tor}"; RAW="${2:-privoxy}"; NNS="$(ip netns identify)"

[ "$(id -u)" -eq 0 ] || exit 1; type nft tor conntrack || exit 2
[ -z "$NNS" ] || exit 3; ln -sfv /usr/share/zoneinfo/Etc/UTC /etc/localtime || exit 4
( id "$TOR" && id "$RAW" ) || { echo 'sudo sh jayanta [debian-]tor[anon] priv[tinypr]oxy'; exit 5; }
sysctl net.ipv4.ip_forward=0 net.ipv6.conf.all.disable_ipv6=1 net.ipv6.conf.default.disable_ipv6=1 || exit 6

for t in nat filter; do nft add table inet $t; nft flush table inet $t; done
nft add chain inet nat output '{ type nat hook output priority dstnat; policy accept; }'
for c in input output forward; do nft add chain inet filter $c "{ type filter hook $c priority filter; policy drop; }"; done; conntrack -F expect && conntrack -F || exit 7
nft add set inet nat reserved '{ type ipv4_addr; flags interval; elements = { 0.0.0.0/8, 10.0.0.0/8, 100.64.0.0/10, 127.0.0.0/8, 169.254.0.0/16, 172.16.0.0/12, 192.0.0.0/24, 192.0.2.0/24, 192.31.196.0/24, 192.52.193.0/24, 192.88.99.0/24, 192.168.0.0/16, 192.175.48.0/24, 198.18.0.0/15, 198.51.100.0/24, 203.0.113.0/24, 224.0.0.0/4, 240.0.0.0/4 }; }'

nft add rule inet nat output udp dport 53 redirect to 9053
nft add rule inet nat output ip daddr 10.192.0.0/10 tcp dport '{ 80, 443 }' tcp flags syn / fin,syn,rst,ack redirect to 9040
nft add rule inet nat output skuid != "{ $TOR, $RAW }" oifname != "lo" ip daddr != @reserved tcp dport '{ 80, 443 }' tcp flags syn / fin,syn,rst,ack redirect to 9040

nft add rule inet filter input ct state vmap '{ invalid : drop, established : accept }'
nft add rule inet filter input ct state new iifname "lo" ip daddr 127.0.0.1 accept

nft add rule inet filter output ct state vmap '{ invalid : drop, established : accept }'
nft add rule inet filter output ct state new ip daddr 127.0.0.1 meta l4proto . th dport vmap '{ udp . 9053 : accept, tcp . 9040 : accept, tcp . 9050 : accept }'
nft add rule inet filter output ct state new tcp dport 443 tcp flags syn / fin,syn,rst,ack skuid "{ $TOR, $RAW }" accept
nft add rule inet filter output ct state new oifname "lo" ip daddr 127.0.0.1 accept; nft list ruleset

{
  echo "SafeSocks 1"
  echo "ReachableAddresses *:443"
  echo "User $TOR"
  echo "DataDirectory /var/lib/tor"
  echo "DNSPort 9053"
  echo "AutomapHostsOnResolve 1"
  echo "AutomapHostsSuffixes .onion"
  echo "VirtualAddrNetworkIPv4 10.192.0.0/10"
  echo "TransPort 9040 IsolateClientAddr IsolateClientProtocol IsolateDestAddr IsolateDestPort"
  echo "SocksPort 9050 IsolateClientAddr IsolateClientProtocol IsolateDestAddr IsolateDestPort"
} | tee /etc/tor/torrc || exit 8
{ sv restart tor || service tor restart || systemctl restart tor || rc-service tor restart; } >/dev/null 2>&1 && echo '[ OK ] tor' || echo '[ NG ] tor' >&2

JAYARAW 🕊️

⎗
✓
#!/bin/sh

# PROJECT: Jayaraw
# UPDATES: 2026-10-05 21:29:11 JST
# LICENSE: The Unlicense (unlicense.org)

PATH='/usr/sbin:/usr/bin:/sbin:/bin'; USR="${SUDO_USER:-${DOAS_USER:-}}"; NNS="$(ip netns identify)"
stty sane; case "$USR" in ''|root) exit 1 ;; esac; type nft || exit 2
[ -z "$NNS" ] || exit 3; ln -sf /usr/share/zoneinfo/Etc/UTC /etc/localtime || exit 4
printf '\033[31m█\033[0m Leak IP [Yes/no]: '; read -r YN; case "$YN" in [Yy]*) ;; *) exit 5 ;; esac
sysctl -q net.ipv4.ip_forward=0 net.ipv6.conf.all.disable_ipv6=1 net.ipv6.conf.default.disable_ipv6=1 || exit 6

ip netns add jaraw 2>/dev/null || :
ip link add raw-veth0 type veth peer name raw-veth1 netns jaraw 2>/dev/null || :
ip addr replace 198.18.1.0/31 dev raw-veth0
ip link set lo up; ip link set raw-veth0 up
ip -n jaraw addr replace 198.18.1.1/31 dev raw-veth1
ip -n jaraw link set lo up; ip -n jaraw link set raw-veth1 up
ip -n jaraw route replace default via 198.18.1.0 dev raw-veth1

nft add table inet nat
nft add chain inet nat postrouting '{ type nat hook postrouting priority srcnat; policy accept; }'
nft flush chain inet nat postrouting
nft add rule inet nat postrouting iifname "raw-veth0" ip saddr 198.18.1.1 masquerade

nft add table inet filter
nft add chain inet filter forward '{ type filter hook forward priority filter; policy drop; }'
nft flush chain inet filter forward
nft add rule inet filter forward ct state vmap '{ invalid : drop, established : accept }'
nft add rule inet filter forward ct state new iifname "raw-veth0" ip saddr 198.18.1.1 accept

CAPS='-bpf,-net_raw,-net_admin,-sys_rawio,-sys_admin,-sys_ptrace,-sys_module'; IF="$(ip route get 1.1.1.1 | awk '{print $5; exit}')"
for i in all default lo raw-veth1; do ip netns exec jaraw sysctl -q net.ipv6.conf.$i.disable_ipv6=1 || exit 7; done; sysctl -q net.ipv4.conf.raw-veth0.forwarding=1 net.ipv4.conf."$IF".forwarding=1 || exit 8
exec ip netns exec jaraw setpriv --no-new-privs --inh-caps="$CAPS" --ambient-caps="$CAPS" --bounding-set="$CAPS" runuser -u "$USR" -- env "XDG_RUNTIME_DIR=/run/user/$(id -u "$USR")" sh -lc 'printf "\033]10;#ff6666\007"; "$@"; sleep 1; printf "\033]110\007"' sh "${@:-bash}"

JAYATOR 🦅

⎗
✓
#!/bin/sh

# PROJECT: Jayator
# UPDATES: 2026-10-17 06:24:53 JST
# LICENSE: The Unlicense (unlicense.org)

PATH='/usr/sbin:/usr/bin:/sbin:/bin'; USR="${SUDO_USER:-${DOAS_USER:-}}"; NNS="$(ip netns identify)"
stty sane; case "$USR" in ''|root) exit 1 ;; esac; type nft tor || exit 2
[ -z "$NNS" ] || exit 3; ln -sf /usr/share/zoneinfo/Etc/UTC /etc/localtime || exit 4
printf '\033[32m█\033[0m Hide IP [Yes/no]: '; read -r YN; case "$YN" in ''|[Yy]*) ;; *) exit 5 ;; esac
sysctl -q net.ipv4.ip_forward=0 net.ipv6.conf.all.disable_ipv6=1 net.ipv6.conf.default.disable_ipv6=1 || exit 6

ip route replace blackhole default table 10
ip rule add pref 2 iif tor-veth0 lookup 10 2>/dev/null && echo '[ OK ] FIB ' || :
ip rule add pref 1 iif tor-veth0 blackhole 2>/dev/null && echo '[ OK ] RPDB' || :

ip netns add jator 2>/dev/null || :
ip link add tor-veth0 type veth peer name tor-veth1 netns jator 2>/dev/null || :
ip addr replace 198.18.3.0/31 dev tor-veth0
ip link set lo up; ip link set tor-veth0 up
ip -n jator addr replace 198.18.3.1/31 dev tor-veth1
ip -n jator link set lo up; ip -n jator link set tor-veth1 up
ip -n jator route replace default via 198.18.3.0 dev tor-veth1

nft add table inet nat
nft add chain inet nat prerouting '{ type nat hook prerouting priority dstnat; policy accept; }'
nft flush chain inet nat prerouting
nft add rule inet nat prerouting iifname "tor-veth0" ip saddr 198.18.3.1 udp dport 53 dnat ip to 198.18.3.0:9053
nft add rule inet nat prerouting iifname "tor-veth0" ip saddr 198.18.3.1 tcp dport '{ 80, 443 }' tcp flags syn / fin,syn,rst,ack dnat ip to 198.18.3.0:9040

nft add table inet filter
for c in input forward; do nft add chain inet filter $c "{ type filter hook $c priority filter; policy drop; }"; done
nft flush chain inet filter input
nft add rule inet filter input ct state vmap '{ invalid : drop, established : accept }'
nft add rule inet filter input ct state new iifname "tor-veth0" ip saddr 198.18.3.1 ip daddr 198.18.3.0 meta l4proto . th dport vmap '{ udp . 9053 : accept, tcp . 9040 : accept, tcp . 9050 : accept }'
nft add rule inet filter input ct state new iifname "lo" ip daddr 127.0.0.1 accept

while IFS= read -r line; do grep -Fxq -- "$line" /etc/tor/torrc || echo "$line" >> /etc/tor/torrc
done <<'EOF'
SafeSocks 1
DNSPort 198.18.3.0:9053
TransPort 198.18.3.0:9040 IsolateClientAddr IsolateClientProtocol IsolateDestAddr IsolateDestPort
SocksPort 198.18.3.0:9050 IsolateClientAddr IsolateClientProtocol IsolateDestAddr IsolateDestPort
EOF
{ sv restart tor || service tor restart || systemctl restart tor || rc-service tor restart; } >/dev/null 2>&1 || echo '[ NG ] tor' >&2

CAPS='-bpf,-net_raw,-net_admin,-sys_rawio,-sys_admin,-sys_ptrace,-sys_module'; IF="$(ip route get 1.1.1.1 | awk '{print $5; exit}')"
for i in all default lo tor-veth1; do ip netns exec jator sysctl -q net.ipv6.conf.$i.disable_ipv6=1 || exit 7; done; sysctl -q net.ipv4.conf.tor-veth0.forwarding=0 net.ipv4.conf."$IF".forwarding=1 || exit 8
exec ip netns exec jator setpriv --no-new-privs --inh-caps="$CAPS" --ambient-caps="$CAPS" --bounding-set="$CAPS" runuser -u "$USR" -- env "XDG_RUNTIME_DIR=/run/user/$(id -u "$USR")" sh -lc 'printf "\033]10;#66ff66\007"; "$@"; sleep 1; printf "\033]110\007"' sh "${@:-bash}"

JAYADNS 🐦‍🔥

⎗
✓
1
2
3
4
5
6
7
8
9
#!/bin/sh

# PROJECT: Jayadns
# UPDATES: 2026-10-17 19:00:04 JST
# LICENSE: The Unlicense (unlicense.org)

PATH='/usr/sbin:/usr/bin:/sbin:/bin'; RAW='1.1.1.1'; TOR='198.18.3.0'
[ "$(id -u)" -eq 0 ] || exit 1; install -v -d /etc/netns/jaraw /etc/netns/jator || exit 2
echo "nameserver $RAW" | tee /etc/netns/jaraw/resolv.conf && echo "nameserver $TOR" | tee /etc/netns/jator/resolv.conf || exit 3

JAYAUNS 🐓

⎗
✓
1
2
3
4
5
6
7
8
9
#!/bin/sh

# PROJECT: Jayauns
# UPDATES: 2026-10-09 15:04:04 JST
# LICENSE: The Unlicense (unlicense.org)

PATH='/usr/sbin:/usr/bin:/sbin:/bin'; CAPS='-bpf,-net_raw,-net_admin'
[ "$(id -u)" -ne 0 ] || exit 1; type unshare || exit 2; case "${NET:-0}" in 0) net='--net' ;; 1) net='--' ;; *) exit 3 ;; esac; [ "$(readlink /proc/self/ns/user)" != "$(readlink /proc/1/ns/user)" ] || exit 4
exec unshare --uts --ipc --pid --fork --time --cgroup --kill-child --user --map-root-user --mount --mount-proc --propagation private "$net" setpriv --no-new-privs --inh-caps="$CAPS" --ambient-caps="$CAPS" --bounding-set="$CAPS" sh -lc 'printf "\033]12;#6666ff\007"; "$@"; sleep 1; printf "\033]112\007"' sh "${@:-bash}"

JAYAVPN 🦆

⎗
✓
#!/bin/sh

# PROJECT: Jayavpn
# UPDATES: 2026-10-07 16:15:33 JST
# LICENSE: The Unlicense (unlicense.org)

PATH='/usr/sbin:/usr/bin:/sbin:/bin'
[ "$(id -u)" -eq 0 ] || exit 1; type nft wg-quick conntrack || exit 2
ip netns exec jaraw true 2>/dev/null && [ -f /etc/wireguard/vpn.conf ] || exit 3
ip netns exec jaraw conntrack -F expect && ip netns exec jaraw conntrack -F || exit 4
ip netns exec jaraw wg show vpn 2>/dev/null || ip netns exec jaraw wg-quick up vpn || exit 5

ip netns exec jaraw nft add table inet filter; ip netns exec jaraw nft flush table inet filter
for c in input output forward; do ip netns exec jaraw nft add chain inet filter $c "{ type filter hook $c priority filter; policy drop; }"; done
ip netns exec jaraw nft add rule inet filter input ct state vmap '{ invalid : drop, established : accept }'
ip netns exec jaraw nft add rule inet filter input ct state new iifname "lo" ip daddr 127.0.0.1 accept
ip netns exec jaraw nft add rule inet filter output ct state vmap '{ invalid : drop, established : accept }'
ip netns exec jaraw nft add rule inet filter output ct state new ip daddr "${IP:-127.0.0.1}" "${PROT:-udp}" dport "${PORT:-51820}" accept
ip netns exec jaraw nft add rule inet filter output ct state new oifname '{ "vpn", "lo" }' accept

JAYAYTD 🦩

⎗
✓
#!/bin/sh

# PROJECT: Jayaytd
# UPDATES: 2026-10-10 08:39:31 JST
# LICENSE: The Unlicense (unlicense.org)

PATH="$HOME/.local/bin:$PATH"; pipe="$(printf '\037')"; mode='search'; type fzf mpv curl chafa ffmpeg yt-dlp || exit 1
printf 'query: '; read -r query; [ -n "$query" ] || exit 2; default="$query"; channel=''; line="${1:-20}"; page=1

while :; do
  case "$mode" in
    videos) src="$query/videos" ;;
    shorts) src="$query/shorts" ;;
    stream) src="$query/streams" ;;
    releas) src="$query/releases" ;;
    podcas) src="$query/podcasts" ;;
    playls) src="$query/playlists" ;;
    search) src="ytsearch$((page * line)):$query" ;;
  esac

  ytd="$(yt-dlp --no-warnings --skip-download --flat-playlist --playlist-end "$((page * line))" --extractor-args 'youtube:lang=ja' --print "%(id)s${pipe}%(title)s${pipe}%(channel)s${pipe}%(channel_url)s${pipe}%(thumbnails.-1.url)s" "$src")" || { [ "$mode" = "search" ] && exit 3; query="$default"; mode='search'; continue; }; [ -n "$ytd" ] || exit 4
  fzf="$(printf '%s' "$ytd" | fzf --with-nth=2 --layout='reverse' --delimiter="$pipe" --prompt="yt[$mode][$page]> " --expect='esc,left,right,ctrl-a,ctrl-d,ctrl-v,ctrl-c,ctrl-s,ctrl-r,ctrl-q,ctrl-f' --preview="[ {3} != NA ] && echo {3}; [ {5} != NA ] && thumb={5} && curl -s https://\${thumb#*//} | chafa")" || continue

  key="$(printf '%s' "$fzf" | head -n1)"
  row="$(printf '%s' "$fzf" | tail -n1)"
  vid="$(printf '%s' "$row" | cut -d"$pipe" -f1)"
  url="$(printf '%s' "$row" | cut -d"$pipe" -f4)"
  [ -n "$url" ] && [ "$url" != "NA" ] && channel="$url"

  case "$key" in
        '') case "$vid" in UC*) query="$channel"; mode='videos' ;; *) mpv -- "ytdl://$vid" || : ;; esac ;;
       esc) [ "$mode" != "search" ] && { query="$default"; mode='search'; } || exit 0 ;;
      left) [ "$page" -gt 1 ] && page="$((page - 1))" ;;
     right) page="$((page + 1))" ;;
    ctrl-a) yt-dlp -f bestaudio -x --audio-format='mp3' -- "$vid" || : ;;
    ctrl-d) yt-dlp -- "$vid" || : ;;
    ctrl-v) query="$channel"; mode='videos' ;;
    ctrl-c) query="$channel"; mode='shorts' ;;
    ctrl-s) query="$channel"; mode='stream' ;;
    ctrl-r) query="$channel"; mode='releas' ;;
    ctrl-q) query="$channel"; mode='podcas' ;;
    ctrl-f) query="$channel"; mode='playls' ;;
  esac
done

JAYATWD 🦚

⎗
✓
1
2
3
4
5
6
7
8
9
#!/bin/sh

# PROJECT: Jayatwd
# UPDATES: 2026-07-28 20:14:41 JST
# LICENSE: The Unlicense (unlicense.org)

PATH="$HOME/.local/bin:$PATH"; pipe="$(printf '\037')"
type fzf mpv ffmpeg yt-dlp || exit 1; printf 'id: '; read -r id; [ -n "$id" ] || exit 2
yt-dlp --no-warnings --skip-download --flat-playlist "https://twitch.tv/$id/videos" --print "%(title)s${pipe}%(url)s" | fzf --with-nth=1 --layout='reverse' --delimiter="$pipe" | cut -d"$pipe" -f2 | xargs -r mpv

JAYATVD 🦃

⎗
✓
#!/bin/sh

# PROJECT: Jayatvd
# UPDATES: 2026-10-10 08:42:21 JST
# LICENSE: The Unlicense (unlicense.org)

PATH="$HOME/.local/bin:$PATH"; pipe="$(printf '\037')"; mode='search'; type jq fzf mpv curl chafa ffmpeg yt-dlp || exit 1; printf 'query: '; read -r query; [ -n "$query" ] || exit 2
KEYS="$(curl -s -X POST --data 'device_type=pc' -H 'user-agent: Mozilla/5.0' 'https://platform-api.tver.jp/v2/api/platform_users/browser/create')"; UID="$(printf '%s' "$KEYS" | jq -r '.result.platform_uid')"; TOKEN="$(printf '%s' "$KEYS" | jq -r '.result.platform_token')"; [ -n "$UID" ] && [ -n "$TOKEN" ] || exit 3

while :; do
  case "$mode" in
    series) epj="$(curl -sG "https://platform-api.tver.jp/service/api/v1/callSeriesEpisodes/$sid" -H 'user-agent: Mozilla/5.0' -H 'origin: https://tver.jp' -H 'referer: https://tver.jp/' -H 'x-tver-platform-type: web' --data-urlencode "platform_uid=$UID" --data-urlencode "platform_token=$TOKEN")" || exit 4 ;;
    search) epj="$(curl -sG 'https://platform-api.tver.jp/service/api/v2/callKeywordSearch' -H 'user-agent: Mozilla/5.0' -H 'origin: https://tver.jp' -H 'referer: https://tver.jp/' -H 'x-tver-platform-type: web' --data-urlencode "platform_uid=$UID" --data-urlencode "platform_token=$TOKEN" --data-urlencode "keyword=$query")" || exit 5 ;;
  esac

  epl="$(printf '%s' "$epj" | jq -r --arg pipe "$pipe" '.result.contents[] | (.contents[]? // .) | select(.type=="episode") | .content | [ .id, .title, .seriesID, .seriesTitle, .thumbnailPath, .broadcasterName ] | join($pipe)')"; [ -n "$epl" ] || exit 6
  fzf="$(printf '%s' "$epl" | fzf --with-nth=2 --layout='reverse' --delimiter="$pipe" --prompt="tv[$mode]> " --expect='esc,ctrl-s' --preview="echo {4} {6}; thumb={5}; curl -s https://image-cdn.tver.jp/w=400\${thumb} | chafa")" || { mode='search'; continue; }

  key="$(printf '%s' "$fzf" | head -n1)"
  row="$(printf '%s' "$fzf" | tail -n1)"
  eid="$(printf '%s' "$row" | cut -d"$pipe" -f1)"
  sid="$(printf '%s' "$row" | cut -d"$pipe" -f3)"

  case "$key" in
        '') mpv -- "https://tver.jp/episodes/$eid" || : ;;
       esc) [ "$mode" != "search" ] && mode='search' || exit 0 ;;
    ctrl-s) [ "$mode" != "series" ] && [ -n "$sid" ] && mode='series' ;;
  esac
done

JAYAMCL ⛏️

⎗
✓
#!/bin/sh

# PROJECT: Jayamcl
# UPDATES: 2026-10-18 17:32:03 JST
# LICENSE: The Unlicense (unlicense.org)

set -eux

PATH='/usr/sbin:/usr/bin:/sbin:/bin'; MC_DIR="$HOME/.minecraft"
MANIFEST_URL='https://piston-meta.mojang.com/mc/game/version_manifest_v2.json'

download() {
  url="$1"; path="$2"; sha1="${3:-}"

  ok() { [ -z "$sha1" ] || echo "$sha1  $path" | sha1sum -c; }

  [ -f "$path" ] && ok && return 0

  curl -fsSL --create-dirs -o "$path" "$url"

  ok || { rm -f "$path"; echo "sha1 mismatch: $path" >&2; return 1; }
}

worker_library() {
  mc_dir="$1"; url="$2"; path="$3"; sha1="$4"

  download "$url" "$mc_dir/libraries/$path" "$sha1"
}

worker_asset() {
  mc_dir="$1"; hash="$2"; dir="${hash%"${hash#??}"}"

  download "https://resources.download.minecraft.net/$dir/$hash" "$mc_dir/assets/objects/$dir/$hash" "$hash"
}

list_libraries() {
  jq -r '.libraries[]
    | select(.downloads.artifact)
    | [.downloads.artifact.url, .downloads.artifact.path, .downloads.artifact.sha1]
    | @tsv' "$version_json"
}

list_assets() {
  jq -r '.objects[].hash' "$1"
}

fetch_version() {
  manifest_json="$MC_DIR/version_manifest.json"

  download "$MANIFEST_URL" "$manifest_json"

  version_url="$(jq -r --arg v "$version" '.versions[] | select(.id == $v) | .url' "$manifest_json")"

  if [ -z "$version_url" ]; then
    echo "unknown version: $version" >&2
    exit 2
  fi

  download "$version_url" "$version_json"

  download "$(jq -r '.downloads.client.url' "$version_json")" "$client_jar" "$(jq -r '.downloads.client.sha1' "$version_json")"
}

fetch_libraries() {
  list_libraries | xargs -P "$JOBS" -n 3 sh "$0" --worker-library "$MC_DIR"
}

fetch_assets() {
  asset_json="$MC_DIR/assets/indexes/$(jq -r '.assetIndex.id' "$version_json").json"

  download "$(jq -r '.assetIndex.url' "$version_json")" "$asset_json"

  list_assets "$asset_json" | xargs -P "$JOBS" -n 1 sh "$0" --worker-asset "$MC_DIR"
}

launch() {
  libraries="$(list_libraries | cut -f2 | sed "s|^|$MC_DIR/libraries/|" | paste -sd ':')"
  classpath="$client_jar:$libraries"

  main_class="$(jq -r '.mainClass' "$version_json")"
  asset_index="$(jq -r '.assets' "$version_json")"

  set -- --gameDir "$MC_DIR" --assetsDir "$MC_DIR/assets" --assetIndex "$asset_index"
  set -- "$@" --username "$username" --version "$version" --accessToken 0

  exec java -cp "$classpath" "$main_class" "$@"
}

main() {
  case "${1:-}" in
    --worker-library)
      shift
      worker_library "$@"
      return
    ;;
    --worker-asset)
      shift
      worker_asset "$@"
      return
    ;;
  esac

  if [ $# -lt 1 ]; then
    echo "usage: $0 <version> [username]" >&2
    exit 1
  fi

  JOBS=2
  command -v nproc >/dev/null 2>&1 && JOBS="$(nproc)"

  version="$1"
  username="${2:-Player}"

  client_jar="$MC_DIR/versions/$version/$version.jar"
  version_json="$MC_DIR/versions/$version/$version.json"

  fetch_version
  fetch_libraries
  fetch_assets

  launch
}

main "$@"

SP-MODE 🎧️

⎗
✓
#!/bin/sh

# PROJECT: SP-MODE
# UPDATES: 2026-10-15 11:02:55 JST
# LICENSE: The Unlicense (unlicense.org)

limit='-1.0'; target='-5.0'

for f in *.mp3 *.wav *.flac; do
  i="$(ffmpeg -hide_banner -i "$f" -filter_complex ebur128 -f null - 2>&1 |
    awk '/I:/ { i=$2 } END { print i }')"
  [ -n "$i" ] || continue; g="$(awk -v t="$target" -v i="$i" 'BEGIN { printf "%.2f", t - i }')"
  ffmpeg -hide_banner -i "$f" -af "volume=${g}dB,alimiter=limit=${limit}dB" -codec:a libmp3lame -b:a 320k "${f%.*}_norm.mp3"
done

VM-QEMU 📦️

⎗
✓
#!/bin/sh

# PROJECT: VM-QEMU
# UPDATES: 2026-10-15 11:40:40 JST
# LICENSE: The Unlicense (unlicense.org)

img="${1:-}"; iso="${2:-}"; mnt="${3:-mnt}"
cpu=2; mem=2048; size='20G'; format='qcow2'

[ -n "$img" ] || exit 1
[ -z "$iso" ] || [ -f "$iso" ] || exit 2
[ -f "$img" ] || qemu-img create -f "$format" "$img" "$size" || exit 3

set -- qemu-system-x86_64
set -- "$@" -display gtk
set -- "$@" -accel kvm -machine q35
set -- "$@" -cpu host -smp "$cpu" -m "$mem"
set -- "$@" -bios /usr/share/edk2/x64/OVMF.4m.fd
set -- "$@" -device virtio-rng-pci -device virtio-gpu-pci
set -- "$@" -audiodev pipewire,id=snd0 -device ES1370,audiodev=snd0
set -- "$@" -drive file="$img",format="$format",if=virtio,cache=none,aio=native
[ -d "$mnt" ] && set -- "$@" -virtfs local,path="$mnt",mount_tag=hostshare,security_model=none

if [ -z "$iso" ]; then exec "$@" -boot order=c; else exec "$@" -cdrom "$iso" -boot order=d; fi

AUTOVOL 🔊

⎗
✓
local mp = require "mp"

--[[
PROJECT: Autovol
UPDATES: 2026-08-25 12:59:11 JST
LICENSE: The Unlicense (unlicense.org) ]]

local enabled = true
local FILTER = "@autovol:lavfi=[speechnorm=e=6.25:r=0.00001:l=1]"

local function filter()
  mp.commandv("af", "remove", FILTER)
  if enabled then
    mp.commandv("af", "add", FILTER)
  end
end

mp.add_key_binding("F1", "toggle-autovol", function()
  enabled = not enabled

  filter()
end)

mp.register_event("file-loaded", filter)

CATSEYE 🐱

⎗
✓
local mp = require "mp"

--[[
PROJECT: Catseye
UPDATES: 2026-08-25 12:59:16 JST
LICENSE: The Unlicense (unlicense.org) ]]

local enabled = true
local FILTER = "@catseye:lavfi=[eq=contrast=1.10:saturation=1.30]"

local function filter()
  mp.commandv("vf", "remove", FILTER)
  if enabled then
    mp.commandv("vf", "add", FILTER)
  end
end

mp.add_key_binding("F2", "toggle-catseye", function()
  enabled = not enabled

  filter()
end)

mp.register_event("file-loaded", filter)

FASTMPV ⏩️

⎗
✓
local mp = require "mp"

--[[
PROJECT: Fastmpv
UPDATES: 2026-08-25 16:02:38 JST
LICENSE: The Unlicense (unlicense.org) ]]

local enabled = true
local last_start, last_end
local SPEED_SILENCE, SPEED_NORMAL = 3, 1
local FILTER = "@fastmpv:lavfi=[silencedetect=noise=-30dB:d=1]"

local function speed(v)
  mp.set_property_number("speed", v)
  if enabled then
    mp.osd_message(string.format("Speed: %.2fx", v))
  end
end

local function check(_, meta)
  if not enabled or not meta then return end

  local s = meta["lavfi.silence_start"]
  local e = meta["lavfi.silence_end"]

  if s and s ~= last_start then
    last_start = s
    speed(SPEED_SILENCE)
  end

  if e and e ~= last_end then
    last_end = e
    speed(SPEED_NORMAL)
  end
end

local function filter()
  mp.commandv("af", "remove", FILTER)
  if enabled then
    mp.commandv("af", "add", FILTER)
  end
  last_start, last_end = nil, nil
  speed(SPEED_NORMAL)
end

mp.add_key_binding("F3", "toggle-fastmpv", function()
  enabled = not enabled

  filter()
end)

mp.register_event("seek", filter)
mp.register_event("file-loaded", filter)
mp.observe_property("af-metadata/fastmpv", "native", check)
Edit

Pub: 05 Dec 2024 05:11 UTC

Edit: 22 Oct 2026 10:02 UTC

Views: 12751

Auto Theme: Dark