peterfajdiga / karousel

Scrollable tiling Kwin script
GNU General Public License v3.0
252 stars 5 forks source link

Scrolling gesture for notebook? #5

Open CavaleriOmar opened 1 year ago

CavaleriOmar commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

maybe this?

peterfajdiga commented 1 year ago

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 commented 1 year ago

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 commented 4 months ago

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 commented 4 months ago

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 commented 4 months ago

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