Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Support for ydotool #212

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Python Checks

on:
push:
branches: [ "main" ]
pull_request:

jobs:
check:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13" ]
steps:
- uses: actions/checkout@v4

- name: Set up Python and uv
uses: astral-sh/setup-uv@v5
with:
python-version: ${{ matrix.python-version }}
enable-cache: true
cache-dependency-glob: "uv.lock"
github-token: ${{ secrets.CUSTOM_GITHUB_TOKEN }}

- name: Build
run: uv build

- name: Run ruff
run: uv run ruff check
53 changes: 53 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Upload Python Package

on:
release:
types: [ published ]

permissions:
contents: read

jobs:
build:
name: Build distribution
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python and uv
uses: astral-sh/setup-uv@v5
with:
python-version: 3.13
enable-cache: true
cache-dependency-glob: "uv.lock"
github-token: ${{ secrets.CUSTOM_GITHUB_TOKEN }}

- name: Build a binary wheel and a source tarball
run: uv build

- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/

publish-to-pypi:
name: Publish to PyPI
needs:
- build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/rofimoji
permissions:
id-token: write

steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/

- name: Publish distribution
uses: pypa/gh-action-pypi-publish@release/v1
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ rofimoji.egg-info
dist
build
src/picker/data/copyme.py
venv/
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2017-2024 Fabian Winter
Copyright (c) 2017-2025 Fabian Winter

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
48 changes: 45 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ You can configure `rofimoji` either with cli arguments or with a config file cal
| `--selector-args` | | | | Define arguments that `rofimoji` will pass through to the selector.<br/>Please note that you need to specify it as `--selector-args="<selector-args>"` or `--selector-args " <selector-args>"` because of a [bug in argparse](https://bugs.python.org/issue9334) |
| `--selector` | | `rofi`, `wofi`, `fuzzel`, `dmenu`, `tofi`, `bemenu`, `wmenu` | (automatically chosen) | Show the selection dialog with this application. |
| `--clipboarder` | | `xsel`, `xclip`, `wl-copy` | (automatically chosen) | Access the clipboard with this application. |
| `--typer` | | `xdotool`, `wtype` | (automatically chosen) | Type the characters using this application. |
| `--typer` | | `xdotool`, `ydotool`, `wtype` | (automatically chosen) | Type the characters using this application. |
| `--keybinding-copy`, `--keybinding-type`, `--keybinding-clipboard`, `--keybinding-unicode`, `--keybinding-copy-unicode` | | | `Alt+c`, `Alt+t`, `Alt+p`, `Alt+u`, `Alt+i` | Choose different keybindings than the default values. |

## Example config file
Expand All @@ -94,7 +94,7 @@ The options are:
| `print` | | Print the chosen characters to `stdout`. |

## Insertion method
By default, `rofimoji` types the characters using either `xdotool` or `wtype` (see [display server support](#display-server-support)). You can enforce this behavior with `--action type` (`-a type`).
By default, `rofimoji` types the characters using either `xdotool`, `ydotool`, or `wtype` (see [display server support](#display-server-support)). You can enforce this behavior with `--action type` (`-a type`).

For some applications (f.e. Firefox), this does not work reliably. To work around this, `rofimoji` can copy the emojis to your clipboard and insert them from there with `shift+insert`. Afterwards, it will restore the previous contents.
Unfortunately, it depends on the receiving application whether `shift+insert` uses the clipboard or the primary selection.
Expand Down Expand Up @@ -159,7 +159,7 @@ This also installs the python dependency `configargparse`.
What else do you need:
- Python 3.8 or higher
- A font that can display your scripts, (for emojis, [EmojiOne](https://github.com/emojione/emojione) or [Noto Emoji](https://www.google.com/get/noto/) work)
- Optionally, a tool to programmatically type characters into applications. Either `xdotool` for X11 or `wtype` for Wayland
- Optionally, a tool to programmatically type characters into applications. Either `xdotool` for X11 or `wtype`/`ydotool` for Wayland
- Optionally, a tool to copy the characters to the clipboard. `xsel` and `xclip` work on X11; `wl-copy` on Wayland

### Supported Selectors
Expand All @@ -183,3 +183,45 @@ All other selectors can be used for the basic functionality.
- [tofi](https://github.com/philj56/tofi)
- [bemenu](https://github.com/Cloudef/bemenu)
- [wmenu](https://git.sr.ht/~adnano/wmenu)

# Troubleshooting
To troubleshoot, run `rofimoji` in the command line and inspect its output.

Below is a list of error messages one can get with the typer and other components.
## Typers
> `Compositor does not support the virtual keyboard protocol`

This is an error thrown by `wtype` to indicate that the virtual keyboard protocol is not implemented. You likely use KDE Plasma or Gnome, who don't implement that protocol. Consider using a different typer such as `ydotool` or `xdotool` by passing in the `--typer` argument.

> ```
> failed to connect socket `/run/user/1000/.ydotool_socket': Connection refused
> Please check if ydotoold is running
> ```

This is an error thrown by `ydotool` to indicate it cannot find its service daemon. `ydotool` needs a daemon called `ydotoold` running in the background in order to be able to type things. You can start the `ydotoold` daemon with one of two options:

1. Create a `systemd` service (recommended)

Create the file `/etc/systemd/system/ydotoold.service`and put the following in it:
```ini
[Unit]
Description=Starts ydotoold Daemon

[Service]
Type=simple
Restart=always
RestartSec=3
ExecStartPre=/bin/sleep 2
ExecStart=/usr/bin/ydotoold --socket-path="/run/user/1000/.ydotool_socket" --socket-own="$(id -u):$(id -g)"
ExecReload=/usr/bin/kill -HUP $MAINPID
KillMode=process
TimeoutSec=180

[Install]
WantedBy=basic.target
```
Then run `sudo systemctl enable ydotoold.service && sudo systemctl start ydotoold.service` and rerun `rofimoji`.

2. Run `ydotoold` on its own (*not recommended!*)

Run `ydotoold &` (with or without sudo) and then run `rofimoji`. If it has trouble finding the socket, set the environment variable `YDOTOOL_SOCKET` when running `rofimoji`
Loading