Lid Events
Lid state monitoring uses D-Bus to listen for UPower lid events. This feature is optional and needs to be explicitly enabled.
Enabling Lid Events
To enable lid state monitoring:
hyprdynamicmonitors run --enable-lid-events
When disabled (default):
- The system defaults to
UNKNOWNlid state - No lid events will be delivered
- No D-Bus connection for lid events will be made
Default Configuration
By default, when enabled, the service listens for D-Bus signals:
- Signal:
org.freedesktop.DBus.Properties.PropertiesChanged - Interface:
org.freedesktop.DBus.Properties - Member:
PropertiesChanged - Path:
/org/freedesktop/UPower
Monitoring Lid Events
You can monitor lid events with:
gdbus monitor --system --dest org.freedesktop.UPower --object-path /org/freedesktop/UPower
Example output:
/org/freedesktop/UPower: org.freedesktop.DBus.Properties.PropertiesChanged ('org.freedesktop.UPower', {'LidIsClosed': <true>}, @as [])
/org/freedesktop/UPower: org.freedesktop.DBus.Properties.PropertiesChanged ('org.freedesktop.UPower', {'LidIsClosed': <false>}, @as [])
Querying Lid Status
On each event, the current lid status is queried. Equivalent command:
dbus-send --system --print-reply \
--dest=org.freedesktop.UPower /org/freedesktop/UPower \
org.freedesktop.DBus.Properties.Get \
string:org.freedesktop.UPower string:LidIsClosed
Custom D-Bus Configuration
Custom Signal Match Rules
You can customize which D-Bus signals to monitor for lid events:
[lid_events]
[[lid_events.dbus_signal_match_rules]]
interface = "org.freedesktop.DBus.Properties"
member = "PropertiesChanged"
object_path = "/org/freedesktop/UPower"
# sender = "org.freedesktop.UPower" # Optional: specific sender
[[lid_events.dbus_signal_receive_filters]]
name = "org.freedesktop.DBus.Properties.PropertiesChanged"
body = "LidIsClosed" # Filter signals containing this in the body
The body filter is useful for limiting the signals processed, as D-Bus property change events can be noisy.
Custom Query Configuration
You can customize how lid state is queried:
[lid_events.dbus_query_object]
destination = "org.freedesktop.UPower"
path = "/org/freedesktop/UPower"
method = "org.freedesktop.DBus.Properties.Get"
expected_lid_closing_value = "true"
[[lid_events.dbus_query_object.args]]
arg = "org.freedesktop.UPower"
[[lid_events.dbus_query_object.args]]
arg = "LidIsClosed"
This configuration is equivalent to the default and queries the lid state using standard UPower D-Bus properties.
See the lid-states example for a complete configuration.
Receive Filters
By default, the service matches:
org.freedesktop.DBus.Properties.PropertiesChangednameLidIsClosedbody
This prevents noisy signals. Lid status changes are only propagated when the state actually changes.
Using Lid State
Lid state is available in templates via functions:
{{if isLidClosed}}
# Disable laptop screen when lid is closed
monitor=eDP-1,disable
{{else}}
monitor=eDP-1,2880x1920@120,0x0,2.0
{{end}}
Available template functions:
isLidClosed- Returns true if the lid is closedisLidOpened- Returns true if the lid is opened.LidState- Returns the lid state string ("Closed","Opened", or"UNKNOWN")
Lid State Values
The .LidState variable can have these values:
"UNKNOWN"- Lid events are disabled or state cannot be determined"Closed"- Lid is closed"Opened"- Lid is open
Common Use Cases
Disable Laptop Screen When Docked with Lid Closed
{{- $laptop := index .MonitorsByTag "laptop" -}}
{{- $external := index .MonitorsByTag "external" -}}
{{if isLidClosed}}
monitor={{$laptop.Name}},disable
{{else}}
monitor={{$laptop.Name}},2880x1920@120,0x0,2.0
{{end}}
monitor={{$external.Name}},preferred,auto,1
Different Layouts Based on Lid State
{{if isLidClosed}}
# Closed lid: external monitor only
monitor=eDP-1,disable
monitor=DP-1,3840x2160@60,0x0,1
{{else}}
# Open lid: dual monitor setup
monitor=eDP-1,2880x1920@120,0x0,2.0
monitor=DP-1,3840x2160@60,2880x0,1
{{end}}
See Also
- Templates - Template syntax and variables
- Power Events - Similar D-Bus event system
- Examples - Lid States