Skip to content

Commit

Permalink
ALL: Reorganized to avoid IDEs showing external and / or private elem…
Browse files Browse the repository at this point in the history
…ents

findMonitor() returns a list of Monitor instances
MACOS: Added contrast(), setContrast(), isOn() and isAttached(), improved setMode()
  • Loading branch information
Kalmat committed Aug 28, 2023
1 parent c565ba8 commit 677cef8
Show file tree
Hide file tree
Showing 15 changed files with 1,143 additions and 1,100 deletions.
5 changes: 3 additions & 2 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
0.0.12, 2023/08/24 -- ALL: findMonitor() returns a list of Monitor instances
MACOS: Added contrast(), setContrast(), isOn() and isAttached(), improved setMode()
0.1, 2023/08/25 -- ALL: Reorganized to avoid IDEs showing external and / or private elements
findMonitor() returns a list of Monitor instances
MACOS: Added contrast(), setContrast(), isOn() and isAttached(), improved setMode()
0.0.11, 2023/08/23 -- MACOS: Added display_manager_lib (thanks to University of Utah - Marriott Library - Apple Infrastructure)
WIN32: Fixed setScale()
0.0.10, 2023/08/21 -- ALL: Fixed watchdog thread
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

Cross-Platform module which provides a set of features to get info on and control monitors.

#### My most sincere thanks and appreciation to the University of Utah Student Computing Labs for their awesome work on the display_manager_lib module, for sharing it so generously, and most especially for allowing to be integrated into PyMonCtl

External tools/extensions/APIs used:
- Linux:
- Xlib's randr extension
Expand All @@ -16,6 +14,9 @@ External tools/extensions/APIs used:
- macOS:
- pmset command-line tool


My most sincere thanks and appreciation to the University of Utah Student Computing Labs for their awesome work on the display_manager_lib module, for sharing it so generously, and most especially for allowing to be integrated into PyMonCtl

## General Functions

Functions to get monitor instances, get info and manage monitors plugged to the system.
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
license='BSD 3',
packages=find_packages(where='src'),
package_dir={'': 'src'},
package_data={"pymonctl": ["py.typed"]},
package_data={"pymonctl": ["py.typed"], "ewmhlib": ["py.typed"]},
test_suite='tests',
install_requires=[
"pywin32>=302; sys_platform == 'win32'",
Expand Down
2 changes: 0 additions & 2 deletions src/ewmhlib/Props.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,5 +135,3 @@ class StackMode(IntEnum):
class HintAction(IntEnum):
KEEP = -1
REMOVE = -2


53 changes: 51 additions & 2 deletions src/ewmhlib/Structs.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,28 @@


class ScreensInfo(TypedDict):
"""
Container class to handle ScreensInfo struct:
- screen_number (str): int (sequential)
- is_default (bool): ''True'' if the screen is the default screen
- screen (Xlib.Struct): screen Struct (see Xlib documentation)
- root (Xlib.xobject.drawable.Window): root X-Window object belonging to screen
"""
screen_number: str
is_default: bool
screen: Struct
root: XWindow


class DisplaysInfo(TypedDict):
"""
Container class to handle DisplaysInfo struct:
- name: Display name (as per Xlib.display.Display(name))
- is_default: ''True'' if the display is the default display
- screens: list of ScreensInfo structs belonging to display
"""
name: str
is_default: bool
screens: List[ScreensInfo]
Expand All @@ -25,7 +40,22 @@ class DisplaysInfo(TypedDict):
Perhaps unnecesary since structs below are defined in Xlib.xobject.icccm.*, though in a more complex way.
"""
class WmHints(TypedDict):
# {'flags': 103, 'input': 1, 'initial_state': 1, 'icon_pixmap': <Pixmap 0x02a22304>, 'icon_window': <Window 0x00000000>, 'icon_x': 0, 'icon_y': 0, 'icon_mask': <Pixmap 0x02a2230b>, 'window_group': <Window 0x02a00001>}
"""
Container class to handle WmHints struct:
Example:
{
'flags': 103,
'input': 1,
'initial_state': 1,
'icon_pixmap': <Pixmap 0x02a22304>,
'icon_window': <Window 0x00000000>,
'icon_x': 0,
'icon_y': 0,
'icon_mask': <Pixmap 0x02a2230b>,
'window_group': <Window 0x02a00001>
}
"""
flags: int
input_mode: int
initial_state: int
Expand All @@ -38,12 +68,31 @@ class WmHints(TypedDict):


class Aspect(TypedDict):
"""Container class to handle Aspect struct (num, denum)"""
num: int
denum: int


class WmNormalHints(TypedDict):
# {'flags': 848, 'min_width': 387, 'min_height': 145, 'max_width': 0, 'max_height': 0, 'width_inc': 9, 'height_inc': 18, 'min_aspect': <class 'Xlib.protocol.rq.DictWrapper'>({'num': 0, 'denum': 0}), 'max_aspect': <class 'Xlib.protocol.rq.DictWrapper'>({'num': 0, 'denum': 0}), 'base_width': 66, 'base_height': 101, 'win_gravity': 1}
"""
Container class to handle WmNormalHints
Example:
{
'flags': 848,
'min_width': 387,
'min_height': 145,
'max_width': 0,
'max_height': 0,
'width_inc': 9,
'height_inc': 18,
'min_aspect': <class 'Xlib.protocol.rq.DictWrapper'>({'num': 0, 'denum': 0}),
'max_aspect': <class 'Xlib.protocol.rq.DictWrapper'>({'num': 0, 'denum': 0}),
'base_width': 66,
'base_height': 101,
'win_gravity': 1
}
"""
flags: int
min_width: int
min_height: int
Expand Down
21 changes: 9 additions & 12 deletions src/ewmhlib/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
from __future__ import annotations

import sys
assert sys.platform == "linux"

from ._ewmhlib import (displaysCount, getDisplaysNames, getDisplaysInfo, getDisplayFromRoot, getDisplayFromWindow,
getProperty, getPropertyValue, changeProperty, sendMessage, _xlibGetAllWindows,
defaultDisplay, defaultScreen, defaultRoot, RootWindow, defaultRootWindow, EwmhWindow
)
import ewmhlib.Props as Props
import ewmhlib.Structs as Structs
#!/usr/bin/python
# -*- coding: utf-8 -*-

__all__ = [
"version", "displaysCount", "getDisplaysNames", "getDisplaysInfo", "getDisplayFromRoot", "getDisplayFromWindow",
Expand All @@ -17,10 +8,16 @@
"Props", "Structs"
]


__version__ = "0.0.1"


def version(numberOnly: bool = True):
"""Returns the current version of ewmhlib module, in the form ''x.x.xx'' as string"""
return ("" if numberOnly else "EWMHlib-")+__version__


from ._main import (displaysCount, getDisplaysNames, getDisplaysInfo, getDisplayFromRoot, getDisplayFromWindow,
getProperty, getPropertyValue, changeProperty, sendMessage,
defaultDisplay, defaultScreen, defaultRoot, RootWindow, defaultRootWindow, EwmhWindow,
Props, Structs
)
9 changes: 9 additions & 0 deletions src/ewmhlib/_main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-

from ._ewmhlib import (displaysCount, getDisplaysNames, getDisplaysInfo, getDisplayFromRoot, getDisplayFromWindow,
getProperty, getPropertyValue, changeProperty, sendMessage,
defaultDisplay, defaultScreen, defaultRoot, RootWindow, defaultRootWindow, EwmhWindow
)
import ewmhlib.Props as Props
import ewmhlib.Structs as Structs
Loading

0 comments on commit 677cef8

Please sign in to comment.