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

Set default values for config_params #309

Merged
merged 3 commits into from
Aug 30, 2023

Conversation

iberianpig
Copy link
Owner

@iberianpig iberianpig commented Aug 29, 2023

Motivation

Sometimes you want to set the default value of config_params for each plugin.
This is because you want to set the configuration values of other plugins from different plugins.

For example, the configuration values in my LibinputCommandInput are as follows,
but I believe the following options should be set automatically without setting anything by user.

plugin:
  inputs:
    libinput_command_input:
      show-keycodes: true # fusuma-plugin-keypress requires this option
      verbose: true       # fusuma-plugin-thumbsense requires this option

fusuma-plugin-keypress and fusuma-plugin-thumbsense require these options.

Solution

These should be set automatically by plugins, and should only be written if the user wants to change them.

Make it possible to include yml files for each plugin.
This PR includes a yml file for libinput_command_input.
Also, add the --show-config option to dump and check the config values.

example: fusuma --show-config

---
plugin:
  inputs:
    remap_keyboard_input:
      keyboard_name_patterns: xremap
hold:
  '4':
    sendkey: LEFTCTRL+SPACE
    threshold: 0.5
swipe:
  '3':
    right:
      update:
        keypress:
          LEFTALT:
            interval: 1
            sendkey: VOLUMEUP
            clearmodifiers: true
    left:
      update:
        keypress:
          LEFTALT:
            interval: 1
            sendkey: VOLUMEDOWN
    up:
      update:
        keypress:
          LEFTALT:
            interval: 1
            command: gdbus call --session --dest org.gnome.SettingsDaemon.Power --object-path
              /org/gnome/SettingsDaemon/Power --method org.gnome.SettingsDaemon.Power.Screen.StepUp
    down:
      update:
        keypress:
          LEFTALT:
            interval: 1
            command: gdbus call --session --dest org.gnome.SettingsDaemon.Power --object-path
              /org/gnome/SettingsDaemon/Power --method org.gnome.SettingsDaemon.Power.Screen.StepDown
  '4':
    up:
      sendkey: LEFTMETA+S
      keypress:
        LEFTSHIFT:
          sendkey: LEFTMETA+DOWN
          clearmodifiers: true
        LEFTMETA:
          sendkey: LEFTMETA+LEFTSHIFT+UP
          clearmodifiers: true
    down:
      sendkey: LEFTMETA+W
      keypress:
        LEFTSHIFT:
          sendkey: LEFTMETA+UP
          clearmodifiers: true
        LEFTMETA:
          sendkey: LEFTMETA+LEFTSHIFT+DOWN
          clearmodifiers: true
    left:
      sendkey: LEFTMETA+D
      keypress:
        LEFTSHIFT:
          sendkey: LEFTMETA+RIGHT
          clearmodifiers: true
    right:
      sendkey: LEFTMETA+A
      keypress:
        LEFTSHIFT:
          sendkey: LEFTMETA+LEFT
          clearmodifiers: true
pinch:
  '2':
    begin:
      command: xdotool keydown ctrl
    end:
      command: xdotool keyup ctrl
    in:
      update:
        command: xdotool click 5
        keypress:
          LEFTALT:
            sendkey: VOLUMEUP
    out:
      update:
        command: xdotool click 4
        keypress:
          LEFTALT:
            sendkey: VOLUMEDOWN
rotate:
  '3':
    clockwise:
      update:
        sendkey: VOLUMEUP
        keypress:
          LEFTALT:
            command: gdbus call --session --dest org.gnome.SettingsDaemon.Power --object-path
              /org/gnome/SettingsDaemon/Power --method org.gnome.SettingsDaemon.Power.Screen.StepUp
    counterclockwise:
      update:
        sendkey: VOLUMEDOWN
        keypress:
          LEFTALT:
            command: gdbus call --session --dest org.gnome.SettingsDaemon.Power --object-path
              /org/gnome/SettingsDaemon/Power --method org.gnome.SettingsDaemon.Power.Screen.StepDown
---
context:
  application: Google-chrome
swipe:
  '3':
    left:
      sendkey: LEFTALT+RIGHT
    right:
      sendkey: LEFTALT+LEFT
    up:
      sendkey: LEFTCTRL+T
    down:
      sendkey: LEFTCTRL+W
---
context:
  application: Microsoft-edge-dev
swipe:
  '3':
    left:
      sendkey: LEFTALT+RIGHT
    right:
      sendkey: LEFTALT+LEFT
    up:
      sendkey: LEFTCTRL+T
    down:
      sendkey: LEFTCTRL+W
---
context:
  application: Slack
swipe:
  '3':
    up:
      sendkey: LEFTALT+DOWN
    down:
      sendkey: LEFTALT+UP
---
context:
  application: Alacritty
swipe:
  '3':
    begin:
      keypress:
        LEFTCTRL:
          command: xdotool mousedown 1
          interval: 0.0
    update:
      keypress:
        LEFTCTRL:
          command: xdotool mousemove_relative -- $move_x, $move_y
          interval: 0.0
          accel: 3
    end:
      keypress:
        LEFTCTRL:
          interval: 0.0
          command: xdotool mouseup 1
remap:
  LEFTMETA: A
---
context:
  thumbsense: true
remap:
  J: BTN_LEFT
  K: BTN_RIGHT
  F: BTN_LEFT
  D: BTN_RIGHT
  SPACE: BTN_LEFT
  I: INSERT
  LEFTALT:
    sendkey: ALT+LEFT
---
context: :plugin_defaults
plugin:
  inputs:
    libinput_command_input:
      show-keycodes: true
      verbose: true
  buffers:
    keypress_buffer:
      source: remap_keyboard_input
  filters:
    keypress_filter:
      keep_device_names:
  executors:
    wmctrl_executor:
      wrap-navigation: false
      matrix-col-size:

- Add --show-config option to show config as YAML format which is loaded internally
  - This option is useful to debug config loading
- plugin can define default value in `plugin/inputs/*.yml`
- plugin_defaults context is added to internal config automatically
@iberianpig iberianpig marked this pull request as ready for review August 29, 2023 23:44
@iberianpig iberianpig merged commit f59a0bb into master Aug 30, 2023
4 checks passed
@iberianpig iberianpig deleted the feature/fetch-config-from-plugin-defaults branch August 30, 2023 00:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant