Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions default/hypr/bindings/utilities.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,12 @@ o.bind_toggle("SUPER + CTRL + I", "Toggle locking on idle", "idle")
o.bind_toggle("SUPER + CTRL + N", "Toggle nightlight", "nightlight")
o.bind("SUPER + CTRL + Delete", "Toggle laptop display", "omarchy-hyprland-monitor-internal toggle")
o.bind("SUPER + CTRL + ALT + Delete", "Toggle laptop display mirroring", "omarchy-hyprland-monitor-internal-mirror toggle")
-- Hyprland compares a switch bind against the device name byte for byte and has
-- no wildcard, so every lid that reports another name needs its own pair.
o.bind("switch:on:Lid Switch", nil, "omarchy-system-lid-close", { locked = true })
o.bind("switch:off:Lid Switch", nil, "omarchy-hyprland-monitor-clamshell", { locked = true })
o.bind("switch:on:Apple SMC power/lid events", nil, "omarchy-system-lid-close", { locked = true })
o.bind("switch:off:Apple SMC power/lid events", nil, "omarchy-hyprland-monitor-clamshell", { locked = true })

o.bind("PRINT", "Screenshot", "omarchy-capture-screenshot")
o.bind("ALT + PRINT", "Screenrecording", "omarchy-capture-screenrecording --stop-recording || omarchy-menu toggle trigger.capture.screenrecord")
Expand Down
38 changes: 38 additions & 0 deletions test/shell.d/lid-switch-bindings-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash

set -euo pipefail

source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh"

run_node_test <<'JS'
const fs = require('fs')
const utilities = fs.readFileSync(path.join(root, 'default/hypr/bindings/utilities.lua'), 'utf8')
const lines = new Set(utilities.split('\n').map((line) => line.trim()))

// Hyprland compares a switch bind against the device name byte for byte and
// offers no wildcard, so a lid reporting any other name never fires at all.
// These assert whole literal lines rather than a pattern on purpose: a
// near-miss in this string is indistinguishable from having no bind.
const edges = [
['on', 'omarchy-system-lid-close'],
['off', 'omarchy-hyprland-monitor-clamshell'],
]

// "Lid Switch" is what a typical ACPI laptop reports; Apple Silicon exposes the
// same SW_LID switch as "Apple SMC power/lid events" and never as the former.
const devices = ['Lid Switch', 'Apple SMC power/lid events']

for (const device of devices) {
for (const [edge, handler] of edges) {
// locked = true is part of the contract, not decoration: without it the
// bind is skipped exactly when the lid closes on an already-locked session.
const bind = `o.bind("switch:${edge}:${device}", nil, "${handler}", { locked = true })`

assert(
lines.has(bind),
`${device} binds ${edge} to ${handler} and fires while locked`,
`missing line: ${bind}`
)
}
}
JS