如何检查MacBook Pro中哪个视频卡处于活动状态?


14

MacBook Pro中的两个视频卡在性能和功耗上都存在很大差异。

问题是,我经常忘记正在运行哪一个。当很快在飞机上时,这可能导致电池耗尽。据我所知,您必须打开“节能器系统偏好设置”以查看哪个处于活动状态。

有谁知道会显示(在菜单栏中,在桌面上,无论如何)我当前视频卡状态的工具?终端命令将报告哪个处于活动状态,这特别好。我可以将其用作我的GeekTool设置的一部分。

如果有人碰巧知道我将在API中的何处查找这些信息,我也可以编写自己的工具。

有人有想法么?

编辑:下面有关system_profiler的答案肯定是朝正确方向迈出的一步。MBP会显示两个视频卡的信息,无论哪个视频卡处于活动状态……BUT将为连接到非活动卡的显示器显示“显示器未连接”。我应该能够编写一些脚本,以便从那里弄清楚。

EDIT2:关键是从system_profier以xml格式获取输出(使用-xml开关)。以下脚本可解析结果plist并显示结果。

Answers:


6

假设system_profiler将仅报告活动显示(我不知道要在MBP附近)如何将其插入GeekTool:

system_profiler | grep GeForce | sed -e 's/:/ /'

编辑:

如果它在“显示未连接”的同一行上列出了非活动状态,该如何处理:

system_profiler | grep GeForce | grep - v "display not connected" | sed -e 's/:/ /'

如果它首先列出了活动的,那么如何:

system_profiler | grep GeForce | head -n 1 | sed -e 's/:/ /'

如果处于活动状态,则将其替换为头部,然后将其替换为尾巴。


为什么用冒号代替空格?
丹尼尔说,请

4

http://codykrieger.com/gfxCardStatus

这是一个位于栏中的小型应用程序,不仅为您提供使用中的卡,还可以控制如何以及何时切换卡。例如,您只能将集成显卡设置为在使用电池供电时才能运行-等等。


gfxCardStatus已针对Mountain Lion和Retina MacBook Pro更新。
slothbear 2012年

3

使用其他两个答案中提出的基本思想,我编写了以下脚本来确定您使用的是“正确的”视频卡(正确的=“使用电池并使用9400”还是“使用交流适配器并使用9600”)

我不知道这些脚本有多脆弱……它们依赖于以特定顺序出现在system_profile plist中的特定数据……但是这个顺序在我的机器上似乎是一致的。将其放置在这里,供任何通过Google找到它的人使用。

Ruby :(需要安装“ Plist” gem)

# video_profiler.rb
require 'rubygems'
require 'plist'

# calculate video data
data = `system_profiler SPDisplaysDataType -xml`
structured_video_data = Plist.parse_xml(data)
display_status = structured_video_data[0]["_items"][0]["spdisplays_ndrvs"][0]["spdisplays_status"]

if (display_status.eql?('spdisplays_not_connected')) then 
    card = '9400'
else
    card = '9600'
end

# calculate power source data
data = `system_profiler SPPowerDataType -xml`
structured_power_data = Plist.parse_xml(data)
on_ac_power = (structured_power_data[0]["_items"][3]["sppower_battery_charger_connected"] == 'TRUE')

# output results
if (on_ac_power and card.eql?'9400') or (not on_ac_power and card.eql?'9600'):
    result = 'You\'re on the wrong video card.'
else
    result = "You\'re on the correct video card."
end

puts(result)

蟒蛇:

# video_profiler.py
from subprocess import Popen, PIPE
from plistlib import readPlistFromString
from pprint import pprint
sp = Popen(["system_profiler", "SPDisplaysDataType", "-xml"], stdout=PIPE).communicate()[0]
pl = readPlistFromString(sp)
display_status = pl[0]["_items"][0]["spdisplays_ndrvs"][0]["spdisplays_status"]
if (display_status == 'spdisplays_not_connected'): 
    card = '9400'
else:
    card = '9600'

# figure out battery status
sp = Popen(["system_profiler", "SPPowerDataType", "-xml"], stdout=PIPE).communicate()[0]
pl = readPlistFromString(sp)
on_ac_power = (pl[0]["_items"][3]["sppower_battery_charger_connected"] == 'TRUE')


if (on_ac_power and card == '9400') or (not on_ac_power and card == '9600'):
    result = 'You\'re on the wrong video card.'
else:
    result = "You\'re on the correct video card."

pprint(result)

2

我知道这个问题已经很久了-但是对于仍然绊脚石的那些人,很高兴知道还有其他选择。对于最简单的解决方案,您可以签出GFXCheck,这是一个简单的应用程序,它将在


2
或gfxcardStatus,它还允许您根据电源配置文件选择手动或自动使用哪一个。
罗伯特·西亚乔

2
实际上,在撰写本文后不久,我发现gfxCardStatus并进行了安装-更好。具有自动切换功能,界面较烦人。
micdah 2010年

您是否知道如何结束句子?
fixer1234

1

我这里没有新的MacBook Pro之一,但您应该可以通过System Profiler查看活动的卡。在终端中,仅需使用system_profiler即可查看系统配置:

终端截图


0

您可以使用active_gfx我编写的红宝石宝石:https : //github.com/ChaosCoder/active_gfx

active_gfx显示您的macOS系统当前正在使用的图形卡。

该工具无需查询Activity Monitor中打开的进程列表,而是通过查询来吐出当前使用的图形芯片system_profiler

作为active_gfx红宝石宝石,请通过安装gem install active_gfx

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.