Files
sasaken1102randClaude Opus 5.5 486be061ae v0.2.0 のリリース準備: README・CHANGELOG・画像を今の動きに合わせる
- README(日英)の更新の説明を今の動きに合わせた: 帯は見出しの右、版は数字だけ、各状態の見え方、
  確かめるタイミング(起動時と 24 時間に 1 回まで・失敗時は 1 時間後)、update_check で止まるのは自動確認だけ、
  SHA256SUMS で照らし合わせること(署名ではないこと)、失敗しても今の版のまま、別ユニット
  frame-perf-overlay-update とログの場所、入るものは install.sh と同じ、v0.1.0 からは一度手で上げること
- インストールで入るもの(frame-update.sh・install-args)、--uninstall で残るもの、プライバシー・免責事項の
  「書き込むもの」を今のコードに合わせた
- README の画像(性能パネル・警告の色・設定パネル、日英)を今の見た目で撮り直した
- CHANGELOG の 0.2.0 に日付を入れ、全体を見直した(更新の仕組み・向き・設定パネル・Wi-Fi・修正)
- install.sh: ロックファイルの PID のプロセスがもういないと途中で止まっていたのを直した
  (--uninstall がいつも何も消せていなかった)。--uninstall で frame-update.sh も消す

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-27 19:39:22 +09:00

