Kindle 搜索栏快捷代码研究

对于 Kindle 越狱玩家来说,搜索栏快捷代码绝对不是什么陌生的东西.最近,我注意到 USBNetwork 这个越狱插件在安装后会为 Kindle 添加两个自定义的快捷代码: ;un 和 ;usbnetwork ,这似乎意味着此类代码并非是写死在系统中的,而是可以通过某种手段新增或修改的.

如何做到对快捷代码的自定义呢?或者说,快捷代码被调用的实际过程是怎样的?一个自然的思路是,每个快捷代码都对应 $PATH 中的一个可执行文件.为了验证这一猜想,执行 find / -name "*711*" 命令,发现存在 /usr/bin/711.sh 文件.进一步发现 /usr/bin 目录下存在大量与某一快捷代码对应的 Shell 脚本,如 311.sh 411.sh 611.sh debugOn.sh 等.这一猜想似乎是正确的.

我研究搜索栏快捷代码的原因其实是想找到一条快速启动 KOReader 阅读器的途径.(默认是通过 KUAL 这个应用启动器来启动 KOReader 的,但操作十分繁琐.)于是我新建了 /usr/bin/ko.sh 文件,内容为:

#!/bin/sh

/mnt/us/koreader/koreader.sh

然后回到主屏幕,在搜索栏中输入 ;ko 并回车,发现并没有成功启动 KOReader.看来并没有找对方法.

当然,这些快捷代码也有可能是以 LIPC 方式储存的 (Kindle 系统一大特色).于是尝试 lipc-probe -av | grep 711 命令,但没有发现与 ;711 这个快捷代码的定义有关的内容.(不过意外地发现执行 ;711 后返回的内容是存在 LIPC 里的)

查阅 MobileRead Wiki 后发现,所有的快捷代码实际上都定义在 /usr/share/webkit-1.0/pillow/debug_cmds.json 这个文件内.这个文件的内容是:

