screenman 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- screenman-0.1.0/.github/workflows/release.yaml +125 -0
- screenman-0.1.0/.gitignore +106 -0
- screenman-0.1.0/LICENSE +22 -0
- screenman-0.1.0/PKG-INFO +85 -0
- screenman-0.1.0/README.md +57 -0
- screenman-0.1.0/examples/example_screenman.toml +48 -0
- screenman-0.1.0/pyproject.toml +39 -0
- screenman-0.1.0/screenman/__init__.py +10 -0
- screenman-0.1.0/screenman/cli.py +52 -0
- screenman-0.1.0/screenman/config.py +65 -0
- screenman-0.1.0/screenman/edid.py +98 -0
- screenman-0.1.0/screenman/screen.py +398 -0
- screenman-0.1.0/screenman/utils.py +41 -0
- screenman-0.1.0/screenman.egg-info/PKG-INFO +85 -0
- screenman-0.1.0/screenman.egg-info/SOURCES.txt +21 -0
- screenman-0.1.0/screenman.egg-info/dependency_links.txt +1 -0
- screenman-0.1.0/screenman.egg-info/entry_points.txt +2 -0
- screenman-0.1.0/screenman.egg-info/requires.txt +6 -0
- screenman-0.1.0/screenman.egg-info/top_level.txt +1 -0
- screenman-0.1.0/setup.cfg +4 -0
- screenman-0.1.0/tests/__init__.py +1 -0
- screenman-0.1.0/tests/test_screenman.py +18 -0
- screenman-0.1.0/uv.lock +139 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# taken from
|
|
2
|
+
# https://github.com/ArjanCodes/examples/blob/943a877dcea7471a80ab4804018e3a51ca015b9c/2024/publish_pypi/with_trusted_publisher/release_pypi.yaml
|
|
3
|
+
name: release
|
|
4
|
+
|
|
5
|
+
on:
|
|
6
|
+
push:
|
|
7
|
+
tags:
|
|
8
|
+
- "*-release"
|
|
9
|
+
- "*-beta"
|
|
10
|
+
- "[0-9]+.[0-9]+.[0-9]+"
|
|
11
|
+
- "[0-9]+.[0-9]+.[0-9]+a[0-9]+"
|
|
12
|
+
- "[0-9]+.[0-9]+.[0-9]+b[0-9]+"
|
|
13
|
+
- "[0-9]+.[0-9]+.[0-9]+rc[0-9]+"
|
|
14
|
+
|
|
15
|
+
jobs:
|
|
16
|
+
details:
|
|
17
|
+
runs-on: ubuntu-latest
|
|
18
|
+
outputs:
|
|
19
|
+
package_name: ${{ steps.package_information.outputs.package_name }}
|
|
20
|
+
new_version: ${{ steps.release.outputs.new_version }}
|
|
21
|
+
suffix: ${{ steps.release.outputs.suffix }}
|
|
22
|
+
tag_name: ${{ steps.release.outputs.tag_name }}
|
|
23
|
+
steps:
|
|
24
|
+
- uses: actions/checkout@v2
|
|
25
|
+
- name: Extract tag and Details
|
|
26
|
+
id: release
|
|
27
|
+
run: |
|
|
28
|
+
if [ "${{ github.ref_type }}" = "tag" ]; then
|
|
29
|
+
TAG_NAME=${GITHUB_REF#refs/tags/}
|
|
30
|
+
NEW_VERSION=$(echo $TAG_NAME | awk -F'-' '{print $1}')
|
|
31
|
+
SUFFIX=$(echo $TAG_NAME | awk -F'-' '{print $2}')
|
|
32
|
+
echo "new_version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
|
|
33
|
+
echo "suffix=$SUFFIX" >> "$GITHUB_OUTPUT"
|
|
34
|
+
echo "tag_name=$TAG_NAME" >> "$GITHUB_OUTPUT"
|
|
35
|
+
echo "Version is $NEW_VERSION"
|
|
36
|
+
echo "Suffix is $SUFFIX"
|
|
37
|
+
echo "Tag name is $TAG_NAME"
|
|
38
|
+
else
|
|
39
|
+
echo "No tag found"
|
|
40
|
+
exit 1
|
|
41
|
+
fi
|
|
42
|
+
|
|
43
|
+
- name: "Set up Python"
|
|
44
|
+
uses: actions/setup-python@v5
|
|
45
|
+
with:
|
|
46
|
+
python-version-file: "pyproject.toml"
|
|
47
|
+
|
|
48
|
+
- name: Get Name of Package
|
|
49
|
+
id: package_information
|
|
50
|
+
run: |
|
|
51
|
+
PACKAGE_NAME=$(awk -F' = ' '/^name/ {gsub(/"/, "", $2); print $2}' pyproject.toml)
|
|
52
|
+
echo "Package name: $PACKAGE_NAME"
|
|
53
|
+
echo "package_name=$PACKAGE_NAME" >> "$GITHUB_OUTPUT"
|
|
54
|
+
|
|
55
|
+
check_pypi:
|
|
56
|
+
needs: details
|
|
57
|
+
runs-on: ubuntu-latest
|
|
58
|
+
steps:
|
|
59
|
+
- name: Fetch information from PyPI
|
|
60
|
+
run: |
|
|
61
|
+
PACKAGE_NAME=${{ needs.details.outputs.package_name}}
|
|
62
|
+
response=$(curl -s https://pypi.org/pypi/$PACKAGE_NAME/json || echo "{}")
|
|
63
|
+
latest_previous_version=$(echo $response | grep -oP '"releases":\{"\K[^"]+' | sort -rV | head -n 1)
|
|
64
|
+
if [ -z "$latest_previous_version" ]; then
|
|
65
|
+
echo "Package not found on PyPI."
|
|
66
|
+
latest_previous_version="0.0.0"
|
|
67
|
+
fi
|
|
68
|
+
echo "Latest version on PyPI: $latest_previous_version"
|
|
69
|
+
echo "latest_previous_version=$latest_previous_version" >> $GITHUB_ENV
|
|
70
|
+
|
|
71
|
+
- name: Compare versions and exit if not newer
|
|
72
|
+
run: |
|
|
73
|
+
NEW_VERSION=${{ needs.details.outputs.new_version }}
|
|
74
|
+
LATEST_VERSION=$latest_previous_version
|
|
75
|
+
if [ "$(printf '%s\n' "$LATEST_VERSION" "$NEW_VERSION" | sort -rV | head -n 1)" != "$NEW_VERSION" ] || [ "$NEW_VERSION" == "$LATEST_VERSION" ]; then
|
|
76
|
+
echo "The new version $NEW_VERSION is not greater than the latest version $LATEST_VERSION on PyPI."
|
|
77
|
+
exit 1
|
|
78
|
+
else
|
|
79
|
+
echo "The new version $NEW_VERSION is greater than the latest version $LATEST_VERSION on PyPI."
|
|
80
|
+
fi
|
|
81
|
+
|
|
82
|
+
setup_and_build:
|
|
83
|
+
needs: details
|
|
84
|
+
runs-on: ubuntu-latest
|
|
85
|
+
steps:
|
|
86
|
+
- uses: actions/checkout@v2
|
|
87
|
+
|
|
88
|
+
- name: Install uv
|
|
89
|
+
uses: astral-sh/setup-uv@v3
|
|
90
|
+
|
|
91
|
+
- name: "Set up Python"
|
|
92
|
+
uses: actions/setup-python@v5
|
|
93
|
+
with:
|
|
94
|
+
python-version-file: "pyproject.toml"
|
|
95
|
+
|
|
96
|
+
- name: Build source and wheel distribution
|
|
97
|
+
run: |
|
|
98
|
+
uv build
|
|
99
|
+
|
|
100
|
+
- name: Upload artifacts
|
|
101
|
+
uses: actions/upload-artifact@v3
|
|
102
|
+
with:
|
|
103
|
+
name: dist
|
|
104
|
+
path: dist/
|
|
105
|
+
|
|
106
|
+
pypi_publish:
|
|
107
|
+
name: Upload release to PyPI
|
|
108
|
+
needs: [setup_and_build, details]
|
|
109
|
+
runs-on: ubuntu-latest
|
|
110
|
+
environment:
|
|
111
|
+
name: release
|
|
112
|
+
permissions:
|
|
113
|
+
# In order to use Trusted Publisher
|
|
114
|
+
id-token: write
|
|
115
|
+
contents: read
|
|
116
|
+
|
|
117
|
+
steps:
|
|
118
|
+
- name: Download artifacts
|
|
119
|
+
uses: actions/download-artifact@v3
|
|
120
|
+
with:
|
|
121
|
+
name: dist
|
|
122
|
+
path: dist/
|
|
123
|
+
|
|
124
|
+
- name: Publish distribution to PyPI
|
|
125
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
env/
|
|
12
|
+
build/
|
|
13
|
+
develop-eggs/
|
|
14
|
+
dist/
|
|
15
|
+
downloads/
|
|
16
|
+
eggs/
|
|
17
|
+
.eggs/
|
|
18
|
+
lib/
|
|
19
|
+
lib64/
|
|
20
|
+
parts/
|
|
21
|
+
sdist/
|
|
22
|
+
var/
|
|
23
|
+
wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
|
|
28
|
+
# PyInstaller
|
|
29
|
+
# Usually these files are written by a python script from a template
|
|
30
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
31
|
+
*.manifest
|
|
32
|
+
*.spec
|
|
33
|
+
|
|
34
|
+
# Installer logs
|
|
35
|
+
pip-log.txt
|
|
36
|
+
pip-delete-this-directory.txt
|
|
37
|
+
|
|
38
|
+
# Unit test / coverage reports
|
|
39
|
+
htmlcov/
|
|
40
|
+
.tox/
|
|
41
|
+
.coverage
|
|
42
|
+
.coverage.*
|
|
43
|
+
.cache
|
|
44
|
+
nosetests.xml
|
|
45
|
+
coverage.xml
|
|
46
|
+
*.cover
|
|
47
|
+
.hypothesis/
|
|
48
|
+
.pytest_cache/
|
|
49
|
+
|
|
50
|
+
# Translations
|
|
51
|
+
*.mo
|
|
52
|
+
*.pot
|
|
53
|
+
|
|
54
|
+
# Django stuff:
|
|
55
|
+
*.log
|
|
56
|
+
local_settings.py
|
|
57
|
+
|
|
58
|
+
# Flask stuff:
|
|
59
|
+
instance/
|
|
60
|
+
.webassets-cache
|
|
61
|
+
|
|
62
|
+
# Scrapy stuff:
|
|
63
|
+
.scrapy
|
|
64
|
+
|
|
65
|
+
# Sphinx documentation
|
|
66
|
+
docs/_build/
|
|
67
|
+
|
|
68
|
+
# PyBuilder
|
|
69
|
+
target/
|
|
70
|
+
|
|
71
|
+
# Jupyter Notebook
|
|
72
|
+
.ipynb_checkpoints
|
|
73
|
+
|
|
74
|
+
# pyenv
|
|
75
|
+
.python-version
|
|
76
|
+
|
|
77
|
+
# celery beat schedule file
|
|
78
|
+
celerybeat-schedule
|
|
79
|
+
|
|
80
|
+
# SageMath parsed files
|
|
81
|
+
*.sage.py
|
|
82
|
+
|
|
83
|
+
# dotenv
|
|
84
|
+
.env
|
|
85
|
+
|
|
86
|
+
# virtualenv
|
|
87
|
+
.venv
|
|
88
|
+
venv/
|
|
89
|
+
ENV/
|
|
90
|
+
|
|
91
|
+
# Spyder project settings
|
|
92
|
+
.spyderproject
|
|
93
|
+
.spyproject
|
|
94
|
+
|
|
95
|
+
# Rope project settings
|
|
96
|
+
.ropeproject
|
|
97
|
+
|
|
98
|
+
# mkdocs documentation
|
|
99
|
+
/site
|
|
100
|
+
|
|
101
|
+
# mypy
|
|
102
|
+
.mypy_cache/
|
|
103
|
+
|
|
104
|
+
# IDE settings
|
|
105
|
+
.vscode/
|
|
106
|
+
.idea/
|
screenman-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024, Hendrik Klug
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
screenman-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: screenman
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A Python tool to manage and configure multi-monitor setups using EDID information, allowing users to apply predefined screen layouts with ease.
|
|
5
|
+
Author-email: Hendrik Klug <hendrik.klug@gmail.com>
|
|
6
|
+
License: MIT license
|
|
7
|
+
Project-URL: Homepage, https://github.com/Jimmy2027/screenman
|
|
8
|
+
Keywords: screenman
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Natural Language :: English
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.6
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Requires-Python: >=3.9
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Requires-Dist: Click>=7.0
|
|
24
|
+
Requires-Dist: loguru>=0.7.2
|
|
25
|
+
Requires-Dist: platformdirs>=4.3.6
|
|
26
|
+
Provides-Extra: test
|
|
27
|
+
Requires-Dist: pytest>=3; extra == "test"
|
|
28
|
+
|
|
29
|
+
# screenman
|
|
30
|
+
|
|
31
|
+
A Python tool to manage and configure multi-monitor setups using EDID information, allowing users to apply predefined screen layouts with ease.
|
|
32
|
+
|
|
33
|
+
## Usage
|
|
34
|
+
|
|
35
|
+
```terminal
|
|
36
|
+
$ screenman --help
|
|
37
|
+
Usage: screenman [OPTIONS]
|
|
38
|
+
|
|
39
|
+
Console script for screenman.
|
|
40
|
+
|
|
41
|
+
Options:
|
|
42
|
+
--log-level TEXT Set the logging level (e.g., DEBUG, INFO, WARNING, ERROR,
|
|
43
|
+
CRITICAL)
|
|
44
|
+
--log-file TEXT Set the log file path.
|
|
45
|
+
--print-info Print the connected screens and the corresponding
|
|
46
|
+
layout.If no layout is defined, the default layout 'auto'
|
|
47
|
+
is used.
|
|
48
|
+
--help Show this message and exit.
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
When wanting to setup a new screen layout, you can use the `--print-info` flag to get the connected screens information. This information can be used to create a new screen layout.
|
|
53
|
+
|
|
54
|
+
```terminal
|
|
55
|
+
$ screenman --print-info
|
|
56
|
+
<HDMI-2, UID: DL51145435704, primary: True, modes: 13, conn: True, rot: normal, enabled: True, res: (1920, 1080)>
|
|
57
|
+
Layout: auto
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
From that we can create our toml configuration file with the following content:
|
|
61
|
+
|
|
62
|
+
```toml
|
|
63
|
+
# the hierarchy of the configuration file is as follows:
|
|
64
|
+
# layouts.<layout_name>.<screen_uid>
|
|
65
|
+
[layouts.single_baetylus.DL51145435704]
|
|
66
|
+
primary = true
|
|
67
|
+
mode = [1920, 1080]
|
|
68
|
+
position = [0, 0]
|
|
69
|
+
rotation = "normal"
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
A more advanced screenman.toml configuration file can be found in the [examples](examples) directory.
|
|
73
|
+
|
|
74
|
+
## Installation
|
|
75
|
+
|
|
76
|
+
### portage
|
|
77
|
+
|
|
78
|
+
`screenman` is available via [Jimmy's overlay](https://github.com/Jimmy2027/overlay/blob/main/dev-python/screenman/screenman-9999.ebuild).
|
|
79
|
+
Either enable the repo or copy the ebuild to your local overlay.
|
|
80
|
+
|
|
81
|
+
Then run:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
emerge -av screenman
|
|
85
|
+
```
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# screenman
|
|
2
|
+
|
|
3
|
+
A Python tool to manage and configure multi-monitor setups using EDID information, allowing users to apply predefined screen layouts with ease.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```terminal
|
|
8
|
+
$ screenman --help
|
|
9
|
+
Usage: screenman [OPTIONS]
|
|
10
|
+
|
|
11
|
+
Console script for screenman.
|
|
12
|
+
|
|
13
|
+
Options:
|
|
14
|
+
--log-level TEXT Set the logging level (e.g., DEBUG, INFO, WARNING, ERROR,
|
|
15
|
+
CRITICAL)
|
|
16
|
+
--log-file TEXT Set the log file path.
|
|
17
|
+
--print-info Print the connected screens and the corresponding
|
|
18
|
+
layout.If no layout is defined, the default layout 'auto'
|
|
19
|
+
is used.
|
|
20
|
+
--help Show this message and exit.
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
When wanting to setup a new screen layout, you can use the `--print-info` flag to get the connected screens information. This information can be used to create a new screen layout.
|
|
25
|
+
|
|
26
|
+
```terminal
|
|
27
|
+
$ screenman --print-info
|
|
28
|
+
<HDMI-2, UID: DL51145435704, primary: True, modes: 13, conn: True, rot: normal, enabled: True, res: (1920, 1080)>
|
|
29
|
+
Layout: auto
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
From that we can create our toml configuration file with the following content:
|
|
33
|
+
|
|
34
|
+
```toml
|
|
35
|
+
# the hierarchy of the configuration file is as follows:
|
|
36
|
+
# layouts.<layout_name>.<screen_uid>
|
|
37
|
+
[layouts.single_baetylus.DL51145435704]
|
|
38
|
+
primary = true
|
|
39
|
+
mode = [1920, 1080]
|
|
40
|
+
position = [0, 0]
|
|
41
|
+
rotation = "normal"
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
A more advanced screenman.toml configuration file can be found in the [examples](examples) directory.
|
|
45
|
+
|
|
46
|
+
## Installation
|
|
47
|
+
|
|
48
|
+
### portage
|
|
49
|
+
|
|
50
|
+
`screenman` is available via [Jimmy's overlay](https://github.com/Jimmy2027/overlay/blob/main/dev-python/screenman/screenman-9999.ebuild).
|
|
51
|
+
Either enable the repo or copy the ebuild to your local overlay.
|
|
52
|
+
|
|
53
|
+
Then run:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
emerge -av screenman
|
|
57
|
+
```
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
[fallback_uid]
|
|
2
|
+
frametux = { Manufacturer = "BOE", Model = "3018" }
|
|
3
|
+
|
|
4
|
+
[layouts.office.008NTLE9T528]
|
|
5
|
+
# horizontal screen
|
|
6
|
+
primary = true
|
|
7
|
+
mode = [2560, 1440]
|
|
8
|
+
position = [0, 0]
|
|
9
|
+
rotation = "left"
|
|
10
|
+
|
|
11
|
+
[layouts.office.H4ZRA04684]
|
|
12
|
+
# vertical screen
|
|
13
|
+
primary = false
|
|
14
|
+
mode = [3440, 1440]
|
|
15
|
+
position = [1440, 0]
|
|
16
|
+
rotation = "normal"
|
|
17
|
+
|
|
18
|
+
[layouts.office.frametux]
|
|
19
|
+
enabled = false
|
|
20
|
+
primary = false
|
|
21
|
+
mode = [2256, 1504]
|
|
22
|
+
position = [0, 0]
|
|
23
|
+
rotation = "normal"
|
|
24
|
+
|
|
25
|
+
[layouts.single_frametux.frametux]
|
|
26
|
+
primary = true
|
|
27
|
+
mode = [2256, 1504]
|
|
28
|
+
position = [0, 0]
|
|
29
|
+
rotation = "normal"
|
|
30
|
+
|
|
31
|
+
[layouts.single_baetylus.DL51145435704]
|
|
32
|
+
primary = true
|
|
33
|
+
mode = [1920, 1080]
|
|
34
|
+
position = [0, 0]
|
|
35
|
+
rotation = "normal"
|
|
36
|
+
|
|
37
|
+
[layouts.home.frametux]
|
|
38
|
+
enabled = true
|
|
39
|
+
primary = true
|
|
40
|
+
mode = [2256, 1504]
|
|
41
|
+
position = [0, 0]
|
|
42
|
+
rotation = "normal"
|
|
43
|
+
|
|
44
|
+
[layouts.home.DL51145435704]
|
|
45
|
+
primary = false
|
|
46
|
+
mode = [1920, 1080]
|
|
47
|
+
position = [2256, 0]
|
|
48
|
+
rotation = "normal"
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
build-backend = "setuptools.build_meta"
|
|
3
|
+
requires = [
|
|
4
|
+
"setuptools>=61",
|
|
5
|
+
"setuptools-scm[toml]>=6.2.3",
|
|
6
|
+
]
|
|
7
|
+
|
|
8
|
+
[project]
|
|
9
|
+
name = "screenman"
|
|
10
|
+
version = "0.1.0"
|
|
11
|
+
description = "A Python tool to manage and configure multi-monitor setups using EDID information, allowing users to apply predefined screen layouts with ease."
|
|
12
|
+
readme = "README.md"
|
|
13
|
+
license = { text = "MIT license" }
|
|
14
|
+
authors = [{ name = "Hendrik Klug", email = "hendrik.klug@gmail.com" }]
|
|
15
|
+
keywords = ["screenman"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"License :: OSI Approved :: MIT License",
|
|
18
|
+
"Natural Language :: English",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Programming Language :: Python :: 3.6",
|
|
21
|
+
"Programming Language :: Python :: 3.7",
|
|
22
|
+
"Programming Language :: Python :: 3.8",
|
|
23
|
+
"Programming Language :: Python :: 3.9",
|
|
24
|
+
"Programming Language :: Python :: 3.10",
|
|
25
|
+
"Programming Language :: Python :: 3.11",
|
|
26
|
+
"Programming Language :: Python :: 3.12",
|
|
27
|
+
"Programming Language :: Python :: 3.13",
|
|
28
|
+
]
|
|
29
|
+
dependencies = ["Click>=7.0", "loguru>=0.7.2", "platformdirs>=4.3.6"]
|
|
30
|
+
requires-python = ">=3.9"
|
|
31
|
+
|
|
32
|
+
[project.urls]
|
|
33
|
+
Homepage = "https://github.com/Jimmy2027/screenman"
|
|
34
|
+
|
|
35
|
+
[project.scripts]
|
|
36
|
+
screenman = "screenman.cli:main"
|
|
37
|
+
|
|
38
|
+
[project.optional-dependencies]
|
|
39
|
+
test = ["pytest>=3"]
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"""Console script for screenman."""
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
|
|
5
|
+
import click
|
|
6
|
+
from loguru import logger
|
|
7
|
+
|
|
8
|
+
from screenman.screen import apply_layout, connected_screens, determine_layout
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def configure_logger(log_level="INFO", log_file=None):
|
|
12
|
+
logger.remove() # Remove default logger
|
|
13
|
+
logger.add(sys.stderr, level=log_level) # Add stderr logging with chosen level
|
|
14
|
+
|
|
15
|
+
if log_file:
|
|
16
|
+
logger.add(log_file, rotation="1 MB", retention="10 days", level=log_level)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@click.command()
|
|
20
|
+
@click.option(
|
|
21
|
+
"--log-level",
|
|
22
|
+
default="INFO",
|
|
23
|
+
help="Set the logging level (e.g., DEBUG, INFO, WARNING, ERROR, CRITICAL)",
|
|
24
|
+
)
|
|
25
|
+
@click.option("--log-file", default=None, help="Set the log file path.")
|
|
26
|
+
@click.option(
|
|
27
|
+
"--print-info",
|
|
28
|
+
is_flag=True,
|
|
29
|
+
help="Print the connected screens and the corresponding layout."
|
|
30
|
+
"If no layout is defined, the default layout 'auto' is used.",
|
|
31
|
+
)
|
|
32
|
+
def main(log_level, log_file, print_info):
|
|
33
|
+
"""Console script for screenman."""
|
|
34
|
+
configure_logger(log_level, log_file)
|
|
35
|
+
|
|
36
|
+
screens = connected_screens()
|
|
37
|
+
layout_name = determine_layout(screens)
|
|
38
|
+
if print_info:
|
|
39
|
+
for s in screens:
|
|
40
|
+
print(s)
|
|
41
|
+
print(f"Layout: {layout_name}")
|
|
42
|
+
return
|
|
43
|
+
|
|
44
|
+
if layout_name:
|
|
45
|
+
logger.info(f"Applying layout: {layout_name}")
|
|
46
|
+
apply_layout(screens, layout_name)
|
|
47
|
+
else:
|
|
48
|
+
logger.info("No matching layout found.")
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
if __name__ == "__main__":
|
|
52
|
+
sys.exit(main()) # pragma: no cover
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
from screenman.utils import ScreenSettings
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
from platformdirs import site_config_dir, user_config_dir
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
import tomllib
|
|
8
|
+
from dataclasses import dataclass, field
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
from typing import Dict
|
|
11
|
+
|
|
12
|
+
from screenman.utils import str_to_rot
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@dataclass
|
|
16
|
+
class Config:
|
|
17
|
+
# for some reason, some monitors don't include the serial number in the EDID
|
|
18
|
+
# for those, define some fallback option to which the edid is matched.
|
|
19
|
+
# This will not be a unique identifier, so it will not work if you have multiple monitors of the same model
|
|
20
|
+
fallback_uid: Dict[str, Dict[str, str]] = field(default_factory=dict)
|
|
21
|
+
layouts: Dict[str, Dict[str, ScreenSettings]] = field(default_factory=dict)
|
|
22
|
+
|
|
23
|
+
@classmethod
|
|
24
|
+
def load_from_toml(cls) -> "Config":
|
|
25
|
+
config_paths = [
|
|
26
|
+
Path.cwd(),
|
|
27
|
+
Path.home(),
|
|
28
|
+
Path(user_config_dir(roaming=True)),
|
|
29
|
+
Path(user_config_dir("synthara_sdk", roaming=False)),
|
|
30
|
+
Path(site_config_dir()),
|
|
31
|
+
]
|
|
32
|
+
for path in config_paths:
|
|
33
|
+
path = path / "screenman.toml"
|
|
34
|
+
if path and path.exists():
|
|
35
|
+
try:
|
|
36
|
+
with open(path, "rb") as f:
|
|
37
|
+
config_data = tomllib.load(f)
|
|
38
|
+
fallback_uid = config_data.get("fallback_uid", {})
|
|
39
|
+
layouts = {
|
|
40
|
+
layout_name: {
|
|
41
|
+
screen_name: ScreenSettings(
|
|
42
|
+
resolution=tuple(screen_data.get("mode", (0, 0))),
|
|
43
|
+
is_primary=screen_data.get("primary", False),
|
|
44
|
+
is_enabled=screen_data.get("enabled", True),
|
|
45
|
+
rotation=str_to_rot(
|
|
46
|
+
screen_data.get("rotation", "normal")
|
|
47
|
+
),
|
|
48
|
+
position=(
|
|
49
|
+
"--pos",
|
|
50
|
+
f"{screen_data['position'][0]}x{screen_data['position'][1]}",
|
|
51
|
+
)
|
|
52
|
+
if "position" in screen_data
|
|
53
|
+
else None,
|
|
54
|
+
)
|
|
55
|
+
for screen_name, screen_data in layout_screens.items()
|
|
56
|
+
}
|
|
57
|
+
for layout_name, layout_screens in config_data.get(
|
|
58
|
+
"layouts", {}
|
|
59
|
+
).items()
|
|
60
|
+
}
|
|
61
|
+
return cls(fallback_uid=fallback_uid, layouts=layouts)
|
|
62
|
+
except Exception as e:
|
|
63
|
+
print(f"Failed to load configuration file '{path}': {e}")
|
|
64
|
+
# Default configuration if no config file is found
|
|
65
|
+
return cls()
|