197 lines
8.8 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# Frame Perf Overlay を Steam Frame に入れる・更新する・外す。本体の上で、ふつうのユーザーで実行する(sudo 不要)。
# ./install.sh 入れる・更新する。自動起動を有効にし、SteamVR が動いていればその場で(再)起動する
# ./install.sh --no-autostart 入れる・更新する。自動起動は無効にする(ダッシュボードの+から起動して使う)
# ./install.sh --uninstall 外す(設定ファイルは残す)
# リリースの tar.gz を展開したフォルダでも、ビルドしたリポジトリのフォルダ(build/ に実行ファイル)でも動く。
set -euo pipefail
name="frame-perf-overlay"
here="$(cd "$(dirname "$0")" && pwd)"
config_home="${XDG_CONFIG_HOME:-$HOME/.config}"
data_home="${XDG_DATA_HOME:-$HOME/.local/share}"
bin="$HOME/.local/bin/$name"
unit="$name.service"
unit_dir="$config_home/systemd/user"
desktop="$data_home/applications/$name.desktop"
icons="$data_home/icons/hicolor"
icon_sizes="48 128 256"
config_dir="$config_home/$name"
usage() {
cat <<'EOF'
Usage: ./install.sh [--no-autostart | --uninstall]
(no option) install or update, turn on autostart, and (re)start it if SteamVR is running
--no-autostart install or update with autostart off (start it from the + button in the dashboard)
--uninstall remove it (your settings in ~/.config/frame-perf-overlay/ are kept)
EOF
}
uninstall=0
autostart=1
for arg in "$@"; do
case "$arg" in
--uninstall) uninstall=1 ;;
--no-autostart) autostart=0 ;;
-h|--help) usage; exit 0 ;;
*) echo "Unknown option: $arg" >&2; usage >&2; exit 2 ;;
esac
done
# +から手で起動したもの(サービスの外で動いているもの)があれば、SIGTERM で止める。
# アプリは SIGTERM でふだんどおりの終了処理(オーバーレイを消してから VR_Shutdown)を通る。
stop_manual_instance() {
local lock="${XDG_RUNTIME_DIR:-/run/user/$(id -u)}/$name.lock"
[[ -r "$lock" ]] || return 0
local pid
pid="$(head -n 1 "$lock" 2>/dev/null | tr -dc '0-9')"
[[ -n "$pid" ]] || return 0
# ロックファイルの PID が古くて別のプロセスに使い回されていることがあるので、名前を確かめる
# (/proc/<pid>/comm は 15 文字で切れるので、cmdline の実行ファイル名で比べる)
# ロックファイルは終了後も残るので、PID のプロセスがもういないことがある(サービスを止めた直後など)。
# そのときは何もしない(読めないファイルを < で開くと set -e で install.sh ごと止まってしまう)
[[ -r "/proc/$pid/cmdline" ]] || return 0
local argv0
argv0="$( { tr '\0' '\n' < "/proc/$pid/cmdline"; } 2>/dev/null | head -n 1 || true)"
[[ "$(basename -- "${argv0:-x}")" == "$name" ]] || return 0
local service_pid
service_pid="$(systemctl --user show -p MainPID --value "$unit" 2>/dev/null || echo 0)"
[[ "$pid" != "$service_pid" ]] || return 0
echo "Stopping the running $name (PID $pid) that was started outside the service..."
kill -TERM "$pid" 2>/dev/null || return 0
for _ in $(seq 1 50); do
[[ -d "/proc/$pid" ]] || return 0
sleep 0.1
done
echo "Warning: PID $pid is still running. Close it from the SteamVR dashboard (Perf icon > Close)." >&2
}
# .desktop とアイコンの一覧を作り直す(コマンドが無ければ何もしない)
refresh_caches() {
if command -v update-desktop-database >/dev/null 2>&1 && [[ -d "$data_home/applications" ]]; then
update-desktop-database "$data_home/applications" || true
fi
if command -v gtk-update-icon-cache >/dev/null 2>&1 && [[ -f "$icons/index.theme" ]]; then
gtk-update-icon-cache -q "$icons" || true
fi
}
if [[ "$uninstall" == 1 ]]; then
# --now の停止は SIGTERM なので、アプリの終了処理がふだんどおり通る
systemctl --user disable --now "$unit" 2>/dev/null || true
stop_manual_instance
rm -f "$unit_dir/$unit" "$bin" "$desktop" "$data_home/$name/frame-update.sh"
rmdir "$data_home/$name" 2>/dev/null || true # 空になったら消す(ほかに何か置かれていれば残す)
for size in $icon_sizes; do
rm -f "$icons/${size}x${size}/apps/$name.png"
done
systemctl --user daemon-reload || true
refresh_caches
echo "Removed $name."
if [[ -d "$config_dir" ]]; then
echo "Your settings are kept in $config_dir. To delete them too: rm -r \"$config_dir\""
fi
exit 0
fi
if [[ "$(uname -m)" != "aarch64" ]]; then
echo "This build is for the Steam Frame (aarch64), but this machine is $(uname -m)." >&2
exit 1
fi
# 実行ファイル: tar.gz の中なら同じフォルダ、リポジトリなら build/
if [[ -f "$here/$name" ]]; then
src_bin="$here/$name"
elif [[ -f "$here/build/$name" ]]; then
src_bin="$here/build/$name"
else
echo "Cannot find the $name binary next to install.sh or in build/. Build it first (see README)." >&2
exit 1
fi
for f in "contrib/$unit" "contrib/$name.desktop"; do
if [[ ! -f "$here/$f" ]]; then
echo "Missing $here/$f" >&2
exit 1
fi
done
# 実行ファイル(一時ファイルに書いてから置き換えるので、動いているものがあっても壊さない)
install -Dm755 "$src_bin" "$bin.new"
mv -f "$bin.new" "$bin"
# アイコン(Steam は hicolor の <サイズ>/apps からアイコンを探す。256x256 だけでは見つからなかったので 3 サイズ入れる)
for size in $icon_sizes; do
install -Dm644 "$here/contrib/icons/$name-$size.png" "$icons/${size}x${size}/apps/$name.png"
done
# .desktop(ダッシュボードの+の一覧に出る。Exec は実行ファイルの絶対パスにする。
# Steam から起動されると PATH に ~/.local/bin が無いことがあるため)
mkdir -p "$(dirname "$desktop")"
sed "s|@BINARY@|$bin|" "$here/contrib/$name.desktop" > "$desktop.tmp"
chmod 644 "$desktop.tmp"
mv -f "$desktop.tmp" "$desktop"
if command -v desktop-file-validate >/dev/null 2>&1; then
desktop-file-validate "$desktop" || true
fi
refresh_caches
# systemd のユーザーサービス
install -Dm644 "$here/contrib/$unit" "$unit_dir/$unit"
systemctl --user daemon-reload
# 更新の仕組み(vendor/frame-updater/frame-update.sh を ~/.local/share/<name>/ に置く。無ければ、この版で
# は入れ替え済みなのでボタンでの更新は使えないが、それ以外はふつうに動く)
update_script="$here/vendor/frame-updater/frame-update.sh"
if [[ -f "$update_script" ]]; then
install -Dm755 "$update_script" "$data_home/$name/frame-update.sh"
else
echo "Warning: $update_script not found. Update from the dashboard won't work until you install a release that includes it." >&2
fi
# 次回の自動更新(frame-update.sh install)が使うオプションを書き残す(--uninstall 以外。1 行 1 つ、# はコメント)
mkdir -p "$config_dir"
install_args="$config_dir/install-args"
: >"$install_args.new"
[[ "$autostart" == 0 ]] && echo "--no-autostart" >>"$install_args.new"
mv -f "$install_args.new" "$install_args"
steamvr_running=0
if systemctl --user is-active --quiet steamvr.service; then
steamvr_running=1
fi
if [[ "$autostart" == 1 ]]; then
systemctl --user enable "$unit"
if [[ "$steamvr_running" == 1 ]]; then
stop_manual_instance
# restart の停止も SIGTERM なので、動いている古いものは終了処理を通ってから新しいものに替わる
systemctl --user restart "$unit"
sleep 2
systemctl --user --no-pager status "$unit" | head -n 5 || true
fi
else
systemctl --user disable "$unit" 2>/dev/null || true
# サービスとして動いているものがあれば、新しい実行ファイルで起動し直す(次の SteamVR 起動からは自動では起動しない)
if systemctl --user is-active --quiet "$unit"; then
systemctl --user restart "$unit"
fi
fi
echo
echo "$name $("$bin" --version 2>/dev/null | awk '{print $2}') is installed."
if [[ "$autostart" == 1 ]]; then
if [[ "$steamvr_running" == 1 ]]; then
echo " It is running now and starts together with SteamVR from now on."
else
echo " It starts together with SteamVR from the next SteamVR start."
fi
else
echo " Autostart is off. Start it from the + button in the SteamVR dashboard (Frame Perf Overlay)."
fi
cat <<EOF
Settings: SteamVR dashboard > Perf, or $config_dir/config.json
Updates: the Perf tab shows the version and checks GitHub for a newer one (at start and at most once a day; "update_check": false in config.json turns that off, "Check now" still works)
Logs: journalctl --user -u $name -f
Remove: ./install.sh --uninstall
EOF