Skip to content

Commit 102b1f1

Browse files
fixed autodoc
1 parent 8140da3 commit 102b1f1

File tree

9 files changed

+252
-146
lines changed

9 files changed

+252
-146
lines changed

README.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Display Server Interactions
22

3+
[![PyPI version](https://badge.fury.io/py/display-server-interactions.svg)](https://pypi.org/project/display-server-interactions/)
4+
[![Documentation Status](https://readthedocs.org/projects/display-server-interactions/badge/?version=latest)](https://display-server-interactions.readthedocs.io/en/latest)
5+
[![Downloads](https://pepy.tech/badge/display-server-interactions)](https://pepy.tech/project/display-server-interactions)
6+
[![Supported Python Versions](https://img.shields.io/pypi/pyversions/display-server-interactions)](https://pypi.org/project/display-server-interactions/)
7+
8+
[![License](https://img.shields.io/github/license/Commandcracker/display-server-interactions)](https://github.com/Commandcracker/display-server-interactions/blob/main/LICENSE.txt)
9+
[![GitHub stars](https://img.shields.io/github/stars/Commandcracker/display-server-interactions)](https://github.com/Commandcracker/display-server-interactions/stargazers)
10+
[![GitHub forks](https://img.shields.io/github/forks/Commandcracker/display-server-interactions)](https://github.com/Commandcracker/display-server-interactions/network)
11+
[![GitHub issues](https://img.shields.io/github/issues/Commandcracker/display-server-interactions)](https://github.com/Commandcracker/display-server-interactions/issues)
12+
313
DSI allows you to perform basic interactions on your display server, like screenshotting a window or sending input to it.
414
Currently, DSI only supports X11/Xorg (GNU/Linux) but it aims to be cross-platform.
515

@@ -44,14 +54,14 @@ while True:
4454
window.send_str("Hello World")
4555
```
4656

47-
### Sending mouse clicks
57+
### Move the mouse pointer
4858

4959
```python
50-
window.send_mouse_click(100, 100)
60+
window.warp_pointer(x=42, y=73)
5161
```
5262

53-
### Move the mouse pointer
63+
### Sending mouse clicks
5464

5565
```python
56-
window.warp_pointer(x=100, y=100)
66+
window.send_mouse_click(x=42, y=73)
5767
```

display_server_interactions/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
from platform import system as __system
55

66
__version__ = "0.0.dev2"
7+
__author__ = "Commandcracker"
78

89
__os_name = __system().lower()
910

1011
if __os_name == "linux":
11-
#from .linux import DSI
12-
pass
12+
from .linux import DSI
1313

1414
elif __os_name == "windows":
1515
raise NotImplementedError("Windows is not yet implemented.")

display_server_interactions/base.py

Lines changed: 39 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,75 +3,79 @@
33

44
from abc import ABCMeta, abstractmethod
55
from .window import WindowBase
6-
#from . import __os_name
6+
from platform import system
77

88

99
class DSIBase(object, metaclass=ABCMeta):
10-
@staticmethod
1110
@abstractmethod
12-
def get_active_window() -> WindowBase:
11+
def get_active_window(self) -> WindowBase:
1312
"""
1413
Gets the active window.
1514
Returns None if no window is active.
1615
"""
1716
pass
1817

19-
@staticmethod
2018
@abstractmethod
21-
def get_all_windows() -> list:
19+
def get_all_windows(self) -> list:
2220
"""
2321
Returns a list of all Windows.
2422
"""
2523
pass
2624

27-
@classmethod
28-
def get_window_by_pid(cls, pid: int) -> WindowBase:
25+
def get_window_by_pid(self, pid: int) -> WindowBase:
2926
"""
3027
Get window by pid.
3128
Returns None if no window found.
3229
"""
33-
all_window = cls.get_all_windows()
30+
all_window = self.get_all_windows()
3431

3532
for window in all_window:
3633
if window.pid == pid:
3734
return window
3835

39-
@classmethod
40-
def get_window_by_name(cls, name: str) -> WindowBase:
36+
def get_window_by_name(self, name: str) -> WindowBase:
4137
"""
4238
Get a window by name.
4339
Returns None if no window with that name is found.
4440
"""
45-
all_window = cls.get_all_windows()
41+
all_window = self.get_all_windows()
4642

4743
for window in all_window:
4844
if window.name is not None and name in window.name:
4945
return window
5046

51-
# @property
52-
# def platform(self) -> str:
53-
# """
54-
# Returns the platform name.
55-
# """
56-
# return __os_name
47+
@property
48+
def platform(self) -> str:
49+
"""
50+
Returns the platform name.
51+
"""
52+
return system().lower()
53+
54+
@property
55+
def linux(self) -> bool:
56+
"""
57+
Returns True if the platform is linux.
58+
"""
59+
return self.platform == "linux"
60+
61+
@property
62+
def windows(self) -> bool:
63+
"""
64+
Returns True if the platform is windows.
65+
"""
66+
return self.platform == "windows"
67+
68+
@property
69+
def mac(self) -> bool:
70+
"""
71+
Returns True if the platform is mac.
72+
"""
73+
return self.platform == "darwin"
5774

58-
# @property
59-
# def linux(self) -> bool:
60-
# """
61-
# Returns True if the platform is linux.
62-
# """
63-
# return self.platform == "linux"
75+
# Allow dsi to be called with ’with’
6476

65-
# @property
66-
# def windows(self) -> bool:
67-
# """
68-
# Returns True if the platform is windows.
69-
# """
70-
# return self.platform == "windows"
77+
def __enter__(self):
78+
return self
7179

72-
# @property
73-
# def mac(self) -> bool:
74-
# """
75-
# Returns True if the platform is mac.
76-
# """
77-
# return self.platform == "darwin"
80+
def __exit__(self, *_):
81+
pass

0 commit comments

Comments
 (0)