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

Scrolling gesture for notebook? #5

Open
CavaleriOmar opened this issue Jul 28, 2023 · 7 comments
Open

Scrolling gesture for notebook? #5

CavaleriOmar opened this issue Jul 28, 2023 · 7 comments

Comments

@CavaleriOmar
Copy link

I am loving the functionality of such a script, as I become more familiar with it I notice the great potential, but to exploit it fully there on notebooks seems to be something missing, such as a gesture on the touchpad, perhaps three touches to one side to move the focus to that direction.

@peterfajdiga
Copy link
Owner

I agree, but unfortunately the KWin Scripting API doesn't expose mouse or keyboard events and, to my knowledge, neither does QML (other than MouseArea, which is a GUI element).

What KWin does allow, though, is to set keyboard bindings, and I could add bindings for scrolling a fixed number of pixels left or right (Karousel actually already had them, but I've removed them as I thought they were superfluous next to the bindings for scrolling one column to the left or right). Then you could use some software for mapping touchpad gestures to simulate a keypress of the same keyboard shortcut that you'd set in Karousel.

Any alternative ideas on how to hack this feature into existence are also greatly appreciated.

@Thesola10
Copy link

maybe this?

@peterfajdiga
Copy link
Owner

peterfajdiga commented Aug 16, 2023

I've reintroduced the key bindings for scrolling a fixed number of pixels left or right. By default they're Meta+Alt+PgUp and Meta+Alt+PgDown. I haven't tried it yet, but it should be possible to use some software (for example Touchegg, as @Thesola10 suggested) to map touchpad gestures to these two keyboard shortcuts.

EDIT: I've tried to set this up with Touchegg, but Kwin is ignoring the simulated keyboard shortcut.

@r0skar
Copy link

r0skar commented Sep 29, 2023

I am using evsieve to bind certain commands to mouse gestures. So far its been the only tool that works for my usescases on Wayland. eg. I send Meta+Alt+PgUp when I drag my mouse to the right while holding the meta key. And I also emit the event when holding meta key and scrolling down with the mouswheeel.

I dont know about touch support, but it might be worth checking it out anyway.

@kelvie
Copy link

kelvie commented May 28, 2024

You can run the commands directly using dbus, I wrote a script (called it karouselctl) to do this, going to try it once I have time to integrate it with e.g. touchegg:

#!/bin/bash

echoerr() {
    echo "$@" 1>&2
}
usage() {
    echoerr "Usage: $0 [ <action> ]"
}

if [ $# -lt 1 ]; then
    # qdbus org.kde.kglobalaccel /component/kwin org.kde.kglobalaccel.Component.shortcutNames
    # but using busctl.
    busctl -j --user call org.kde.kglobalaccel /component/kwin org.kde.kglobalaccel.Component shortcutNames \
        | jq -r '.data[0].[]'  | grep -e '^karousel-' | sed 's/^karousel-//' | sed 's/[0-9]\+$//' | sort | uniq
    exit 0
fi

set -euo pipefail
action="$1"

busctl --user call org.kde.kglobalaccel /component/kwin org.kde.kglobalaccel.Component invokeShortcut "s" "karousel-$action"

on fish you can get completions with it via: complete -c karouselctl -a '(karouselctl)' -f -k

and use it e.g.:

karouselctl grid-scroll-left

@kelvie
Copy link

kelvie commented May 28, 2024

Totally just got it to work with touchegg (3 finger swipe left and right)

~/.config/touchegg/touchegg.conf

<touchégg>
  <settings>
    <property name="animation_delay">150</property>
    <property name="action_execute_threshold">20</property>
    <property name="color">auto</property>
    <property name="borderColor">auto</property>
  </settings>
  <application name="All">
    <gesture type="SWIPE" fingers="3" direction="LEFT">
      <action type="RUN_COMMAND">
        <command>~/bin/karouselctl grid-scroll-left</command>
        <repeat>true</repeat>
        <animation>NONE</animation>
        <decreaseCommand>~/bin/karouselctl grid-scroll-right</decreaseCommand>
      </action>
    </gesture>
    <gesture type="SWIPE" fingers="3" direction="RIGHT">
      <action type="RUN_COMMAND">
        <command>~/bin/karouselctl grid-scroll-right</command>
        <repeat>true</repeat>
        <animation>NONE</animation>
        <decreaseCommand>~/bin/karouselctl grid-scroll-left</decreaseCommand>
      </action>
    </gesture>
  </application>
</touchégg>

@peterfajdiga
Copy link
Owner

peterfajdiga commented May 31, 2024

This is awesome! I didn't know about that dbus method. Really useful. Thanks for sharing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants