4

By that I mean is there a command I could type into the terminal then click on a window behind, and It is scrolled up / down, and then turn this into a custom shortcut?

xdotool key Next or xdotool key Page_Down is not what I want, I'm looking for one that is metaphorically 'deeper' in the way Linux / general OSs works.

I know how to use xdotool, but I don't want to use it. I want to know the command that is executed when that button is pressed, XDO words as an emulator essentially.

Braiam
  • 67,791
  • 32
  • 179
  • 269
Tim
  • 32,861
  • 27
  • 118
  • 178
  • I do not understand what do you mean by deeper. When you press, say, PgDown in a window application, the OS send to that window a KeyPress/KeyRelease event. The application is listening to events directed to its window(s), and will execute some internal code when "sees" the PgDown event. So the only way to go deeper is to manipulate the application source code, probably. If you explains more in detail why xdotool does not work for you, maybe someone can help. (for example, some application is programmed, for security, to refuse synthetic keypresses. Is that the problem?) – Rmano May 30 '14 at 17:36
  • No, I want to have a command that scrolls by a set amount, but asking that didn't get me anywhere, on a different site, e.g. 5 pixels. – Tim May 30 '14 at 17:37
  • It will probably depend on the application (or in the best of cases on the graphical toolkit used). Most applications do fine scrolling on "mouse wheel" (buttons 4 & 5) events, so maybe sending them could be a way to experiment. Still, you'll be better if you give more specific info in the question. – Rmano May 30 '14 at 17:42
  • @Rmano I have tried sending them 4 and 5, and they scrolled, but it wasn't as fine as I need, I think it was by about 3 lines (11px). – Tim May 30 '14 at 17:43
  • Yep -- app dependent, definitely; probably the graphic toolkit has a default, which most app would not change, but that's not guaranteed. – Rmano May 30 '14 at 17:48

2 Answers2

5

I'm looking for one that is metaphorically 'deeper' in the way Linux / general OSs works

Metaphor be damned, this is how it actually works:

  • You mash the keyboard
  • An evdev driver/keymap/etc converts that into an X11 event
  • The display server sends the event to the application (and optionally bubbles that up the stack)
  • The application (or its framework) determines what to do with the input

There is no "paging" metaphor built into X; it's just a behaviour common to many applications and their frameworks.

So in terms of emulating an event that looks like somebody hit the Page Down key, your best bet is actually generating that X11 event and sending it to the window.

Your only other option is to add an alternative interface for your running application that it intercepts and internally makes the change to the window. That's very possible but it's also a metric buttload of work.

Oli
  • 293,335
  • +1, couldn't express that better (I tried in the comments but this answer is much better) – Rmano May 30 '14 at 18:20
2

The sleep command is a good way to add a delay (so in my example its 60s) then double ampersand to run an additional command when the sleep has finished.

sleep 60 && xdotool key Page_Up
sleep 60 && xdotool key Page_Down

XDO is for simulating keypresses in X11, not sure how deeper you can go from a terminal without writing your own app to manipulate X11 apis directly.

NGRhodes
  • 9,490