ããããªã¼ã®æ®é表示
30åããã°ã©ã ããã®426ãHP2133ã«å
¥ãã¦ããUbunutuã®ã¦ã¤ã³ãã¦ããã¼ã¸ã£ãRatpoisonã«ããããããããªã¼è¡¨ç¤ºãæ¶ãã¦ãã¾ã£ãã
ã§ããããããªã¼è¡¨ç¤ºã®ããã«GNOMEã«ã¯ãã©ããªãä½ã«ãªã£ã¦ãã¾ã£ãã®ã§ãç°¡åãªããããªã¼æ®é表示ããã°ã©ã ãæ¸ãã¦ã¿ãã
/proc/acpi/battery/ãèªãã°ããããªã¼ã®æ
å ±ã¯å¾ãããã®ã§ãããã¨ç°¡åã
使ãæ¹
å®è¡ããã¨æ®éããã¼ã»ã³ãã§è¡¨ç¤ºããã
$ ./battery 89.0%
screenã®ã¹ãã¼ã¿ã¹ã©ã¤ã³ã«çµã¿è¾¼ãã§ããã
# 60ç§(1å)ã«ä¸åãæ®éãæ´æ° backtick 0 0 60 battery % %0`ã§ããããªã¼æ®éã表示 hardstatus alwayslastline "[%02c](%0`) %-w%{=b bw}%n %t%{-}%+w"
ã½ã¼ã¹ã³ã¼ã
#!/usr/bin/env ruby class Battery attr_reader :remain,:full def initialize(path) @remain = File.read("#{path}/state"). scan(/^remaining capacity:\s*(\d+)/).first.first.to_i @full = File.read("#{path}/info"). scan(/^last full capacity:\s*(\d+)/).first.first.to_i end def percent (@remain.to_f / @full) * 100 end end bat = Battery.new('/proc/acpi/battery/BAT1') printf "%.1f%%\n",bat.percent