热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

Ahigh-levelLispconfiguratorfortheErgodoxkeyboard

Overview Mugur is a high-level ErgoDox EZ Configurator for Emacs users. M

Overview

Mugur is a high-level ErgoDox EZ Configurator for Emacs users.

Mugur offers a consistent interface for all the ErgoDox features. With the C code configurator, for example, if you want to specify an Ergodox macro key, you first have to give your key a unique name, then write some C code to implmenet this new key, and then finally use it in one of your layers. If you want a mod-tap key, the modifier keycode is different than if you'd just wanted to have a simple modifier key. With mugur, all these features are defined in a consistent way by having all the keys be just simple lists, defined directly in your layers. No extra code, no extra functions. Mugur interprets these mugur-keys differently, depending on the context, and generates the correct C code to implement their semantics.

A mugur-key is just a list of symbols, and can be (k) for sending the k character when tapped, or (C k) for sending k when tapped but acting like Control when held (mod-tap), a string like ("my_email_address@me.com") , a key combination like the often used (C-u C-space) , or even an fbound Emacs function, like (other-window) , among other things (see all features).

This is a simplified example that defines an Ergodox configuration, and contains macros, simple keys, mod-tap, layer changes, combos and emacs fbound symbols (emacs functions). For a more complex example, see the mugur-keymap configuration from my init.el file. This is the configuration that I'm using to flash my ErgoDox.

(mugur-keymap
  :tapping-term 200
  :rgblight-animations nil

  :combos '((left right escape)
            (x y (C-x "pressed both x and y at once")))
  
  :with-keys '((mybspace (lt numeric bspace))
               (emacs-split (C-x 3)))
  
  :layers
  '(("base" vertical
     ((---)   (vol-down) (vol-up) (---) (---) (---) (reset) 
      (---)      (q)        (w)     (e)   (r)  (t)   (---) 
      (---)      (a)       (G t)   (M d) (C f) (g) 
      (osm S)    (z)        (x)     (c)   (v)  (b)   (---) 
      (---)     (---)      (---)   (---) (---) 
                  (other-window) (save-buffers-kill-emacs) 
                                                     (M-x)
                       (mybspace) (lt numeric space) (tab))

     (---) (---) (---)  (---)  (---) (---)  (---)
     (---)  (y)   (u)    (i)    (o)  (---)  (---)
            (h)  (C j)  (M k)  (G l)  (p)   (---)
     (---)  (n)   (m)  (comma) (dot) (---) (osm S)
                 (---)  (---)  (---) (---)  (---)
     (emacs-split) (---)
     (C-u C-space)
     (escape) (enter) (---))
  
  ("numeric"
    (( ) ( ) ( ) ( ) ( ) ( ) ( )     ( ) ( ) ( ) ( ) ( ) ( ) ( )
     ( ) ( ) (1) (2) (3) ( ) ( )     ( ) ( ) ( ) ( ) ( ) ( ) ( )
     ( ) ( ) (4) (5) (6) ( )             ( ) ( ) ( ) ( ) ( ) ( )
     ( ) (0) (7) (8) (9) ( ) ( )     ( ) ( ) ( ) ( ) ( ) ( ) ( )
     ( ) ( ) ( ) ( ) ( )                     ( ) ( ) ( ) ( ) ( )
                         ( ) ( )     ( ) ( )
                         (1 2 3)     ("one two three")
                     ( ) ( ) ( )     ( ) ( ) ( )))))

Install

Git clone it, for now, until this package will be available from MELPA.

git clone https://github.com/mihaiolteanu/mugur ~/.emacs.d/lisp/mugur

Add mugur to your load-path

