Created
March 15, 2026 14:45
-
-
Save harrigan/cc89eb867e2d473f2014e9b7136dc213 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| set -euo pipefail | |
| IFS=$'\n\t' | |
| trap 'echo "Error: Script failed due to command above."' ERR | |
| # Workaround for xwayland-satellite not propagating keyboard focus | |
| # to X11 clients on niri. | |
| # https://github.com/Supreeeme/xwayland-satellite/issues/263 | |
| # | |
| # Watches niri's JSON event stream for focus changes and uses xdotool | |
| # to activate and click the X11 window, which is needed for toolkits | |
| # like Java Swing to accept keyboard input. | |
| niri msg --json event-stream | jq --unbuffered -r 'select(has("WindowFocusChanged")) | "focus"' | while read -r _; do | |
| sleep 0.05 | |
| if win=$(xdotool getactivewindow 2>/dev/null); then | |
| xdotool windowactivate --sync "$win" | |
| xdotool click --window "$win" 1 | |
| fi | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment