Skip to content

Instantly share code, notes, and snippets.

@Tetz
Last active July 1, 2019 08:39
Show Gist options
  • Save Tetz/2d7a91247bfb469b3f7a230e55e38efc to your computer and use it in GitHub Desktop.
Save Tetz/2d7a91247bfb469b3f7a230e55e38efc to your computer and use it in GitHub Desktop.
Change Japnese Input Mozc Default Input Method on Ubuntu 18.04
#!/bin/bash
echo 'setting ibus-mozc...'
# Change ibus-mozc default input mode to hiragana
sleep 3 && \
xdotool keydown super+space && sleep 0.2 && \
xdotool key space && sleep 0.2 && \
xdotool keyup super+space && \
for i in `seq 0 9`
do
mozc=`ps -ef | grep 'ibus-mozc' | grep -v grep | grep -v srvchk | wc -l`
if [ $mozc -gt 0 ]; then
sleep 1
xdotool keydown Hiragana && sleep 0.2 && \
xdotool keyup Hiragana && sleep 0.2
break
else
sleep 1
fi
done
sleep 3 && \
xdotool keydown super+space && sleep 0.2 && \
xdotool key space && sleep 0.2 && \
xdotool keyup super+space && sleep 0.2 && \
echo 'ibus-mozc setting done.'
sleep 1
@Tetz
Copy link
Author

Tetz commented Jul 1, 2019

Run the scrypt automatically on boot.

vim ~/.config/autostart/my_auto_start.desktop

And then paste

[Desktop Entry]
Name=MyAutoStart
GenericName=My Auto Start Script
Comment=no comment
Exec=/home/<your_user_name>/ibus-mozc-default-input-method.sh
Terminal=true
Type=Application
X-GNOME-Autostart-enabled=true

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