(add-to-list 'load-path "~/.emacs.d/lisp/mugur")

Set the mugur-qmk-path to point to the location of your qmk source code .

(setf mugur-qmk-path "/home/mihai/projects/qmk_firmware")

You'll also need wally-cli if you want to flash directly from Emacs.

Supported keys in the mugur-keymap layers

The following are all qmk features that are supported by mugur by directly specifying a mugur-key in the mugur-keymap definition. A mugur-key is a list that contains one or more qmk keycodes, modifiers, special symbols and the like. Depending on the context, the same keycode might mean different things. Bellow are the definitions of these mugur-keys which highlight the supported features of mugur.

Simple keys ( qmk )

(key)

This defines a simple, normal key, like in a classic keyboard. All the normal keys are supported, including all the letters, numbers, punctuation marks, commands (like enter) and mouse keys. Most of them can be specified as is, like (x), (enter) or (^) but some, like the open parenthesis for example, has to be specified either as a string, like ("(") or (lparens). The full list of supported keycodes can be checked out by calling mugur-doc-keycodes . The right hand side on that list corresponds to the qmk's simple keycodes list, but without the KC_ prefix.

Mod-Tap ( qmk )

(modifier key)

Send the key when tapped, as above, but act like the modifier key when held . The modifiers are C, M, G, and S for Control, Alt, Win and Shift. Combinations like C-M, C-M-S or C-M-G are also possible. Consult the mugur-doc-keycodes list for the supported modifiers.

The modifier key has to be in uppercase and has to be the first in the list, otherwise (c a) means a totally different thing.

Modifier Keys ( qmk )

(modifier-key)

Hold down the modifier and press key at the same time. For example, (C-a) will send C-a when tapped. That is, send the a keycode with C (Control) pressed.

Layers ( qmk )

(tg layer)

(lt layer mod-or-key)

Send key when tapped, momentarily switch to layer when held, for example. There are a lot of variants for these layer-switching keys. Check out the mugur-doc-layer-switching or the official qmk documentation linked above for the complete list

Unlike the previous examples where the key definition is context aware, in this key, the first element of the key must be one of lt , to , etc. to unambiguously define what kind of layer switching you want.

For example, (lt symbols a) will send a when tapped and momentarily switch to the symbols layer when held. The symbols layers must be available in the mugur-keymap list of layers.

One Shot Layer ( qmk )

(osl layer)

Momentarily activates layer until a key is pressed, after which, if goes back to the original layer.

One Shot Modifier ( qmk )

(osm modifier)

Similar to the one shot layer, momentarily activates the modifier key until a key is pressed, after which, it deactivates it. Useful for Shift modifiers, for example, to insert uppercase letters.

Tapdance ( qmk )

(key1 key2)

(key layer)

The tapdance feature is vast and featureful. Mugur only supports one simple case where you can send two different characters with a single key, for example.

That is, (a b) will send a when tapped once and b when tapped twice in quick succession. An alternative is to specify a layer as the second key, (a symbols) , which will switch to the symbols layer when tapped twice.

Macros ( qmk )

(any number of keys, modifiers or strings)

If your key definition doesn't mach any definition from above, mugur will infer that your key is more than likely a macro. With a macro, you can send your email address when you press a key, or send any other key combination.

For example, (C-e "this is awesome." enter) would define a key that, when tapped, will call C-e, then send "this is awesome" followed by Enter.

These two are equivalent macros: (a b c) , ("a b c") .

User-defined mugur-key names

(mykey)

All the above key definitions can be given a name. This is useful when they become quite large and are hard to see or destroy the visual look of the layer (long macros, for example). mugur-keymap supports the :with-keys argument for these cases. For example these are two keys that can be used as (myspace) and (em-split) in the mugur-keymap layers,

:with-keys '((mybspace (lt xwindow bspace))
             (em-split (C-x 3)))

The first element of each list is the new key name and the second element is anything that could have been specified directly in the mugur-keymap layers. In short, this is just a list of shortcuts.

Combos ( qmk )

(key1 key2 action-or-key)

Combos are not keys you can use in the mugur-keymap layers, but specify what happens when you press two keys at the same time.

mugur-keymap supports a keyboard argument named :combos for these cases,

:combos '((left right escape)
          (x y (C-x "now")))

In the above case, pressing left and right and the same time will send the escape key and pressing x and y will send C-x followed by "now".

Emacs functions

(fbound-emacs-symbol)

