Skip to content

Commit

Permalink
ALL: Added saveSetup() and restoreSetup(). Fixed / Improved watchdog …
Browse files Browse the repository at this point in the history
…(especially in Linux). Fixed / improved setPosition() method

LINUX: Added ewmhlib as separate module. Fixed watchdog (freezing randomly invoking screen_resources and get_output_info), fixed workarea crash (some apps/environments do not set it), improved to work almost fine in Manjaro/KDE, avoid crashing in Wayland for "fake" :1 display (though module won't likely work)
WIN32: Fixed dev.StateFlags returning weird values for multi-monitor. Fixed GetAwarenessFromDpiAwarenessContext not supported on Windows Server
MACOS: Replaced display-manager-lib by other alternatives which seem to work in several macOS versions (brightness only) Added setScale() method (using a workaround). Added wakeup feature to turnOn() method
  • Loading branch information
Kalmat committed Apr 16, 2024
1 parent 91c9440 commit c998c49
Show file tree
Hide file tree
Showing 23 changed files with 1,892 additions and 4,636 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/type-checking.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ jobs:
python-version: ["3.11"]
fail-fast: false
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
Expand Down
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
/.idea/
/build/
dist/
/src/PyMonCtl.egg-info/
/tests/multi_monitor_coords.py
/make_wheel.bat
/pip_make.bat
/pip_upload.bat
/pip_upload.bat
*.cpython-310.pyc
/tests/source-shake.lua
/tests/test.py
/tests/test2.py
/tests/test3.py
/tests/test_cec.py
/tests/_display_manager_lib.py
11 changes: 9 additions & 2 deletions AUTHORS.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
PyMonCtl authors, contributors and maintainers:
PyMonCtl authors, contributors and bugs/issues raisers:

Kalmat https://github.com/Kalmat
University of Utah - Marriott Library - Apple Infrastructure https://github.com/univ-of-utah-marriott-library-apple
University of Utah - Marriott Library - Apple Infrastructure https://github.com/univ-of-utah-marriott-library-apple
Danie10 - https://github.com/Danie10
SamuMazzi - https://github.com/SamuMazzi
lappely - https://github.com/poipoiPIO
odknt - https://github.com/odknt

In general, all those who so generously share their work and knowledge on Internet (stackoverflow, github, ...)
so I could find a solution or a string to pull!
4 changes: 4 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
0.8, 2023/10/11 -- ALL: Added saveSetup() and restoreSetup(). Fixed / Improved watchdog (especially in Linux). Fixed / improved setPosition() method
LINUX: Added ewmhlib as separate module. Fixed watchdog (freezing randomly invoking screen_resources and get_output_info), fixed workarea crash (some apps/environments do not set it), improved to work almost fine in Manjaro/KDE, avoid crashing in Wayland for "fake" :1 display (though module won't likely work)
WIN32: Fixed dev.StateFlags returning weird values for multi-monitor. Fixed GetAwarenessFromDpiAwarenessContext not supported on Windows Server
MACOS: Replaced display-manager-lib by other alternatives which seem to work in several macOS versions (brightness only) Added setScale() method (using a workaround). Added wakeup feature to turnOn() method
0.7, 2023/09/20 -- LINUX: Working in Manjaro/KDE. Avoid crashing in Wayland (though module won't likely work on it)
0.6, 2023/09/15 -- ALL: Added *_CENTERED positions. Added coordinates (x, y) as input to setPosition() and arrangeMonitor()
LINUX: Improved performance thru ewmhlib features
Expand Down
35 changes: 25 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ Functions to get monitor instances, get info and arrange monitors plugged to the
| getAllMonitorsDict |
| getMonitorsCount |
| getPrimary |
| findMonitorAtPoint |
| findMonitorAtPointInfo |
| findMonitorsAtPoint |
| findMonitorsAtPointInfo |
| findMonitorWithName |
| findMonitorWithNameInfo |
| saveSetup |
| restoreSetup |
| arrangeMonitors |
| getMousePos |

Expand Down Expand Up @@ -60,7 +62,7 @@ the provided handle is not valid.
| colordepth | X | X | X |
| dpi | X | X | X |
| scale | X | X | X |
| setScale | X | X | |
| setScale | X | X | X |
| orientation | X | X | X |
| setOrientation | X | X | X (1) |
| brightness | X (2) | X | X (1) |
Expand All @@ -74,8 +76,8 @@ the provided handle is not valid.
| allModes | X | X | X |
| setPrimary | X | X | X |
| isPrimary | X | X | X |
| turnOn | X | X | |
| turnOff | X (4) | X | |
| turnOn | X (4) | X | X (4) |
| turnOff | X (4) | X | X (4) |
| isOn | X (2) | X | X |
| suspend | X (4) | X (4) | X (4) |
| isSuspended | X (2) | X | X |
Expand All @@ -90,16 +92,29 @@ the provided handle is not valid.

(3) It doesn't exactly return / change contrast, but gamma values.

(4) Working on Windows with VCP MCCS support, otherwise, it will suspend ALL monitors.
To address a specific monitor, try using turnOff() / turnOn() / detach() / attach() methods.
(4) Windows: Working with VCP MCCS support only.
Linux: It will suspend ALL monitors. To address just one monitor, try using turnOff() / turnOn() / detach() / attach() methods.
macOS: It will suspend ALL monitors. Use turnOn() to wake them up again

#### WARNING: Most of these properties may return ''None'' in case the value can not be obtained

### Important OS-dependent behaviors and limitations:

- On Windows, primary monitor is mandatory, and it is always placed at (0, 0) coordinates. Besides, the monitors can not overlap. To set a monitor as Primary, it is necessary to reposition primary monitor first, so the rest of monitors will sequentially be repositioned to LEFT.
- On Linux, primary monitor can be anywhere, and even there can be no primary monitor. Monitors can overlap, so take this into account when setting a new monitor position. Also bear in mind that xrandr won't accept negative values, so the whole setup will be referenced to (0, 0) coordinates.
- On macOS, primary monitor is mandatory, and it is always placed at (0, 0) coordinates. The monitors can overlap, so take this into account when setting a new monitor position. To set a monitor as Primary, it is necessary to reposition primary monitor first, so the rest of monitors will sequentially be repositioned to LEFT.
- Windows:
- Primary monitor is mandatory, and it is always placed at (0, 0) coordinates.
- Monitors can not overlap.
- To set a monitor as Primary, it is necessary to reposition primary monitor first, so the rest of monitors will sequentially be repositioned to RIGHT_TOP.
- If you attach / detach / plug / unplug a monitor, all IDs may change. The module will try to refresh the IDs for all Monitor class instances, but take into account it may fail!
- Linux:
- Primary monitor can be anywhere, and even there can be no primary monitor.
- Monitors can overlap, so take this into account when setting a new monitor position.
- xrandr won't accept negative values, so the whole setup will be referenced to (0, 0) coordinates.
- xrandr will sort primary monitors first. Because of this and for homegeneity, when positioning a monitor as primary (only with setPosition() method), it will be placed at (0 ,0) and all the rest to RIGHT_TOP.
- macOS:
- Primary monitor is mandatory, and it is always placed at (0, 0) coordinates.
- Monitors can overlap, so take this into account when setting a new monitor position.
- To set a monitor as Primary, it is necessary to reposition primary monitor first, so the rest of monitors will sequentially be repositioned to RIGHT_TOP.
- setScale() method uses a workaround by applying the nearest monitor mode to magnify text to given value

It is highly recommended to use `arrangeMonitors()` function for complex setups or just in case there are two or more monitors.

Expand Down
Binary file removed dist/PyMonCtl-0.7-py3-none-any.whl
Binary file not shown.
11 changes: 6 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@
license='BSD 3',
packages=find_packages(where='src'),
package_dir={'': 'src'},
package_data={"pymonctl": ["py.typed"], "ewmhlib": ["py.typed"]},
package_data={"pymonctl": ["py.typed"]},
test_suite='tests',
install_requires=[
"pywin32>=302; sys_platform == 'win32'",
"python-xlib>=0.21; sys_platform == 'linux'",
"ewmhlib>=0.1; sys_platform == 'linux'",
"pyobjc>=8.1; sys_platform == 'darwin'",
"typing_extensions>=4.4.0"
],
Expand All @@ -45,7 +46,8 @@
"types-setuptools>=65.5",
"mypy>=0.990",
"types-pywin32>=305.0.0.3",
"types-python-xlib>=0.32"
"types-python-xlib>=0.32",
"pywinctl>=0.3"
]
},
keywords="screen display monitor control geometry size position frequency scale orientation "
Expand All @@ -61,9 +63,8 @@
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10'
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11'
],
)
5 changes: 0 additions & 5 deletions src/ewmhlib/Props/__init__.py

This file was deleted.

141 changes: 0 additions & 141 deletions src/ewmhlib/Props/_props.py

This file was deleted.

4 changes: 0 additions & 4 deletions src/ewmhlib/Structs/__init__.py

This file was deleted.

Loading

0 comments on commit c998c49

Please sign in to comment.