mirror of
https://github.com/swaywm/sway.git
synced 2024-11-25 09:21:28 +00:00
Pure shell script for lid.
parent
03ed979e63
commit
fed824ae8b
20
Home.md
20
Home.md
|
@ -93,18 +93,24 @@ bindswitch --reload --locked lid:on output $laptop disable
|
||||||
bindswitch --reload --locked lid:off output $laptop enable
|
bindswitch --reload --locked lid:off output $laptop enable
|
||||||
```
|
```
|
||||||
|
|
||||||
However, when reloading sway while using clamshell mode, the displays may reset (i.e. both displays will be enabled). To stop this, save this bash script:
|
However, when reloading sway while using clamshell mode, the displays may reset (i.e. both displays will be enabled). To stop this, save this shell script:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
if grep -q open /proc/acpi/button/lid/LID/state; then
|
|
||||||
swaymsg output <LAPTOP> enable
|
LAPTOP_OUTPUT="<LAPTOP>"
|
||||||
else
|
LID_STATE_FILE="/proc/acpi/button/lid/LID0/state"
|
||||||
swaymsg output <LAPTOP> disable
|
|
||||||
fi
|
read -r LS < "$LID_STATE_FILE"
|
||||||
|
|
||||||
|
case "$LS" in
|
||||||
|
*open) swaymsg output "$LAPTOP_OUTPUT" enable ;;
|
||||||
|
*closed) swaymsg output "$LAPTOP_OUTPUT" disable ;;
|
||||||
|
*) echo "Could not get lid state" >&2 ; exit 1 ;;
|
||||||
|
esac
|
||||||
```
|
```
|
||||||
|
|
||||||
Replace `<LAPTOP>` with the name of the display.
|
Replace `<LAPTOP>` with the name of the display, ensure lid state file path is correct for your system.
|
||||||
|
|
||||||
To make sure this script runs whenever Sway is reloaded, add this line to your sway config:
|
To make sure this script runs whenever Sway is reloaded, add this line to your sway config:
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue