Repository navigation
Give TUI and agent windows their terminal's touchpad scroll speed #15840
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
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| #!/bin/bash | ||
|
|
||
| source "$(dirname "${BASH_SOURCE[0]}")/base-test.sh" | ||
|
|
||
| require_command lua | ||
|
|
||
| tmpdir=$(mktemp -d) | ||
| trap 'rm -rf "$tmpdir"' EXIT | ||
|
|
||
| # The scroll_touchpad rules input.lua registers, one per line: class, initial | ||
| # title (any title when the rule doesn't match on it), and speed. | ||
| rules=$(HOME="$tmpdir" XDG_CONFIG_HOME="$tmpdir/.config" OMARCHY_PATH="$ROOT" lua <<'LUA' | ||
| package.path = os.getenv("OMARCHY_PATH") .. "/?.lua;" .. package.path | ||
|
|
||
| hl = { | ||
| config = function() end, | ||
| window_rule = function(rule) | ||
| if rule.scroll_touchpad then | ||
| print(("%s\t%s\t%s"):format(rule.match.class, rule.match.initial_title or ".*", rule.scroll_touchpad)) | ||
| end | ||
| end, | ||
| } | ||
|
|
||
| require("default.hypr.helpers") | ||
| require("default.hypr.input") | ||
| LUA | ||
| ) || fail "input.lua loads" "$rules" | ||
|
|
||
| # Hyprland matches a pattern against the whole value, and the last matching | ||
| # rule wins. | ||
| scroll_touchpad_for() { | ||
| local class="$1" initial_title="$2" | ||
| local rule_class rule_title speed result="" | ||
|
|
||
| while IFS=$'\t' read -r rule_class rule_title speed; do | ||
| [[ $class =~ ^($rule_class)$ ]] || continue | ||
| [[ $initial_title =~ ^($rule_title)$ ]] || continue | ||
| result=$speed | ||
| done <<<"$rules" | ||
|
|
||
| printf '%s\n' "$result" | ||
| } | ||
|
|
||
| assert_scroll_touchpad() { | ||
| local description="$1" class="$2" initial_title="$3" expected="$4" | ||
| local actual | ||
|
|
||
| actual=$(scroll_touchpad_for "$class" "$initial_title") | ||
| [[ $actual == "$expected" ]] || fail "$description" "expected '$expected', got '$actual'" | ||
| pass "$description" | ||
| } | ||
|
|
||
| assert_scroll_touchpad "foot windows scroll at foot's speed" "foot" "foot" "2.0" | ||
| assert_scroll_touchpad "foot's other app-id scrolls at foot's speed" "org.codeberg.dnkl.foot" "foot" "2.0" | ||
| assert_scroll_touchpad "an agent window in foot scrolls at foot's speed" "org.omarchy.agent" "foot" "2.0" | ||
| assert_scroll_touchpad "a TUI in kitty scrolls at kitty's speed" "org.omarchy.btop" "kitty" "1.5" | ||
| assert_scroll_touchpad "an installed TUI in Alacritty scrolls at Alacritty's speed" "TUI.float" "Alacritty" "1.5" | ||
| assert_scroll_touchpad "an agent window in Ghostty scrolls at Ghostty's speed" "org.omarchy.agent" "Ghostty" "0.2" | ||
| assert_scroll_touchpad "Ghostty windows scroll at Ghostty's speed" "com.mitchellh.ghostty" "Ghostty" "0.2" | ||
| assert_scroll_touchpad "other apps keep the global touchpad speed" "chromium" "foot" "" | ||
| assert_scroll_touchpad "an Omarchy window whose title only starts with a terminal's name keeps the global touchpad speed" "org.omarchy.agent" "football" "" | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.