Guide For Setting Up Multitouch Touchpad / Trackpad Gestures With fusuma

Multitouch gestures with libinput driver on Linux using fusuma. (GitHub - iberianpig/fusuma: Multitouch gestures with libinput driver on Linux) specifically tested on Garuda KDE Dr460nized & Garuda Sway Editions.

NOTE: For the purpose of this HOWTO I know this setup works on Garuda KDE & Sway Editions. Please see appropriate config.yml for your flavor DE/WM in this post below.

Same Article In Garuda WIki - This Wiki Article WIll Be The Latest & Up-To-Date

Edit: Added Custom fusuma config.yml for Garuda Sway


My Touchpad : Apple Magic Trackpad 2

NOTE: This should work with any trackpad/touchpad. If you use a different touchpad/trackpad/DE/WM please reply here to this post with your particular device with results and feel free to share your ~/.config/fusuma/config.yml to help others along the way.


Sysinfo:

OS: Garuda Linux
Host: Apple Inc. Mac-B809C3757DA9BB8D
Kernel: 5.17.1-zen1-1-zen
DE: Plasma 5.24.4
WM: KWin
WM Theme: Sweet-Dark
Terminal: konsole
CPU: Intel i7-6700K (8) @ 4.2GHz
GPU: AMD ATI Radeon R9 M395/ M395X Mac Edition
Memory: 3.72GiB / 23.38GiB

Let’s Go.

  • 1. Install fusuma and xdotool
paru -S ruby-fusuma xdotool --needed
  • 2. Install the following fusuma plugins
paru -S ruby-fusuma-plugin-tap ruby-fusuma-plugin-keypress ruby-fusuma-plugin-wmctrl

NOTE: Do not install the plugin packages “ruby-fusuma-plugin-sendkey” or “ruby-fusuma-plugin-appmatcher” — If you have them installed, remove them. They can cause errors/conflicts with the following config.yml examples provided in this post.

  • 3. Create the directory ~/.config/fusuma
mkdir ~/.config/fusuma
  • 4. Create a new file ~/.config/fusuma/config.yml using a text editor or touch

  • 5. Edit your newly created config.yml to contain the following:

Use a text editor and place the following content (directly below) into the file and save. This particular config works perfectly in Garuda KDE Dr460nized. If you feel Dra460ny, you can look at all the example configs that have been contributed for your convenience HERE and adjust your config.yml to your hearts desire. IIRC this config.yml works on Gnome & XFCE as well. I will eventually test in Gnome and Xfce to confirm.

[ Original Source Used for config.yml Example ] :
KDE to mimic MacOS

  • Note: I have made edits to the original [ Source ] (below)

Your ~/.config/fusuma/config.yml should contain the following:
Copy/Paste/Save This Section Into config.yml

swipe:
  4:
    right:
      command: 'xdotool key alt+Right' # History forward
    left:
      command: 'xdotool key alt+Left' # History back
    up:
      command: 'xdotool key ctrl+t' # Open new tab
      keypress:
        LEFTSHIFT:
          command: 'xdotool key --clearmodifiers ctrl+shift+t' # Open last closed tab
    down:
      command: 'xdotool key ctrl+w' # Close tab
  3:
    left:
      workspace: 'next' # Switch to next workspace
      keypress:
        LEFTSHIFT: 
          window: 'next' # Move window to next workspace
        LEFTMETA:
          command: 'xdotool key --clearmodifiers super+ctrl+Left' # Move window to left side
    right:
      workspace: 'prev' # Switch to previous workspace
      keypress:
        LEFTSHIFT: 
          window: 'prev' # Move window to previous workspace
        LEFTMETA:
          command: 'xdotool key --clearmodifiers super+ctrl+Right'  # Move window to right side
    up:
      command: 'xdotool key Control_L+F10' # Workspace overview
      keypress:
        LEFTMETA:
          window:
            maximized: 'toggle' # Toggle Maximize/Unmaximize Window
    down:
      command: 'xdotool key Control_L+F12' #minimise all windows
      keypress:
        LEFTMETA:
          window: 'close' # Close window

pinch:
  2:
    in:
      command: 'xdotool keydown ctrl click 4 keyup ctrl' # Zoom in
    out:
      command: 'xdotool keydown ctrl click 5 keyup ctrl' # Zoom out
  4:
    in:
      command: 'xdotool key super+a' # Window overview
    out:
      command: 'xdotool key super+s' # Workspace overview

