给sunpinyin加速
因为sunpinyin词库一大就会卡,因此需要自己添加一个脚本给sunpinyin加速。
加速的原理就是把词库添加到内存,现在内存都这么大,根本不在乎这么几兆,当然输入体验更重要啦~
首先先建一个脚本实现把词库放到内存中的功能,脚本就取名为sunpinyin_speed_up吧。
#!/bin/sh # Capture the exit signal, make sure it is the FIRST uncommented line.
trap "do_exit" SIGHUP SIGINT SIGQUIT SIGTERM SUN_DIR="/home/xuzhenan/.sunpinyin"
SHM_USERDICT="/dev/shm/sunpinyin_userdict.sh0" # Backup the userdict and restore all changes made by this script on exit.
do_exit() {
cp -f "${SHM_USERDICT}" "${SUN_DIR}/userdict.real"
rm -f "${SHM_USERDICT}"
mv -f "${SUN_DIR}/userdict.real" "${SUN_DIR}/userdict"
#notify-send 'Pinyin dict' 'done'
exit
} # Work around for abnormal quit.
if [ -e "${SUN_DIR}/userdict.real" ]
then
rm -f "${SHM_USERDICT}"
mv -f "${SUN_DIR}/userdict.real" "${SUN_DIR}/userdict"
fi # Rename the real userdict, copy it to RAM and make a symblic link back.
# From now on the modification and query on userdict takes place in RAM.
mv -f "${SUN_DIR}/userdict" "${SUN_DIR}/userdict.real"
cp -f "${SUN_DIR}/userdict.real" "${SHM_USERDICT}"
ln -sf "${SHM_USERDICT}" "${SUN_DIR}/userdict" # Automatically backup the userdict, make sure not losing the modification.
p_count=
while [ true ]
do
p_count=$(($p_count+))
sleep if [ $p_count == ]
then
p_count=
cp -f "${SHM_USERDICT}" "${SUN_DIR}/userdict.real"
fi p_size_shm=$(ls -l "${SHM_USERDICT}" | awk '{print $5}')
p_size_real_t=$(ls -l "${SUN_DIR}/userdict.real" | awk '{print $5}')
p_size_real=$(($p_size_real_t+)) if [ $p_size_shm -ge $p_size_real ]
then
cp -f "${SHM_USERDICT}" "${SUN_DIR}/userdict.real"
fi
done
sunpinyin_speed_up
之后将其设置为开机启动就好了。
因为我们用systemd的方式,所以需要再写一个开机启动的服务放到/etc/systemd/system/中。
[Unit]
Description=Sunpinyin dict cache [Service]
ExecStart=/home/xuzhenan/mysh/sunpinyin_speed_up [Install]
WantedBy=multi-user.target
sunpinyin_speed_up.service
之后运行
sudo systemctl enable sunpinyin_speed_up.service
将其设置为开机自启动就好了。
给sunpinyin加速的更多相关文章
- 百度MIP移动页面加速——不只是CDN
MIP是用CDN做加速的么?准确答案是:是,但不只是. MIP全称Mobile Instant Pages,移动网页加速器,是百度提出的页面加速解决方案.MIP从前端渲染和页面网络传输两方面进行优化, ...
- 【初码干货】使用阿里云对Web开发中的资源文件进行CDN加速的深入研究和实践
提示:阅读本文需提前了解的相关知识 1.阿里云(https://www.aliyun.com) 2.阿里云CDN(https://www.aliyun.com/product/cdn) 3.阿里云OS ...
- 阿里云系列——6.给你的域名使用CDN加速(详细步骤+简单配置)
网站部署之~阿里云系列汇总 http://www.cnblogs.com/dunitian/p/4958462.html 进入管理页面:https://home.console.aliyun.com/ ...
- Signalr系列之虚拟目录详解与应用中的CDN加速实战
目录 对SignalR不了解的人可以直接移步下面的目录 SignalR系列目录 前言 前段时间一直有人问我 在用SignalR 2.0开发客服系统[系列1:实现群发通讯]这篇文章中的"/Si ...
- docker学习(2) mac中docker-machine使用vmware fusion以及配置国内镜像加速
一.前言 先回顾下上一节创建docker-machine的过程,默认情况下docker toolbox中的docker-machine使用virtual box创建虚拟机,KI首次启动时创建虚拟机的过 ...
- [转]加速Android Studio/Gradle构建
加速Android Studio/Gradle构建 android android studio gradle 已经使用Android Studio进行开发超过一年,随着项目的增大,依赖库的增多, ...
- 利用免费cdn加速webpack单页应用
回顾现状 在之前的学习过程中,react单页应用经过webpack打包之后会输出大概如下的目录结构,它就是站点的所有前端组成了: 1 2 3 4 5 6 MacBook-Pro:output ba ...
- ffmpeg实现dxva2硬件加速
这几天在做dxva2硬件加速,找不到什么资料,翻译了一下微软的两篇相关文档.这是第二篇,记录用ffmpeg实现dxva2. 第一篇翻译的Direct3D device manager,链接:http: ...
- 用CSS开启硬件加速来提高网站性能
国外一篇文章,有点意思,转载过来,准备尝试下~ 中文地址:http://www.cnblogs.com/rubylouvre/p/3471490.html 原文地址:http://blog.teamt ...
随机推荐
- 91. Ext中获取combobox中的valueField和displayField的值
转自:https://blog.csdn.net/jcy472578/article/details/42113119Ext.getCmp("schemaVersion").val ...
- java将JSON字符串转换为实体类对象,基于net.sf.json实现
@SuppressWarnings("unchecked") public static <T> T jsonToObject(String jsonString, C ...
- [Apple开发者帐户帮助]八、管理档案(3)创建App Store配置文件
您可以创建自己的App Store配置文件,以便在将应用程序上载到App Store Connect时使用. 有关完整的App Store工作流程,请转到通过 Xcode帮助中的App Store分发 ...
- C语言标准库头文件
<assert.h><complex.h><ctype.h><errno.h><fenv.h><float.h><intt ...
- CSS布局——三栏布局
说到三栏布局,很多都会提到圣杯布局和双飞翼布局这两个经典的三栏布局方式.于是,我在网上搜了一些相关资料,阅读并跟着代码敲了一遍,发现在处理三栏布局上,他们采用的都是两边栏固定,中间栏自适应的策略.在处 ...
- Android项目实战_手机安全卫士手机防盗界面
#安全卫士手机防盗# ###1.Activity的任务栈 1.类似一个木桶,每层只能放一个木块,我们放入木块和取出木块的时候只能从最上面开始操作 ###2.Android中的坐标系 organization external ###说明创建外部表 ( ...
- RTL Compiler之synthesis flow
1 generic RTL Compiler work flow 2 invoking RTL compiler RTL Compiler is invoked from the operating ...
- GNSS数据下载网站
Bernese 数据表文件下载 rinex文件下载 ftp://nfs.kasi.re.kr DCB.ION文件ftp://ftp.unibe.ch/AIUB/CODE/ 下载5.0更新文件 ftp: ...
- 回顾Google IO 2016 -Keynote【图解】
Google IO大会倒计时进行中~~ 两名演奏者在使用高空“古筝”. 最后5秒倒计时~~~~全场轰动~ 倒计时结束,IO大会正式开始.屏幕中,一个人把纯白的唱片放入唱片机中. 然后欢快的音乐响起,台 ...