Code Monkey home page Code Monkey logo

wlanthy's Introduction

wlanthy

Experimental, simple Wayland-native Japanese input method, using protocols implemented by wlroots. Born as a modification of wlhangul.

On Sway, this requires version >= 1.6.

Building

Depends on anthy, wayland and libxkbcommon.

meson build/
ninja -C build/
./build/wlanthy

By default it starts in anthy mode, so you should be able to start typing in japanese right away after giving focus to a supported application.

Supported applications are those that implement the text-input-v3 protocol:

  • gtk+3 applications (e.g. Firefox, GNOME apps)
  • foot terminal emulator, since 1.6.0

Unfortunately, at the moment qt5 implements text-input-v2 which is not implemented by wlroots.

Usage

Romaji input is immediately turned into kana. Press Space to subdivide the sentence into segments called phrases (文節). Use Tab or Left/Right to navigate between phrases: for a given phrase you can press Space or Up/Down to change candidates and use Alt+Tab to resize it. Undo with Backspace. Commit with Enter (or by starting to type the next sentence).

By default romaji input is mapped into Hiragana. Other mappings can be selected with the following keys:

F5 F6 F7 F8
Hiragana Katakana Half-Width Full-Width

Press F12 to toggle anthy/passthrough mode. Passthrough mode is slow because the key has to travel back-and-forth between wlanthy and the compositor, so it is recommended to instead bind a keyboard shortcut to a script that toggles the wlanthy service.

License

MIT

wlanthy's People

Contributors

ammgws avatar dnkl avatar emersion avatar jbeich avatar st3r4g avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

wlanthy's Issues

Build fails on FreeBSD

Hey, I'm trying to build this on FreeBSD but I get an error where meson complains that libanthyinput can't be found. I'm able to build wlhangul just fine, so I'm trying to find out if it is an issue with the ja-anthy package in FreeBSD.

Running meson build/ gives me:

The Meson build system
Version: 0.59.1
Source dir: /usr/home/kallinen/code/wlanthy
Build dir: /usr/home/kallinen/code/wlanthy/build
Build type: native build
Project name: wlanthy
Project version: 0.0.0
C compiler for the host machine: cc (clang 11.0.1 "FreeBSD clang version 11.0.1 ([email protected]:llvm/llvm-project.git llvmorg-11.0.1-0-g43ff75f2c3fe)")
C linker for the host machine: cc ld.lld 11.0.1
Host machine cpu family: x86_64
Host machine cpu: x86_64
Compiler for C supports arguments -Wno-missing-braces: YES 
Compiler for C supports arguments -Wno-unused-parameter: YES 
Found pkg-config: /usr/local/bin/pkg-config (1.7.4)
Run-time dependency anthy found: YES 0.4

meson.build:29:1: ERROR: C shared or static library 'anthyinput' not found

meson-log.txt

Can virtual-keyboard be avoided? (partial keyboard grab)

Forwarding keys with virtual-keyboard has a performance penalty (input latency). The key travels in this way:
compositor -> im -> compositor -> end_client

We need to forward keys based on our state sometimes (e.g. Return, Tab, Backspace). We could tell the compositor at connection time the set of keys we would like to receive for each of the "states" and tell the compositor every time the state changes. In this way forwarding has no penalty:
compositor -> end_client

But we would need to extend the input-method protocol for this. Is it doable?

For wlanthy the partial keyboard grab config would look like this:
In state 0, we want to receive: Space...asciitilde
In state 1, we want to receive: Space...asciitilde+F5...F8+Return+BackSpace+Tab+Left_Tab+Alt_L (mod)
Important: If any modifier is active, the compositor must not send keys unless we specified that modifier in the list. If the user presses Ctrl+A, we don't want to catch A. But if we are in state 1, we do want to receive Alt+Tab.

The partial grab is configured by issuing multiple times (for different values of state) this request:

<request name="configure_grab">
  <arg name="state" type="uint"/>
  <arg name="ranges" type="array"/>
  <arg name="singles" type="array"/>
</request>

And in order to notify the compositor of a state change:

<request name="state_change">
  <arg name="state" type="uint"/>
</request>

But... for this to work, the above must be sent every each key event (even if the state stays the same), and the compositor must wait for it before sending the next.

Another approach might be to statically configure also the keys that change states so the compositor is automatically aware:

<request name="configure_transitions">
  <arg name="state_i" type="uint"/>
  <arg name="state_f" type="uint"/>
  <arg name="singles" type="array"/>
</request>

So:

<interface name="zwp_input_method_keyboard_grab_v2" version="2">
...
  <request name="configure_grab">
    <arg name="state" type="uint"/>
    <arg name="ranges" type="array"/>
    <arg name="singles" type="array"/>
  </request>

  <request name="configure_transitions">
    <arg name="state_i" type="uint"/>
    <arg name="state_f" type="uint"/>
    <arg name="singles" type="array"/>
  </request>
...
</interface>

Underlying keymap issue

Hi,

I found a weird (and somewhat problematic, at least for me) behavior: on the first launch of wlanthy, it uses the keymap of the first keyboard I type on (fr-oss for the built-in keyboard and bepo for the external keyboard) but if I kill it (^C), I have to wait ~10-15 minutes or the keymap used by wlanthy will be qwerty (no other software seems to be impacted).

While I don’t really mind being restricted to the first keymap used on launch*, I would prefer being able to simply restart wlanthy when I un-/dock the laptop (and changing which physical keyboard I use) without waiting 10-15 minutes before being able to use it again.

Any idea on how to diagnose/fix this? 🙂

In case it helps:

  • Sway v1.6.1
  • VoidLinux
  • Linux 5.12.17_1
  • wlanthy from master (6cf315a) launched manually via foot 1.8.2

とにかく,wlanthyを生み出してありがとう! (apologies for any mistake, I have much to learn still 😛)

* Obviously, it would be best if the underlying keymap could change on the fly but it would be more of a nice-to-have feature ^^

Some keys are passed through to client while in pre-edit

Some keys, like the arrow keys, are passed through to the client while pre-editing. As a result, I can "move" whatever I'm pre-editing in e.g. vim.

Not sure if the above description is clear enough. Let me know if it's not.

Integrating wlanthy with "xkb_layout"

Hi, I use sway and up until recently I only used two keyboard layouts(none of which are Japanese), and switched between them in the following way in the .config/sway/config file:

input * {
    xkb_layout "us,il"
    xkb_options "grp:caps_toggle"
}

I would like to make it possible so that when I press tab, the keyboard layout would still change like it does now, but also "toggle" to the wlanthy service so that I could seamlessly switch between all three languages using tab. How can I do this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.