Created
July 6, 2014 15:50
-
-
Save quietlynn/f3b03ebf1d510eec9acb to your computer and use it in GitHub Desktop.
Inputting chat message in Minecraft (probably with IM)
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
#!/bin/bash | |
# Dependencies: | |
# * xdotool | |
# * xclip | |
# * kdialog or zenity | |
# * perl (only if "sleep 0.3" (float) is not accepted) | |
# Usage: | |
# Bind this script to a keyboard shortcut and then press it in Minecraft. | |
# Configuration: | |
paste_sleep=0.3 # Increase if chat is sent too early, before paste is accepted. | |
dialog_text="Chat:" | |
# == The script now begins == | |
dialog="kdialog --inputbox \"$dialog_text\"" | |
if ! which kdialog; then | |
if which zenity; then | |
dialog="zenity --entry --text=\"$dialog_text\"" | |
else | |
echo "Please install kdialog or zenity." | |
exit 1 | |
fi | |
fi | |
portable_sleep() { | |
sleep $1 >/dev/null 2>/dev/null || perl -e "select(undef,undef,undef,$1);" | |
} | |
xdotool key "t" | |
eval set -- $dialog | |
if text=$("$@"); then | |
echo -n "$text" | xclip -i -selection clipboard | |
xdotool key "ctrl+v" | |
portable_sleep $paste_sleep | |
xdotool key Return | |
else | |
xdotool key Escape | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment