#navi(../)
* AC電源駆動かバッテリー駆動なのかを確認する方法 [#za68df92]
ノートPCがAC電源駆動中なのか、バッテリー駆動中なのかを確認するコマンドを紹介します。~
今回紹介するon_ac_powerコマンドですが、CentOS6, Ubuntu12.04にあることと動作確認を行いました。

#contents
#htmlinsertpcsp(linux_ads_top.html,linux-sp.html)

* on_ac_powerコマンド [#v24198c1]
CentOS6とUbutnu12.04にインストールされているon_ac_powerのmanを確認しました。~
違いは以下の通りで、電源が不明の場合のステータス記述がCentOS側には無いようです

- CentOS
 NAME
        on_ac_power - test whether the computer is running on line power
 SYNOPSIS
        on_ac_power
 EXIT CODES
       The command succeeds (status 0) if the system is using line power and fails (status other than
       0) otherwise. It is designed to be easy to use in shell scripts.
       0 (true)
           System is on line power.
       1 (false)
           System is not on line power.
-Ubuntu
 NAME
       on_ac_power - test whether computer is running on AC power
 SYNOPSIS
       on_ac_power
 DESCRIPTION
       on_ac_power checks whether the system is running on AC power (i.e., mains power) as opposed to battery power.
 OPTIONS
       None.
 EXIT STATUS
       0 (true)  System is on mains power
       1 (false) System is not on mains power
       255 (false)    Power status could not be determined

* 実際にon_ac_powerを使ってみる [#zf48c3ef]
-AC電源の時
 sakura@ubuntu:~$ on_ac_power
 sakura@ubuntu:~$ echo $?
 0

-バッテリー駆動の時
 sakura@ubuntu:~$ on_ac_power
 sakura@ubuntu:~$ echo $?
 1

以上、ノートPCがAC電源駆動中なのかバッテリー駆動中なのかを確認する方法でした。

#htmlinsertpcsp(linux_ads_btm.html,linux-sp.html)

トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS