We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents bc27804 + abcb868 commit 62238ceCopy full SHA for 62238ce
1 file changed
noclamshell
@@ -1,13 +1,12 @@
1
#!/usr/bin/env bash
2
3
-CLAMSHELL=$(ioreg -r -k AppleClamshellState | grep AppleClamshellState | grep Yes)
4
-FLAG_FILE=$TMPDIR/noclamshell.lid.closed.and.sleeping
5
-
6
-if [ "$CLAMSHELL" ]; then
7
- if [[ ! -f $FLAG_FILE ]]; then
8
- touch $FLAG_FILE
9
- pmset sleepnow
+LID_CLOSED=$(ioreg -r -k AppleClamshellState | grep AppleClamshellState | grep Yes)
+if [ "$LID_CLOSED" ]; then
+ EXTERNAL_DISPLAY_CONNECTED=$(pmset -g powerstate | grep AppleDisplay | grep USEABLE)
+ if [ "$EXTERNAL_DISPLAY_CONNECTED" ]; then
+ AWAKE=$(pmset -g powerstate | grep IODisplayWrangler | grep USEABLE)
+ if [ "$AWAKE" ]; then
+ pmset sleepnow
10
+ fi
11
fi
-else
12
- rm -f $FLAG_FILE
13
0 commit comments