You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For some Linux users, especially those coming from Windows, scrolling through long PDFs or webpages is a real nightmare. On Windows you just click the middle mouse button to start scrolling and move your mouse to adjust the direction and speed.
2
-
3
-
This is exactly what this simple Python script does. It gives you a Windows-like autoscroll feature on Linux. It works system-wide on every distribution with Xorg.
1
+
This simple Python script gives you a Windows-like autoscroll feature on Linux. It works system-wide on every distribution with Xorg.
2. Create a Python virtual environment and activate it:
12
10
```
13
-
cd linux-autoscroll/
14
-
python3 -m venv .venv
15
-
source .venv/bin/activate
11
+
python3 -m venv .autoscroll
12
+
source .autoscroll/bin/activate
16
13
```
17
14
3. Install pynput:
18
15
```
19
16
python3 -m pip install pynput
20
17
```
21
-
4. Add the following shebang to the script (substitute `/path/to/linux-autoscroll` with the actual path to your virtual environment):
18
+
4. Add the following shebang to the script (substitute `/path/to` with the actual path to your virtual environment):
22
19
```
23
-
#!/path/to/linux-autoscroll/.venv/bin/python3
20
+
#!/path/to/.autoscroll/bin/python3
24
21
```
25
22
5. Make the script executable:
26
23
```
@@ -32,9 +29,9 @@ chmod u+x autoscroll.py
32
29
33
30
You can adjust the `DELAY` and `BUTTON` constants for better experience.
34
31
35
-
By changing `DELAY` you can adjust the speed of scrolling. By default its value is 3 but you may find it either too fast or too slow. You can decrease the value to make scrolling faster or increase it to make scrolling slower.
32
+
By changing `DELAY` you can adjust the speed of scrolling. By default its value is 5 but you may find it either too fast or too slow. You can decrease the value to make scrolling faster or increase it to make scrolling slower.
36
33
37
-
Modifying `BUTTON` is going to change the button used for entering the scroll mode. The default is the middle mouse button but if your mouse has additional side buttons it might be a good idea to use one of them instead, as the middle button is often used for different purposes (for example to open a link in a new tab in most web browsers or to copy and paste text system-wide). As the script is using the pynput library, you can hopefully find the name of the side button with the following piece of code:
34
+
Modifying `BUTTON` is going to change the button used for entering the scroll mode. The default is the middle mouse button but if your mouse has additional side buttons it might be a good idea to use one of them instead, as the middle button is often used for different purposes (for example to open a link in a new tab in most web browsers or to copy and paste text system-wide). As the script is using the pynput library, you can hopefully find names of all of your mouse buttons with the following piece of code:
38
35
```python
39
36
from pynput.mouse import Button, Listener
40
37
@@ -47,4 +44,9 @@ def on_click(x, y, button, pressed):
47
44
with Listener(on_click= on_click) as listener:
48
45
listener.join()
49
46
```
50
-
Then just replace `BUTTON = Button.middle` with `BUTTON = Button.name` where `name` is the name of the side button.
47
+
48
+
## Usage
49
+
50
+
Click the middle mouse button (or the button you have assigned to `BUTTON`) and move your mouse to start scrolling. The further you move the mouse (vertically) from the point where you clicked the button, the faster the scrolling becomes. To leave the scroll mode, simply press the button again.
51
+
52
+
Note that at slow speed the scrolling is not smooth and (probably) there is no way to make it smooth. However, one can easily get used to it.
0 commit comments