819 字
4 分钟
Ubuntu Ibus失灵/高延迟
前言
该问题自从我将系统从18.04升级到20.04后,就始终存在,经常卡死无法输入中文。
我在升级之后,我修过电脑主板,起初以为是电脑硬件问题,比如芯片缓冲炸裂或不稳定啥的。
因此我还说服了我自己再买了台电脑,发现问题依旧…,所以实际问题是出在软件上么???
新电脑真香~
具体表现
在使用中文输入法时,大概是每隔2个小时左右(应该是和字数或占用内存有关),就会发病一次,突然无法输入任何内容,但键盘和输入法并没有失效。
首先,通过键盘快捷键依旧可以打开终端;其次,快捷键 win+space
时任何可以切换其他输入法,并且其他输入法依旧正常;最后,你在失灵期间键入的任何内容,都还会慢~慢~地键入到输入框中。
为此我还检查过CPU、内存占用等内容,发现没有异常,所以应该就是软件本身问题。
解决方法
方法1:重启IBUS
这是在我查了csdn后一位老哥给出的解决方案1。
对于所有的软件问题,都能通过重装或重启来解决。
根据之前提到的特性,在中文输入法之外再增加一个英文输入法:^
当中文输入法失灵时,使用 Win+空格 切换到英文输入法,并打开终端输入:
ibus restart
完成后,IBUS就能完成重启,中文输入法就能正常使用了。
方法2:脚本定时重启IBUS
针对这个BUG的特性,通过脚本定时重启IBUS。
编写 restart_ibus.sh:
#! /bin/bashibus restart
给予权限:
chmod 777 restart_ibus.sh
添加定时任务:
crontab -e
增加内容如下:
# Edit this file to introduce tasks to be run by cron.## Each task to run has to be defined through a single line# indicating with different fields when the task will be run# and what command to run for the task## To define the time you can provide concrete values for# minute (m), hour (h), day of month (dom), month (mon),# and day of week (dow) or use '*' in these fields (for 'any').## Notice that tasks will be started based on the cron's system# daemon's notion of time and timezones.## Output of the crontab jobs (including errors) is sent through# email to the user the crontab file belongs to (unless redirected).## For example, you can run a backup of all your user accounts# at 5 a.m every week with:# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/## For more information see the manual pages of crontab(5) and cron(8)## m h dom mon dow command1 * * * * /home/user/restart_ibus.sh
增加的内容是让你的电脑在每小时的第1分钟,运行一次重启ibus的脚本。
输入完成后保存,并重启cron:
sudo service cron restart
这个方法,不会在你关机后丢失,每次开机也不用重新启动脚本,Nice哦~
关于时间配置或Cron的使用方法,可以查看这篇文章2。
方法3:模鱼
定时发作,每次发作几分钟,真好拿来提醒你该摸鱼了,工作强度越高,摸鱼频率越高。
Footnotes
Ubuntu Ibus失灵/高延迟
https://fuwari.vercel.app/posts/ubuntu/ubuntu-ibus失灵高延迟/