Created
January 25, 2019 08:53
-
-
Save ttdoda/1848de5eaca83be8a16f15b7a402f4cf to your computer and use it in GitHub Desktop.
DEC Locator mode対応確認
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# locator-check.bash: 端末が DEC Locator mode に対応しているか確認する | |
# | |
# 端末に ESC [ ? 55 n (ロケータ状態問い合わせ) を出力し、それへの応答で判断する | |
# ESC [ ? 50 n - 対応 | |
# ESC [ ? 53 n - 非対応。ただしロケータ問い合わせ自体は理解出来ているので、 | |
# 設定等で対応する可能性あり。 | |
# 応答なし - 非対応 | |
# | |
# License: CC0 | |
trap 'stty echo' 0 1 2 3 | |
stty -echo | |
printf "\e[?55n" # ロケータ状態問い合わせ | |
if read -r -t 1 -d n resp; then | |
case $resp in | |
*\?50) echo "Support.";; # ESC [ ? 50 n | |
*\?53) echo "No locator device.";; # ESC [ ? 53 n | |
*) echo "Invalid response.";; | |
esac | |
else | |
echo "Not support." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment