Skip to content

Commit fbc26bd

Browse files
committed
changes in the script and README
1 parent 5bd1afb commit fbc26bd

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

README.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
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.
42

53
## Installation
64

@@ -10,17 +8,16 @@ git clone https://github.com/TWolczanski/linux-autoscroll.git
108
```
119
2. Create a Python virtual environment and activate it:
1210
```
13-
cd linux-autoscroll/
14-
python3 -m venv .venv
15-
source .venv/bin/activate
11+
python3 -m venv .autoscroll
12+
source .autoscroll/bin/activate
1613
```
1714
3. Install pynput:
1815
```
1916
python3 -m pip install pynput
2017
```
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):
2219
```
23-
#!/path/to/linux-autoscroll/.venv/bin/python3
20+
#!/path/to/.autoscroll/bin/python3
2421
```
2522
5. Make the script executable:
2623
```
@@ -32,9 +29,9 @@ chmod u+x autoscroll.py
3229

3330
You can adjust the `DELAY` and `BUTTON` constants for better experience.
3431

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.
3633

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:
3835
```python
3936
from pynput.mouse import Button, Listener
4037

@@ -47,4 +44,9 @@ def on_click(x, y, button, pressed):
4744
with Listener(on_click = on_click) as listener:
4845
listener.join()
4946
```
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.

autoscroll.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ def on_move(x, y):
1212
direction = -1
1313
else:
1414
direction = 0
15-
if abs(delta) < 20:
16-
interval = DELAY / 20
15+
if abs(delta) < DELAY * 2:
16+
interval = 0.5
1717
else:
1818
interval = DELAY / abs(delta)
1919

@@ -41,8 +41,11 @@ def autoscroll():
4141
pos = mouse.position
4242
direction = 0
4343
interval = 0
44-
DELAY = 3
44+
45+
# modify this to adjust the speed of scrolling
46+
DELAY = 5
47+
# modify this to change the button used for entering the scroll mode
4548
BUTTON = Button.middle
4649

4750
listener.start()
48-
autoscroll()
51+
autoscroll()

0 commit comments

Comments
 (0)