JoseExposito / touchegg

Linux multi-touch gesture recognizer
GNU General Public License v3.0
3.68k stars 171 forks source link

Conditional Gestures #442

Closed lucas-salas closed 3 years ago

lucas-salas commented 3 years ago

It would be nice if there was some basic functionality that allowed us to dictate what a gesture does based on a given condition.

My reason for wanting this is to continue my quest to make my gestures identical to windows. On windows if you swipe up with three fingers it presents all the open windows. You can then swipe down to return to your original view. Once you're at your normal view the behavior of the three finger down swipe changes to present desktop. Essentially the function of swiping down with three fingers depends on what state your screen is in (i.e desktop or window switcher.)

JoseExposito commented 3 years ago

Hi Lucas,

I'm afraid it is not possible for me to know the current status of your desktop to apply one action or the other.

Implementing it is possible, but it'll require a lower level integration, like the one I made on elementary OS: https://blog.elementary.io/multitouch-gestures-in-elementary-os-6/

If you are using elementary, then this will be available. Otherwise, your desktop environment will have to implement this.

NICHOLAS85 commented 3 years ago

I'm not 100% familiar with toucheggs config but if you have the ability to run a command/script when a gesture is detected you could write yourself a script that does what you want. Here is one I use with a different gesture daemon:

#!/bin/bash
# presentview

DOWNID="${TMPDIR:-/tmp}/downid"
CURRENTLYUP(){
    EFFECTS=("$(qdbus org.kde.KWin /Effects activeEffects)")
    [[ "${EFFECTS[*]}" =~ "presentwindows" ]] && true || false
}
invoke(){ qdbus org.kde.kglobalaccel /component/kwin invokeShortcut "$1"; }

case $1 in
  --up )
    if [[ -e $DOWNID ]]; then
      xdotool windowactivate "$(xdotool search --pid "$(cat $DOWNID)" | tail -1)" && rm -f $DOWNID || invoke "Expose"
    elif ! CURRENTLYUP; then
      invoke "Expose"
    fi
  ;;
  --down )
    if CURRENTLYUP; then
      xdotool click 3
    else
      xdotool getwindowpid $(xdotool getwindowfocus) > $DOWNID
      invoke "Window Minimize"
      { sleep 0.6; rm -f $DOWNID; } &
    fi
  ;;
esac

On presentview --down if I'm currently in present view it'll close it, otherwise minimize the current active application, remembering its pid for 0.6 seconds. On presentview --up it'll activate the last minimized application(only within 0.6 seconds), otherwise invoke present view.

elvisisvan commented 1 year ago

i'm trying to make my linux gestures acts like on windows too and i think it's the "opposite command" option you are looking for image