Skip to content

Commit

Permalink
update readme regarding custom tables feature
Browse files Browse the repository at this point in the history
  • Loading branch information
v-spassky committed Jul 12, 2023
1 parent 1e8a6b4 commit afbc684
Show file tree
Hide file tree
Showing 2 changed files with 118 additions and 6 deletions.
124 changes: 118 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
A keyboard layout switcher. Just highlight the text and press a preconfigured
hotkey to switch the layout.

<img src="assets/happensdemo.gif" alt="workflow demonstration"/>

### Installation

1. Install `xdotool`:
Expand All @@ -17,8 +15,122 @@ sudo apt install xdotool
2. Grab the binary from releases and put it in any folder that is visible in
`$PATH`.

3. [Bind the binary to a hotkey](https://help.ubuntu.com/stable/ubuntu-help/keyboard-shortcuts-set.html.en) in your desktop environment. Note the `--table`
argument. Currently, the only supported tables are `eng-to-ru` and `ru-to-eng`
but new ones are coming.
> **Note:**
>
> If there is no pre-built binary for your platform, you may build it
> yourself from source like this (Rust tooling is required):
```
git clone https://github.com/v-spassky/happens.git
```

```
cd happens
```

```
cargo build --release
```

```
cp target/release/happens ~/.local/bin/
```

```
chmod u+x ~/.local/bin/happens
```

3. [Bind the binary to a hotkey](https://help.ubuntu.com/stable/ubuntu-help/keyboard-shortcuts-set.html.en)
in your desktop environment.

<img src="assets/hotkey-binding-example.png" alt="ubuntu hotkey binding example"/>

You may set up the binding in two distinct modes:

##### Using one of the precompiled tables:

```
happens --table [ru-to-eng | eng-to-ru]
```

Example:

```
happens --table ru-to-eng
```

With such configuration, the program will work like this:

<img src="assets/happensdemo.gif" width="500" alt="workflow demonstration"/>

##### Using your own custom table:

```
happens --from-file /<...>/table.txt
```

In this case, the `table.txt` file should be formatted as follows:

<img src="assets/hotkey-binding-example.png" alt="workflow demonstration"/>
```
<key1_before>: <key1_after>
<key2_before>: <key2_after>
...
<keyN_before>: <keyN_after>
```

Example:

```
a: R
s: R
d: R
f: R
g: R
```

With the configuration above using the custom table shown above, the program
will work like this:

<img src="assets/happensdemo2.gif" width="500" alt="workflow demonstration 2"/>

### Development notes

To set up the program up and running, first set up a hotkey binding to call
such command:

```
happens --from-file /<...>/happens/samples/custom_table.txt --logfile-name /<...>/happens/logs.txt
```

Alternatively, if you want to use the a precompiled table:

```
happens --table [ru-to-eng | eng-to-ru] --logfile-name /<...>/happens/logs.txt
```

Then, copy the binary from project folder to a folder, visible in `$PATH`
and make it executable:

```
cargo build
```

```
cp target/debug/happens ~/.local/bin/
```

```
chmod u+x ~/.local/bin/happens
```

Or, as a shortcut:

```
cargo build && cp target/debug/happens ~/.local/bin/ && chmod u+x ~/.local/bin/happens
```

It is also possible to run the program via a terminal like this:

```
cargo run -- --from-file /<...>/happens/samples/custom_table.txt
```
Binary file added assets/happensdemo2.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit afbc684

Please sign in to comment.