{Blocking
    ";dm" : "/usr/bin/dm.sh",
    ";dmcc" : "/usr/bin/dmcc.sh",
    ";dh" : "/usr/bin/dh.sh",
    ";dt" : "/usr/bin/dt.sh",
    ";wifipopup" : "/usr/local/bin/wifipopup.sh",
    ";sandbox" : "/usr/local/bin/sandbox.sh",
    ";sbx" : "/usr/local/bin/sandbox.sh",
    ";shpm" : "/usr/sbin/shipping_mode",
    ";lzzl" : "/usr/sbin/shipping_mode",
    ";urst" : "/usr/sbin/userstore_reset",
    ";usbnetwork" : "/usr/local/bin/usbnetwork.sh start",
    ";un" : "/usr/local/bin/usbnetwork.sh start",
    ";uns" : "/usr/local/bin/usbnetwork.sh stop",
    ";di" : "/usr/local/bin/indexerdisable.sh",
    "`stopIndexing" : "/usr/local/bin/indexerstop.sh",
    "`startIndexing" : "/usr/local/bin/indexerenable.sh",
    "`disableIndexing" : "/usr/local/bin/indexerdisable.sh",
    "`indexStatus" : "/usr/local/bin/indexstatus.sh",
    ";ddc" : "/usr/local/bin/dynconfig.sh",
    ";resetConfig" : "/usr/local/bin/resetConfig.sh",
    ";rc" : "/usr/local/bin/resetConfig.sh",
    ";twoFingerChromeOn" : "/usr/local/bin/altChrome.sh 1",
    ";homeKeyChromeOn" : "/usr/local/bin/altChrome.sh 2",
    ";normalChrome" : "/usr/local/bin/altChrome 0",
    ";debugOn" : "/usr/bin/debugOn.sh",
    ";debugPaint" : "/usr/bin/debugPaint.sh",
    ";debugOff" : "/usr/bin/debugOff.sh",
    ";debugPerf" : "/usr/bin/debugPerf.sh",
    ";dP" : "/usr/bin/debugPerf.sh",
    ";311" : "/usr/bin/311.sh",
    ";411" : "/usr/bin/411.sh",
    ";611" : "/usr/bin/611.sh",
    ";711" : "/usr/bin/711.sh",
    ";setTime" : "/usr/bin/dateTime.sh",
    ";st" : "/usr/bin/dateTime.sh",
    "~ds" : "/usr/bin/ds.sh",
    ";hv" : "/usr/local/bin/htmlViewer.sh",
    ";installHtml" : "/usr/local/bin/installHtmlViewer.sh",
    ";merchant" : "/usr/local/bin/merchant.sh",
    ";updateCamp" : "/usr/bin/updateCamp.sh",	
    ";cll" : "/usr/bin/configureloglevel.sh",
    ";rll" : "/usr/bin/resetLogInfo.sh",
    ";reagloff" : "/usr/local/bin/reaglMode.sh 0",
    ";reaglswitch" : "/usr/local/bin/reaglMode.sh 1",
    ";reaglfull" : "/usr/local/bin/reaglMode.sh 2",
    ";reagldfull" : "/usr/local/bin/reaglMode.sh 3",
    ";reagldpart" : "/usr/local/bin/reaglMode.sh 6",
    ";reaglpart" : "/usr/local/bin/reaglMode.sh 7",
    ";reaglswitch2" : "/usr/local/bin/reaglMode.sh 8",
    ";dsc" : "/usr/local/bin/discovery.sh",
    ";debugScripts" : "/usr/bin/confirmDebugScriptsEnabled.sh",
    ";pcap" : "/usr/local/bin/pcap.sh",
    ";fw" : "/usr/local/bin/firewall.sh",
    ";dgsmden" : "/usr/local/bin/enableDiags.sh",
    ";reaglConfig" : "/usr/bin/reaglConfig.sh",
    ";gsdebug" : "/usr/local/bin/gsdebug.sh",
    ";mangaGcFlash" : "/usr/bin/mangaGcFlash.sh",
    ";report" : "/usr/bin/reportBug.sh",
    ";recoverUserType" : "/usr/bin/recoverUserType.sh",
    ";mkjira" : "/usr/bin/createJira.sh",
    ";ghp" : "/usr/bin/generateHprof.sh",
    ";log" : "/usr/bin/logThis.sh",
    ";ooms" : "/usr/local/bin/oomWatch.sh",
    ";gs"  : "/usr/bin/configureGripSuppression.sh",
    ";dshot" : "/usr/bin/delayShot.sh",
    ";csc" : "/usr/bin/clearStoreCache.sh",
    ";uzb" : "/usr/bin/enableUSBInDemo.sh",
    ";duzb" : "/usr/bin/disableUSBInDemo.sh",
    ";dsts" : "/usr/bin/startSettingsInDemo.sh",
    ";enter_demo" : "/usr/bin/createDemoModeFlagFile.sh",
    ";exit_demo" : "/usr/bin/deleteDemoModeFlagFile.sh",
    ";demo" : "/usr/bin/demoConfig.sh",
    ";vfd" : "/usr/bin/verifyDemo.sh",
    ";wwftux" : "/usr/local/bin/wwResetFtux.sh",
    ";wwreset" : "/usr/bin/wwReset.sh",
    ";chkup" : "/usr/bin/checkUpdate.sh",
    ";wwresetoverride" : "/usr/bin/wwResetOverride.sh",
    ";wwresetknown" : "/usr/bin/wwResetKnown.sh",
    ";att" : "/usr/bin/play.sh" ,
    ";astop" : "/usr/bin/stopPlay.sh",
    ";accelstop" : "/usr/bin/accel_log_stop.sh",   
    ";accel" : "/usr/bin/accel_log.sh",
    ";invertedPage" : "/usr/bin/pageTurnConfig.sh",
    ";qb" : "/usr/bin/quickboot.sh",
    ";jit" : "/usr/bin/resetTutorial.sh",
    ";kb1" : "/usr/bin/cspUpdate.sh",
    ";kb2" : "/usr/bin/enableKeyboards.sh",
    ";temp" : "/usr/local/bin/showTemperature.sh",
    ";bsalogOn" : "/usr/bin/bsaLogOn.sh",
    ";bsalogOff" : "/usr/bin/bsaLogOff.sh",
    ";pinyinreset" : "/usr/bin/pinyinReset.sh"

}

一目了然,快捷代码与可执行文件的对应关系以 JSON 格式储存,可以自行添加.同时也注意到,快捷代码并非必须以 ; 开头.考虑到我添加快捷代码是为了方便启动 KOReader, 而分号在 Kindle 的虚拟键盘里并非那么容易找到,我添加了这么一行:

".ko" : "/usr/bin/ko.sh"

然后重启.以后,就可以通过在搜索栏里输入 .ko 来启动 KOReader 了,非常方便.使用类似的方法,也可以为其它 Kindle 功能或越狱插件设置快捷代码.

有两点需要注意:

  1. 修改 /usr/share/webkit-1.0/pillow/debug_cmds.json 前,似乎需要把 Kindle 的根文件系统挂载为读写,方法是执行 mntroot rw .出于安全考虑,修改完成后应该执行 mntroot ro 挂载只读.
  2. 在为 /usr/share/webkit-1.0/pillow/debug_cmds.json 新增内容时,记得要给上一行的末尾加上逗号,这毕竟是 JSON.

以上.

6 thoughts on “Kindle 搜索栏快捷代码研究

    • 我不知道,但可以给你提供一个思路: Kindle 的操作系统的 UI 部分用的全是 web 那套技术,或许搜索栏的图标和布局是定义在系统目录的某个 HTML 文件里的.或者,你也可以在 Kindle 的开放源代码里找找(虽说 UI 部分的代码很大可能是私有的闭源代码)

发表评论

电子邮件地址不会被公开。 必填项已用*标注