Specify an fbound symbol (a function name) directly in the key definition. Mugur keeps an internal list of exotic and unbound key sequences (kbd's) which it can bind to the functions specified in the layers definition.

That is, you specify (sp-next-sexp) as a key definition, for example, mugur finds an available key sequence, say C-F5, and puts that in your keymap. When you flash your keyboard, mugur generates an .el file that contains bind-key forms for all such keys. When flashing, mugur loads this file for you, but when you start or restart Emacs you'll have to manually load this file by calling mugur-load-keybindings in your init.el file or interactively.

Layer general config options

These two options can be specified anywhere after the layer name in the mugur-kemap entry. These do not affect the mugur-key definitions.

Turn on LEDs on layer switching

When defining the mugur-keymap , you can add a list of three elements after a layer name but before the key definitions list. A list like (1 0 0) will turn on the first led on your keyboard when that layer is active. You can turn on any LED, all the LEDs or none. This feature is only supported for Ergodox Ez keyboards for now. PRs accepted for other keyboards.

Keymap orientation

Since the base layer usually has lots and lots of keys, it might be better to split the keyboard halves vertically for a better view. For layers where most of the keys are transparent keys, the layout can be more compact and a horizontal split might be more convenient. The default is horizontal, but you can change this behavior by simply adding a vertical (or confirm it by adding horizontal ) between the layer name and the actual layer keys.

Configuration options

Besides the actual layers, you can specify a list of additional config options for each mugur-keymap . These are all implemented as keyword arguments, and include tapping-term , combo-term , rgblight-enable , rgblight-animations and force-nkro . The meaning and functionality of these arguments should be checked in the qmk documentation . More such config options can be added in the future, as the need arises. Open an issue if you need something from the qmk extensive list of options.

Generate, build and flash the qmk keyboards

All the following functionalities lets you select one of your keymaps, as defined with mugur-keymap . If you only have one keymap defined, that keymap is used by default.

Generate keymap

mugur-generate : Generate the C files in the qmk_path/keymap-name folder. These are the same files that you would write by hand but are now generated by mugur based on the keymap specified with mugur-keymap .

Make keymap

mugur-make : Call make on the generated qmk layout. A new compile-mode buffer is opened with the compile results.

Build keymap

mugur-build : Generate and make the keymap. This is equivalent to calling mugur-generate and mugur-make one after another.

Flash keymap

mugur-flash : Flash the keymap (actually the generated hex file). Currently only supported for Ergodox Ez keyboards. For other boards the flashing process might be different. Consider opening an issue or a PR if you own other keyboards and you want this feature supported for them as well.


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 我们


推荐阅读
  • MongoDB高可用架构:深入解析Replica Set机制
    MongoDB的高可用架构主要依赖于其Replica Set机制。Replica Set通过多个mongod节点的协同工作,实现了数据的冗余存储和故障自动切换,确保了系统的高可用性和数据的一致性。本文将深入解析Replica Set的工作原理及其在实际应用中的配置和优化方法,帮助读者更好地理解和实施MongoDB的高可用架构。 ... [详细]
  • 在Java编程中,为了提高代码的可读性和执行效率,建议优先使用局部变量来存储方法的返回值,而不是多次调用同一个方法。这样不仅可以减少方法调用的开销,还能避免潜在的性能问题。此外,使用局部变量还可以增强代码的可维护性和调试便利性。 ... [详细]
  • 本书详细介绍了在最新Linux 4.0内核环境下进行Java与Linux设备驱动开发的全面指南。内容涵盖设备驱动的基本概念、开发环境的搭建、操作系统对设备驱动的影响以及具体开发步骤和技巧。通过丰富的实例和深入的技术解析,帮助读者掌握设备驱动开发的核心技术和最佳实践。 ... [详细]
  • 本文深入探讨了RecyclerView的缓存与视图复用机制,详细解析了不同类型的缓存及其功能。首先,介绍了屏幕内ViewHolder的Scrap缓存,这是一种最轻量级的缓存方式,旨在提高滚动性能并减少不必要的视图创建。通过分析其设计原理,揭示了Scrap缓存为何能有效提升用户体验。此外,还讨论了其他类型的缓存机制,如RecycledViewPool和ViewCacheExtension,进一步优化了视图复用效率。 ... [详细]
  • Git基础操作指南:掌握必备技能
    掌握 Git 基础操作是每个开发者必备的技能。本文详细介绍了 Git 的基本命令和使用方法,包括初始化仓库、配置用户信息、添加文件、提交更改以及查看版本历史等关键步骤。通过这些操作,读者可以快速上手并高效管理代码版本。例如,使用 `git config --global user.name` 和 `git config --global user.email` 来设置全局用户名和邮箱,确保每次提交时都能正确标识提交者信息。 ... [详细]
  • PHP中元素的计量单位是什么? ... [详细]
  • Spring Boot 实战(一):基础的CRUD操作详解
    在《Spring Boot 实战(一)》中,详细介绍了基础的CRUD操作,涵盖创建、读取、更新和删除等核心功能,适合初学者快速掌握Spring Boot框架的应用开发技巧。 ... [详细]
  • 开发心得:深入探讨Servlet、Dubbo与MyBatis中的责任链模式应用
    开发心得:深入探讨Servlet、Dubbo与MyBatis中的责任链模式应用 ... [详细]
  • 本文作为“实现简易版Spring系列”的第五篇,继前文深入探讨了Spring框架的核心技术之一——控制反转(IoC)之后,将重点转向另一个关键技术——面向切面编程(AOP)。对于使用Spring框架进行开发的开发者来说,AOP是一个不可或缺的概念。了解AOP的背景及其基本原理,对于掌握这一技术至关重要。本文将通过具体示例,详细解析AOP的实现机制,帮助读者更好地理解和应用这一技术。 ... [详细]
  • Android 图像色彩处理技术详解
    本文详细探讨了 Android 平台上的图像色彩处理技术,重点介绍了如何通过模仿美图秀秀的交互方式,利用 SeekBar 实现对图片颜色的精细调整。文章展示了具体的布局设计和代码实现,帮助开发者更好地理解和应用图像处理技术。 ... [详细]
  • 本文详细介绍了如何在Linux系统中搭建51单片机的开发与编程环境,重点讲解了使用Makefile进行项目管理的方法。首先,文章指导读者安装SDCC(Small Device C Compiler),这是一个专为小型设备设计的C语言编译器,适合用于51单片机的开发。随后,通过具体的实例演示了如何配置Makefile文件,以实现代码的自动化编译与链接过程,从而提高开发效率。此外,还提供了常见问题的解决方案及优化建议,帮助开发者快速上手并解决实际开发中可能遇到的技术难题。 ... [详细]
  • Jedis接口分类详解与应用指南
    本文详细解析了Jedis接口的分类及其应用指南,重点介绍了字符串数据类型(String)的接口功能。作为Redis中最基本的数据存储形式,字符串类型支持多种操作,如设置、获取和更新键值对等,适用于广泛的应用场景。 ... [详细]
  • 深入解析零拷贝技术(Zerocopy)及其应用优势
    零拷贝技术(Zero-copy)是Netty框架中的一个关键特性,其核心在于减少数据在操作系统内核与用户空间之间的传输次数。通过避免不必要的内存复制操作,零拷贝显著提高了数据传输的效率和性能。本文将深入探讨零拷贝的工作原理及其在实际应用中的优势,包括降低CPU负载、减少内存带宽消耗以及提高系统吞吐量等方面。 ... [详细]
  • 探索JavaScript倒计时功能的三种高效实现方法及代码示例 ... [详细]
  • 在Matlab中,我尝试构建了一个神经网络模型,用于预测函数 y = x^2。为此,我设计并实现了一个拟合神经网络,并对其进行了详细的仿真和验证。通过调整网络结构和参数,成功实现了对目标函数的准确估计。此外,还对模型的性能进行了全面评估,确保其在不同输入条件下的稳定性和可靠性。 ... [详细]
author-avatar
mobiledu2502859163
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有