如何检查Macbook Lid是否通过终端关闭? [英] How to Check if Macbook Lid is closed via Terminal?
问题描述
我之所以问这个问题,是因为我的计划任务是每30分钟运行一次。但是,当计算机正在休眠/休眠时,crontab不运行。我的解决方案是使用pmset每30分钟安排一次唤醒。但是,我需要一种方法在盖子当前关闭的情况下让电脑重新进入睡眠状态。我不希望我的电脑在盖子关闭的情况下长时间保持清醒状态,即在睡觉时整夜醒来,因为这会损坏屏幕。
方案
ioreg -r -k AppleClamshellState -d 4 | grep AppleClamshellState |头部-1
测试并运行于10.7。*,找到 here 。
更新2018-03-24 :
仍然适用于macOS 10.13 High Sierra。
I'm running OS X 10.8 (Mountain Lion). I was wondering if there was a terminal command to check if the macbook pro's lid is currently closed. If I used grep, what would I be looking for exactly, and where?
The reason I ask is because I have cron jobs scheduled to run every 30 minutes. However, crontab doesn't run when the computer is sleeping/hibernating. My solution was to use pmset to schedule wakes every 30 minutes. However, I need a way to put my computer back to sleep on the condition that the lid is currently closed. I don't want my computer to be awake for too long with the lid closed i.e. awake all night when I'm sleeping because that could damage the screen.
ioreg -r -k AppleClamshellState -d 4 | grep AppleClamshellState | head -1
Tested and works on 10.7.*, found here.
Update 2018-03-24:
Still works on macOS 10.13 High Sierra.
这篇关于如何检查Macbook Lid是否通过终端关闭?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!