Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm looking for a way to be able to scroll half a page, preferably by using a key combination like shift page up/down. In Windows, this is doable via autohotkey, for OS there does not seem to be any as easy solution as all I found was this.

I just switch to using Ubuntu 14.04 (from win7). From googling around it seems to me that the easiest way to achieve this is by creating a couple of xdotool/xbindkeys scripts, which emulate half a page worth of mouse scrolling or arrow clicking up and down, respectively. Then I would bind these to custom hotkeys.

However, since I just switched to Ubuntu, I realize that I might be missing something. Therefore I wonder, which is your preferred way to enable half page scrolling in Linux?

Update: I created a script, which emulates scrolling the mousewheel a few times:

#!/bin/bash
xdotool click 4
xdotool click 4
xdotool click 4
xdotool click 4

It works decently, but two problems remain:

  1. It always scrolls the window where the mouse is. I have tried to make it scroll the active window but no luck.

  2. Since it sends mouse wheel scrolls, these are interpreted by other programs such that I cannot have control as a hotkey, because then it zooms. This is a problem in programs where all hotkeys are taken so ideally, I would like to specify the scrolling distance without emulating mouse wheel scrolling.

share|improve this question

I finally came up with a solution that works very well for most of my use-cases. Using xdotools, I created two scripts, one for scrolling in each direction. This is the script for scrolling down (to scroll up, substitute '5' for '4').

#!/bin/bash

#Get active window id
win=`xdotool getactivewindow`

#Move the mouse to the active window
xdotool mousemove --window $win 45 110 

#Scroll active window several times
xdotool click --clearmodifiers 5
xdotool click --clearmodifiers 5
xdotool click --clearmodifiers 5
xdotool click --clearmodifiers 5
xdotool click --clearmodifiers 5
xdotool click --clearmodifiers 5
xdotool click --clearmodifiers 5
xdotool click --clearmodifiers 5
xdotool click --clearmodifiers 5
xdotool click --clearmodifiers 5
xdotool click --clearmodifiers 5

#Send click to specific window. Finicky.
#xdotool click --window $win 5

Basically, xdotools get the activewindow id and then moves the moves there before sending the mouse scroll signal several times. I could not get it to work by directly specifying which window to send the clicks to, so I solved it by moving the mouse cursor instead. Since Linux automatically scrolls the window under the mouse, this solves problem 1 listed in my question. The --clearmodifiers parameter releases whatever modifier key used in the hotkey combination so that the only key that is sent is the one from xdotool, this solves problem number 2 for me.

The only minor annoyance left is that in some windows, there are multiple panels and with this script I can only scroll the top leftmost panel. This is not a problem when browsing but for IDEs such as spyder. So if someone has a better approach, please share!

share|improve this answer
    
Thanks for this. I'll ping you up if I find a better approach but so far I am taking this – Rojo Jun 20 '14 at 4:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .