Mac OS X Simple way to know when to call

Source: Internet
Author: User

Recently the cat is in the community often power outages, often midnight or early morning only call Ah! Get up in the morning the cat is thinking how to know the exact call time, but it does not bother the method.

Method one is to use a mobile phone recorder recording, because the access will be issued after the "drop" of a sound, so long as you know the time to start recording can know the time of the call!

Method Two is the power outage will be water, find a container placed under the open faucet, keep ultra-small water outlet, and then the next day to see the capacity to know the time of the call. But this method is a little bit of a brain residue.

Method Three is to call the doorman directly to ask the guard uncle, because they do not sleep 24 hours ah. or call the power supply Bureau said: Please believe that the cat has a very important reason, please tell me last night call time!

Method Four is if the laptop battery is enough, write code to get the exact time! The cat checked out how to get AC status under OS X system, which is the status of the power adapter. If it is conneted, it means that the battery is in power. Degree Niang search, very simple method:

System_profiler Spsoftwaredatatype Sphardwaredatatype Sppowerdatatype | Grep-e "Serial number \ (system\) | Computer name| Cycle count| Charge remaining| Charge capacity "

Return as follows:

Computer Name: Kissair

Serial Number (System): xxxxxxxxxxxxxx:)

Charge Remaining (mAh): 4296

Full Charge capacity (mAh): 4340

Cycle Count: 67

Although there is battery information, but there is no AC information, I slightly modified it, delete those unused output:

System_profiler Sppowerdatatype

Return:

Power:


Battery Information:


Model Information:

Serial number:xxxxxxxxxxxxxxx:)

Manufacturer:dp

Device name:bq20z451

Pack Lot code:0

PCB Lot code:0

Firmware version:406

Hardware Revision:1

Cell revision:173

Charge Information:

Charge Remaining (mAh): 4321

Fully Charged:no

Charging:no

Full Charge Capacity (MAH): 4321

Health information:

Cycle count:67

Condition:normal

Battery Installed:yes

Amperage (MA): 9

Voltage (MV): 8268


System Power Settings:


AC Power:

System Sleep Timer (Minutes): 60

Disk Sleep Timer (Minutes): 10

Display Sleep Timer (Minutes): 10

Wake on AC Change:no

Wake on Clamshell Open:yes

Wake on Lan:yes

Autopoweroff delay:14400

Autopoweroff enabled:1

Darkwakebackgroundtasks:1

Display Sleep Uses Dim:yes

prioritizenetworkreachabilityoversleep:0

Standby delay:4200

Standby enabled:1

Battery Power:

System Sleep Timer (Minutes): 10

Disk Sleep Timer (Minutes): 10

Display Sleep Timer (Minutes): 2

Wake on AC Change:no

Wake on Clamshell Open:yes

Autopoweroff delay:14400

Autopoweroff enabled:1

Current Power Source:yes

darkwakebackgroundtasks:0

Display Sleep Uses Dim:yes

Reduce Brightness:yes

Standby delay:4200

Standby enabled:1


Hardware Configuration:


UPS Installed:no


AC Charger Information:


Connected:no

Charging:no


Note the last few lines, that is the AC connection status Ah! However, further streamlining of the command is needed:

[Email protected]: ~ $system _profiler sppowerdatatype|grep Connected:

Connected: Yes

[Email protected]: ~ $system _profiler sppowerdatatype|grep Connected:

Connected: No

This time, it will be easy to do it in code:

#!/usr/bin/rubywhile Trueret = ' System_profiler sppowerdatatype|grep Connected: ' If ret =~/yes/#表示有电源接入puts ' power come W Hen #{time.now} "; Breakend;sleep 1end

Kids Shoes brain hole open, help me think of other good ways!

Mac OS X simple way to know when to call out

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.