Skip to content

Instantly share code, notes, and snippets.

@nanpuyue
Last active August 5, 2018 07:23
Show Gist options
  • Save nanpuyue/7faa40ff87c8775fc8fd7dc9d5caec56 to your computer and use it in GitHub Desktop.
Save nanpuyue/7faa40ff87c8775fc8fd7dc9d5caec56 to your computer and use it in GitHub Desktop.
Linux 下的 Minecraft 中文输入脚本
#!/bin/bash
# file: minecraft-input.sh
# date: 2017-12-01
# license: GPLv3 https://www.gnu.org/licenses/gpl-3.0.txt
# author: nanpuyue <[email protected]> https://blog.nanpuyue.com
#
# 依赖:zenity xdotool xclip
#
# 使用方法:
# 将脚本绑定快捷键,不带参数的用于聊天,带-i参数的用于书写告示牌, 例如:
# 设置快捷键 alt + t 绑定 minecraft-input.sh
# 设置快捷键 alt + i 绑定 minecraft-input.sh -i
# 聊天时先按 t ,再按 alt + t,书写告示牌时按 alt + i,输完后回车或单击“确定”即可上屏。
# 如果出现不能上屏的情况,可自行调整 500 与 200 两个延时
window=$(xdotool search --onlyvisible --class "Minecraft")
text="$(zenity --entry --title 中文输入 --text 中文输入)"
echo -n "$text"|xclip -i -sel clip
case "$1" in
-i )
xdotool type --delay 500 --window $window "$text"
;;
* )
xdotool key --delay 200 --window $window --clearmodifiers ctrl+v
;;
esac
@nanpuyue
Copy link
Author

nanpuyue commented Dec 1, 2017

依赖:zenity xdotool xclip

将脚本绑定快捷键,不带参数的用于聊天,带-i参数的用于书写告示牌。
例如:
设置快捷键 alt + t 绑定 minecraft-input.sh
设置快捷键 alt + i 绑定 minecraft-input.sh -i

聊天时先按 t ,再按 alt + t,书写告示牌时按 alt + i,输完后回车或单击“确定”即可上屏。

@BattiestStone4
Copy link

您好,请问怎么给脚本绑定快捷键呢?

@nanpuyue
Copy link
Author

nanpuyue commented Aug 5, 2018

@BattiestStone4 这个得看桌面环境了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment