jbensmann/mouseless

I need vim functionality to save the position

Closed this issue · 2 comments

I03D commented

I want to have a mode for remembering the cursor position (preferably three: horizontal, vertical and both) and a mode for restoring the position. Like the standard " m " and " ' " in vim. Your application turned out to be convenient for everyday use, but it took a relatively long time to aim the cursor at small panels or timeline videos.

I have 4*4 keys to teleport the cursor, as in keynav/keynavish/warpd, but this is too universal a solution. I would like to record positions on the fly without a hardcode.

Thanks, mouseless works stably and it is much better than keynav/keynavish/warpd/xmouseless. What an irony, I tried mouseless the last of such programs.

Great to hear that mouseless works for you.

I agree that would be a nice feature. The problem is that mouseless currently only simulates a real mouse and does not know where the cursor is, and how to get the cursor position depends on which display manager is in use (Xorg or Wayland), so this might be some more work, but I will have a look how it could be done.

Until then, one could do this by executing external scripts with the exec binding that store and read the cursor position from files, here is an example how to do it in Xorg with saving both x and y positions (it requires that xdotool is installed, which is a nice tool for interacting with windows, keyboards and the mouse):

  • create a script for saving marks, e.g. in ~/.config/mouseless/save-mark.sh:
#!/usr/bin/env sh
BASEDIR=$(dirname "$0")
mkdir "$BASEDIR/marks"
xdotool getmouselocation | sed 's/x:\([0-9]*\)\s*y:\([0-9]*\).*/\1 \2/' > "$BASEDIR/marks/$1"
  • create a script for reading marks, e.g. ~/.config/mouseless/goto-mark.sh:
#!/usr/bin/env sh
BASEDIR=$(dirname "$0")
cat "$BASEDIR/marks/$1" | xargs xdotool mousemove
  • make them both executable with
chmod +x ~/.config/mouseless/save-mark.sh ~/.config/mouseless/goto-mark.sh
  • add the following to the mouseless config
- name: mouse
  bindings:
    ...
    m: toggle-layer save-mark
    apostrophe: toggle-layer goto-mark
- name: save-mark
  passThrough: false
  bindings:
    a: 'exec /home/jbensmann/.config/mouseless/save-mark.sh a'
    b: 'exec /home/jbensmann/.config/mouseless/save-mark.sh b'
    c: 'exec /home/jbensmann/.config/mouseless/save-mark.sh c'
- name: goto-mark
  passThrough: false
  bindings:
    a: 'exec /home/jbensmann/.config/mouseless/goto-mark.sh a'
    b: 'exec /home/jbensmann/.config/mouseless/goto-mark.sh b'
    c: 'exec /home/jbensmann/.config/mouseless/goto-mark.sh c'

Here you have to change /home/jbensmann with the name of your home directory, and one has to define a binding for every key one wants to save a mark to.
When in the mouse layer, one can then e.g. save a mark on a by pressing and holding m, pressing and releasing a, and releasing m, and similarly go to a mark with '.

Not a very clean solution, but the best I could come up with.

I03D commented

Thanks, it works!