plugin: 
  inputs:
    libinput_command_input: # options for lib/plugin/inputs/libinput_command_input
      enable-tap: true # click to tap
      enable-dwt: true # disable tap while typing
      show-keycodes: true # https://github.com/iberianpig/fusuma-plugin-keypress#add-show-keycode-option

More Examples Of config.yml

  • 6. Start fusuma in terminal by simply typing the command fusuma
fusuma

I suggest first to start fusuma in a terminal, not-daemonized, for initial testing. Simply type fusuma in your terminal as instructed above in step 6. fusuma should now be running in your terminal.

  • 7. Test

Try some gestures on your trackpad / touchpad…

You can plainly see which gestures are defined in the ~/.config/fusuma/config.yml that you just created.

Try 3-finger-swipe up/down/left/right, for example.

Watch the terminal output from fusuma in the terminal you started fusuma in to see the output from the gesture as you are swiping, etc.

You should now have Multitouch Gestures.

  • 8. Setup fusuma daemonized so it will automatically run when you login

Remember, we are running fusuma in a terminal for testing purposes right now as instructed in this guide. You can ctrl-c out of that to kill it. Now we want to run fusuma in the background each time we login.

8.a: Open KDE Settings/Startup and Shutdown/Autostart
8.b: Click Add / Application
8.c: Type fusuma -d in the popup

fusuma -d

8.d: Click OK
8.e: DONE. Now fusuma will run daemonized each time you login to KDE.


NOTE: I find fusuma to be very reliable as well as cross-desktop.

My short video on Odysee showing ~/.config/fusuma/config.yml and 3-finger swiping in KDE

Another (more complete video) setting up fusuma by another user on Odysee


Enjoy,
-Cannabis

3 Likes

This looks awesome!

Any experience getting this set up on Sway? I know there has been interest in more robust gesture support for Sway: Sway garuda setup gestures to simulate keystrokes

1 Like

Thanks man!

I will do that tonight in Sway. Let me make some coffee and wipe one of my test machines and install garuda sway and test it. :smiley:

Enjoy,
-Cannabis

1 Like

I don't think it likes Sway. :sob:

fusuma
I, [2022-04-01T00:16:40.957327 #34653]  INFO -- : reload config: /home/jeremy/.config/fusuma/config.yml
I, [2022-04-01T00:16:41.032020 #34653]  INFO -- : ---------------------------------------------
I, [2022-04-01T00:16:41.032202 #34653]  INFO -- : Fusuma: 2.3.0
I, [2022-04-01T00:16:41.032704 #34653]  INFO -- : libinput: 1.20.0
I, [2022-04-01T00:16:41.032717 #34653]  INFO -- : ruby 3.0.3p157
I, [2022-04-01T00:16:41.033377 #34653]  INFO -- : OS: Linux 5.17.1-zen1-1-zen #1 ZEN SMP PREEMPT Mon, 28 Mar 2022 21:56:46 +0000
I, [2022-04-01T00:16:41.033699 #34653]  INFO -- : Distribution: Garuda Linux \r (\l)
I, [2022-04-01T00:16:41.035654 #34653]  INFO -- : Desktop session: wayland
I, [2022-04-01T00:16:41.035664 #34653]  INFO -- : ---------------------------------------------
I, [2022-04-01T00:16:41.035671 #34653]  INFO -- : Enabled Plugins:
I, [2022-04-01T00:16:41.035738 #34653]  INFO -- :   Fusuma::Plugin::Buffers::AppmatcherBuffer
I, [2022-04-01T00:16:41.035745 #34653]  INFO -- :   Fusuma::Plugin::Buffers::GestureBuffer
I, [2022-04-01T00:16:41.035750 #34653]  INFO -- :   Fusuma::Plugin::Buffers::KeypressBuffer
I, [2022-04-01T00:16:41.035755 #34653]  INFO -- :   Fusuma::Plugin::Buffers::TapBuffer
I, [2022-04-01T00:16:41.035761 #34653]  INFO -- :   Fusuma::Plugin::Buffers::TimerBuffer
I, [2022-04-01T00:16:41.035766 #34653]  INFO -- :   Fusuma::Plugin::Detectors::AppmatcherDetector
I, [2022-04-01T00:16:41.035771 #34653]  INFO -- :   Fusuma::Plugin::Detectors::HoldDetector
I, [2022-04-01T00:16:41.035776 #34653]  INFO -- :   Fusuma::Plugin::Detectors::KeypressDetector
I, [2022-04-01T00:16:41.035781 #34653]  INFO -- :   Fusuma::Plugin::Detectors::PinchDetector
I, [2022-04-01T00:16:41.035786 #34653]  INFO -- :   Fusuma::Plugin::Detectors::RotateDetector
I, [2022-04-01T00:16:41.035791 #34653]  INFO -- :   Fusuma::Plugin::Detectors::SwipeDetector
I, [2022-04-01T00:16:41.035795 #34653]  INFO -- :   Fusuma::Plugin::Detectors::TapDetector
I, [2022-04-01T00:16:41.035800 #34653]  INFO -- :   Fusuma::Plugin::Events::Records::AppmatcherRecord
I, [2022-04-01T00:16:41.035805 #34653]  INFO -- :   Fusuma::Plugin::Events::Records::ContextRecord
I, [2022-04-01T00:16:41.035810 #34653]  INFO -- :   Fusuma::Plugin::Events::Records::GestureRecord
I, [2022-04-01T00:16:41.035815 #34653]  INFO -- :   Fusuma::Plugin::Events::Records::IndexRecord
I, [2022-04-01T00:16:41.035820 #34653]  INFO -- :   Fusuma::Plugin::Events::Records::KeypressRecord
I, [2022-04-01T00:16:41.035825 #34653]  INFO -- :   Fusuma::Plugin::Events::Records::TextRecord
I, [2022-04-01T00:16:41.035830 #34653]  INFO -- :   Fusuma::Plugin::Executors::CommandExecutor
I, [2022-04-01T00:16:41.035835 #34653]  INFO -- :   Fusuma::Plugin::Executors::WmctrlExecutor
I, [2022-04-01T00:16:41.035840 #34653]  INFO -- :   Fusuma::Plugin::Filters::KeypressFilter
I, [2022-04-01T00:16:41.035845 #34653]  INFO -- :   Fusuma::Plugin::Filters::LibinputDeviceFilter
I, [2022-04-01T00:16:41.035850 #34653]  INFO -- :   Fusuma::Plugin::Inputs::AppmatcherInput
I, [2022-04-01T00:16:41.035855 #34653]  INFO -- :   Fusuma::Plugin::Inputs::LibinputCommandInput
I, [2022-04-01T00:16:41.035860 #34653]  INFO -- :   Fusuma::Plugin::Inputs::TimerInput
I, [2022-04-01T00:16:41.035865 #34653]  INFO -- :   Fusuma::Plugin::Parsers::AppmatcherParser
I, [2022-04-01T00:16:41.035873 #34653]  INFO -- :   Fusuma::Plugin::Parsers::KeypressParser
I, [2022-04-01T00:16:41.035878 #34653]  INFO -- :   Fusuma::Plugin::Parsers::LibinputGestureParser
I, [2022-04-01T00:16:41.035883 #34653]  INFO -- :   Fusuma::Plugin::Parsers::TapParser
I, [2022-04-01T00:16:41.035889 #34653]  INFO -- : ---------------------------------------------
E, [2022-04-01T00:16:41.037080 #34653] ERROR -- : appmatcher doesn't support
XDG_CURRENT_DESKTOP: 'sway'
XDG_SESSION_TYPE: 'wayland'"

Execute

paru -R ruby-fusuma-plugin-appmatcher

restart fusuma

fusuma

Then try again please, sir.

Enjoy,
-Cannabis

Hey, nice one! It does launch now.

It looks like I may have to go back to the drawing board with my fusuma config. I was trying to test it out by taking a few keyboard shortcuts from my sway config and applying gestures to them, but perhaps I had the wrong idea thinking that was a good place to start?

I picked out these bits from my ~/.config/sway/config.d/default:

    # Sway has a "scratchpad", which is a bag of holding for windows.
    # You can send windows there and get them back later.

    # Move the currently focused window to the scratchpad
    bindsym $mod+Shift+minus move scratchpad

    # Show the next scratchpad window or hide the focused scratchpad window.
    # If there are multiple scratchpad windows, this command cycles through them.
    bindsym $mod+minus scratchpad show

    # Start your launcher
    bindsym $mod+d exec $menu

    # Launcher
    bindsym $mod+Shift+d exec $launcher

    # Activities
    bindsym $mod+p exec ~/.config/wofi/windows.py

    # Move focused window with arrow keys
    bindsym $mod+Shift+Left move left
    bindsym $mod+Shift+Down move down
    bindsym $mod+Shift+Up move up
    bindsym $mod+Shift+Right move right

And I loaded them in to ~/.config/fusuma/config.yml like so:

swipe:
  4:
    left:
      command: 'xdotool key --clearmodifiers super+shift+-' # Send to scratchpad
    right:
      command: 'xdotool key super+-' # Reveal scratchpad
    up:
      command: 'xdotool key super+d' # wofi launcher
      keypress:
        LEFTSHIFT:
          command: 'xdotool key --clearmodifiers super+Shift+d' # full launcher
    down:
      command: 'xdotool key super+p' # Activities
  3:
    left:
      command: 'xdotool key --clearmodifiers super+shift+Left' # Move focused window left
    right:
      command: 'xdotool key --clearmodifiers super+shift+Right' # Move focused window right
    up:
      command: 'xdotool key --clearmodifiers super+shift+Up' # Move focused window up
    down:
      command: 'xdotool key --clearmodifiers super+shift+Down' # Move focused window down

I do see that I cannot use "-" as a value (perhaps it is "Minus"?) but the other items are not working for some other reason.

Here's the output if I three-finger swipe right:

I, [2022-04-01T02:01:53.087898 #40668]  INFO -- : {:command=>"xdotool key --clearmodifiers super+shift+Left", :args=>{:move_x=>-3.22, :move_y=>-0.59, :unaccelerated_x=>-3.22, :unaccelerated_y=>-0.59, :zoom=>0.0, :rotate=>0.0}}

I can't tell if that looks right or not, but it does not achieve the desired effect (move active window to the left).

What do you think? Am I way off?

I’ll look closer at your last posted ~/.config/fusuma/config.yml
I think you should give this a try → wayland-specific example ubuntu-style - download it here
Drop that wayland-ubuntu config example as-is in your config.yml and reload and test if you wish. Luck! Keep an eye on fusuma output in terminal while testing swipes / pinches / etc

1 Like

~/.config/fusuma/config.yml for Multitouch Trackpad Gestures in Garuda Sway using fusuma

  • @BluishHumility --->>> Below is a custom tested and working fusuma config.yml
    for Garuda Sway.

  • Please test on your sway box at your leisure.
    Tested in Garuda Sway on bare metal ( Inxi Here )
    Success, All touchpad gestures working as expected.

  • Check back with your results please sir. TIA @BluishHumility Done & Thanks!

NOTE:

Do not install the plugin packages "ruby-fusuma-plugin-sendkey" or
"ruby-fusuma-plugin-appmatcher". If installed, remove them.

  • ~/.config/fusuma/config.yml
# Custom ~/.config/fusuma/config.yml for Garuda Sway Edition
#
# config.yml for fusuma --- https://github.com/iberianpig/fusuma
#
# This should work in any linux distro running sway and using fusuma.
#
# Author: Donald Tanner (Cannabis on Garuda Forum)
# Email:  
#
# Note, this is not a file included in Garuda Official.
# This is user contributed to help others along the way.
#
# swipe section
swipe:
  3:
    left:
      command: exec sway move left # Move Window Left
    right:
      command: exec sway move right #  Move Window Right
    up:
      command: exec sway move up # Move Window Up
    down:
      command: exec sway move down # Move Window Down
  4:
    left:
     command: exec sway workspace next # Next Workspace
    right:
      command: exec sway workspace prev # Previous Workspace
    up:
      command: exec sway fullscreen toggle # Fullscreen Toggle
    down:
      command: exec sway floating toggle # Tiling Floating Toggle
# pinch section
pinch:
  2:
    in:
      command: 'xdotool keydown ctrl click 4 keyup ctrl' # Zoom In - Test in a browser
    out:
      command: 'xdotool keydown ctrl click 5 keyup ctrl' # Zoom Out - Test in a browser
  4:
    in:
      command: 'xdotool key super+a' # Window Overview - Mod+a not defined in sway
                                     # Redefine to something useful
    out:
      command: 'xdotool key super+s' # Workspace Overview - Mod+s not defined in sway
                                     # Redefine to something useful
threshold:
  swipe: 0.4
  pinch: 0.4

interval:
  swipe: 0.8
  pinch: 0.1
  • Restart fusuma and Test
1 Like

Amazing! It works great, I really appreciate you taking the time to put this together. :blush:

That's brilliant putting in the exec sway commands for the shortcuts--I don't know why I didn't think of that! I had tried to call the sway commands through the keyboard shortcuts defined in the sway config with xdotool key--very clunky, and did not work! :laughing:

This is much more elegant. And it works! :smile:

1 Like
  • :ninja: Great! No worries. Glad it is working for you.

  • :ninja: Question: Do you have Mod+a and/or Mod+s keyboard shortcuts defined in Sway?

If Yes, then 4-finger-pinch-in-out should activate with this config.yml.
If No, we can define anything you would like for those gestures.

Let me know if there are actions/gestures you would like to define for 3-or-4-pinch-in-out.
Right now I have Mod+a ( defined as super-a by xdotool ) and Mod+s ( defined as super-s by xdotool ) defined for 4-finger-pinch-in-out. 3-finger-pinch-in-out can be added.

We have spares, Captain.

1 Like

I was thinking resizing windows would be a great function for a pinch gesture, although maybe a little tricky. There is a window resize shortcut bound to the scroll wheel like so:

# Resize floating windows with mouse scroll:
bindsym --whole-window --border $mod+button4 resize shrink height 5 px or 5 ppt
bindsym --whole-window --border $mod+button5 resize grow height 5 px or 5 ppt
bindsym --whole-window --border $mod+shift+button4 resize shrink width 5 px or 5 ppt
bindsym --whole-window --border $mod+shift+button5 resize grow width 5 px or 5 ppt

Scrolling up and down is intuitive enough (shrink or grow), but there are separate functions for height and width. So to translate to pinch gestures, either one could be a three pinch and one could be a four pinch, or they could be the same pinch but one would have a keypress added (shift or something).

One thing I did change in the config was exec sway focus left → exec sway move left, and so on with right, up, down. My thinking was window focus changes automatically in Sway when you move the mouse cursor from one window to another–you don’t even need to click or anything–so if you have your hand on the touchpad already, no need to have a shortcut to change focus. The “move” function comes in handy though–you can toss a window to a different side of the screen or whatever–so I swapped that one in.

Another handy Sway function that would be neat to have in gesture form is the scratchpad. You can get a window right off the screen–it’s nice if it is getting a little crowded–and then you can call back the scratchpad whenever you like.

# Scratchpad:
#
    # Sway has a "scratchpad", which is a bag of holding for windows.
    # You can send windows there and get them back later.

    # Move the currently focused window to the scratchpad
    bindsym $mod+Shift+minus move scratchpad

    # Show the next scratchpad window or hide the focused scratchpad window.
    # If there are multiple scratchpad windows, this command cycles through them.
    bindsym $mod+minus scratchpad show

Following your example, I would assume the relevant commands to assign would be move scratchpad and scratchpad show. I was thinking they could be a 4-swipe up or down with a keypress–what do you think?

I was kind of wondering…the pinch zoom is working, but which command is helping it work?

# pinch section
pinch:
  in:
    command: 'xdotool key ctrl+plus'
  out:
     command: 'xdotool key ctrl+minus'
  2:
    in:
      command: 'xdotool keydown ctrl click 4 keyup ctrl' # Zoom In - Test in a browser
    out:
      command: 'xdotool keydown ctrl click 5 keyup ctrl' # Zoom Out - Test in a browser

As far as I can tell, those are both zoom shortcuts. Are there some situations where one or the other does not work?

I actually don’t–which is pretty remarkable! I feel like a good chunk of the keyboard real estate is spoken for, so the fact that you managed to pick two keys I haven’t tied up in a shortcut yet is really something. Remember that old board game “Battleship”? :joy:

1 Like

Remove these 4 lines [ directly under pinch: ] please. Not needed plus possibly conflicting, even. Good catch.

  in:
    command: 'xdotool key ctrl+plus'
  out:
     command: 'xdotool key ctrl+minus'
  • I’ve also edited the original example config.yml [ in the OP ] and removed same 4 lines.

A little Sway scratchpad talk and some Mod/Super ideas

:bulb: 4-finger-pinch / super+a / super+s idea…

Ok. Good to know.

4-finger-pinch-in/out already points to super+a and super+s. Since those are Free/Unused bindings in sway default, you could define the key bindings in sway.

The point is that you can now define super+a/super+s in sway keyboard shortcut/bindings and then 4-finger-pinch-in/out will automatically activate your two new shortcuts. =)

This is already defined in fusuma. ^^^

:bulb: Sway Scratchpad…

Quick note here. I am not happy with the way fusuma (or any gesture backend) and sway are working on the scratchpad commands.

For instance, the nature of pinching means that with some commands the gesture will execute the command repeatedly during the pinch.

Sway scratchpad hide|show commands are of this type that executes repeatedly during the gesture.

The reason is because these commands cycle through items in your scratchpad. One of the pinch for scratchpad creates a NEW scratchpad This results in multiple windows/scratchpads flipping by and you have no control to stop/release at the exact millisecond.

Havoc ensues quickly. Mayhem, I say.

I am still experimenting to achieve this:

  • Define in the fusuma config.yml so that a command that should only execute once during the pinch/gesture.

Have a good one!

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.