0
# Output Management
1
2
Complete output (monitor/display) querying functionality for i3/sway. Provides detailed information about connected displays, their configuration, capabilities, and current state.
3
4
## Capabilities
5
6
### Output Querying
7
8
```python { .api }
9
def get_outputs(self) -> List[OutputReply]:
10
"""
11
Get information about all outputs/monitors.
12
13
Returns:
14
List[OutputReply]: comprehensive output details for all connected displays
15
"""
16
```
17
18
### Output Reply Structure
19
20
```python { .api }
21
class OutputReply:
22
"""Complete output information from GET_OUTPUTS response."""
23
24
# Basic identification
25
name: str # Output name (e.g., "HDMI-A-1", "eDP-1")
26
active: bool # Whether output is currently active and usable
27
primary: bool # Whether output is designated as primary display
28
29
# Workspace assignment
30
current_workspace: str # Name of workspace currently displayed on this output
31
32
# Geometry and positioning
33
rect: Rect # Output rectangle (position and dimensions)
34
35
# Sway-specific properties (None in i3)
36
make: str # Monitor manufacturer
37
model: str # Monitor model name
38
serial: str # Monitor serial number
39
scale: float # Display scaling factor
40
transform: str # Display transformation (normal, 90, 180, 270, flipped-90, etc.)
41
max_render_time: int # Maximum render time in milliseconds
42
focused: bool # Whether output currently has focus
43
dpms: bool # DPMS (power management) state
44
subpixel_hinting: str # Subpixel rendering mode
45
modes: List[OutputMode] # Available display modes
46
current_mode: OutputMode # Currently active display mode
47
48
# Raw data access
49
ipc_data: dict # Complete raw IPC response data
50
```
51
52
### Output Mode Structure (Sway Only)
53
54
```python { .api }
55
class OutputMode:
56
"""Display mode specification for sway outputs."""
57
width: int # Mode width in pixels
58
height: int # Mode height in pixels
59
refresh: int # Refresh rate in mHz (millihertz)
60
61
def __getitem__(self, item):
62
"""Dictionary-style access for backwards compatibility."""
63
64
@classmethod
65
def _parse_list(cls, data) -> List[OutputMode]:
66
"""Parse list of mode data into OutputMode objects."""
67
```
68
69
### Rectangle Geometry
70
71
```python { .api }
72
class Rect:
73
"""Rectangle dimensions and positioning for outputs."""
74
x: int # X coordinate of output in global coordinate system
75
y: int # Y coordinate of output in global coordinate system
76
width: int # Output width in pixels
77
height: int # Output height in pixels
78
```
79
80
### Output Examples
81
82
```python
83
# Get all outputs and display their information
84
outputs = i3.get_outputs()
85
for output in outputs:
86
print(f"Output: {output.name}")
87
print(f" Active: {output.active}")
88
if output.active:
89
print(f" Primary: {output.primary}")
90
print(f" Current workspace: {output.current_workspace}")
91
print(f" Dimensions: {output.rect.width}x{output.rect.height}")
92
print(f" Position: ({output.rect.x}, {output.rect.y})")
93
94
# Sway-specific information
95
if hasattr(output, 'make') and output.make:
96
print(f" Monitor: {output.make} {output.model}")
97
print(f" Scale: {output.scale}x")
98
print(f" Transform: {output.transform}")
99
print(f" Focused: {output.focused}")
100
101
if output.current_mode:
102
mode = output.current_mode
103
refresh_hz = mode.refresh / 1000 # Convert mHz to Hz
104
print(f" Current mode: {mode.width}x{mode.height}@{refresh_hz}Hz")
105
106
print(f" Available modes: {len(output.modes)}")
107
for mode in output.modes[:3]: # Show first 3 modes
108
refresh_hz = mode.refresh / 1000
109
print(f" {mode.width}x{mode.height}@{refresh_hz}Hz")
110
111
# Find active outputs
112
active_outputs = [output for output in outputs if output.active]
113
print(f"Active outputs: {len(active_outputs)}")
114
115
# Find primary output
116
primary_output = next((output for output in outputs if output.primary), None)
117
if primary_output:
118
print(f"Primary output: {primary_output.name}")
119
120
# Map workspaces to outputs
121
workspace_to_output = {}
122
for output in active_outputs:
123
if output.current_workspace:
124
workspace_to_output[output.current_workspace] = output.name
125
126
print("Workspace -> Output mapping:")
127
for workspace, output_name in workspace_to_output.items():
128
print(f" {workspace} -> {output_name}")
129
```