2009-02-13 86 views

回答

1

epatel相当接近,我不得不改变AppleGraphicsControlBacklight关键字别的东西让它在我的MacBook工作,所以我猜想这是OSX版本和/或macbook版本之间可能会改变的东西。

我把一个简短的ruby脚本扔在一起,在命令行上打印出一个小小的视觉指示器。

# grab the string containing the values 
brite_string = `ioreg -c AppleBacklightDisplay | grep brightness` 

# build a regex to match those vals 
brite_regex = /"brightness"=\{"min"=([0-9]{1,3}),"value"=([0-9]{1,3}),"max"=([0-9]{1,3})/ 

# match them 
match_data = brite_regex.match(brite_string) 

# extract the values from the match 
min = match_data[1].to_i 
val = match_data[2].to_i 
max = match_data[3].to_i 

# print them out nice 
puts "Current Brightness" 
print "[" 

max.times do |i| 
    print i > val ? " " : "*" 
end 

puts "]" 
-1

我不是一个mac家伙,但/ proc存在于文件系统中吗?如果存在,您可能需要查看该虚拟文件目录。

+0

/proc在Max OS X上不存在。我不知道其他目录是否具有相同的作用。 – mouviciel 2009-02-13 21:23:57

+0

嗯..是的,只是猜测,因为Linux和OS X是或多或少表亲。 – 2009-02-13 21:50:35

2

我相信可以用IOKit查看它。在终端中运行ioreg命令如下所示,可以看到两行亮度值可见。

% ioreg -c AppleGraphicsControlBacklight | grep brightness 

| | |  "IODisplayParameters" = {"brightness"={"min"=0,"value"=408,"max"=1024},"commit"={"reg"=0}} 
| | |  "IODisplayParameters" = {"brightness"={"min"=0,"value"=408,"max"=1024},"commit"={"reg"=0}} 

也许有人有足够的知识,由于IOKit可以把一个样本...

相关问题