Skip to content

Commit

Permalink
action/set_power_consumption: Added PD version constriction [GH-110]
Browse files Browse the repository at this point in the history
Feature is available only since Parallels Desktop 9
  • Loading branch information
legal90 committed Apr 23, 2014
1 parent 8f9ac1f commit c65097b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/vagrant-parallels/action/set_power_consumption.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ def initialize(app, env)
end

def call(env)
pd_version = env[:machine].provider.driver.version
if Gem::Version.new(pd_version) < Gem::Version.new("9")
@logger.info("Power consumption management is available only for Parallels Desktop >= 9")
return @app.call(env)
end

# Optimization of power consumption is defined by "Longer Battery Life" state.
vm_settings = env[:machine].provider.driver.read_settings

Expand All @@ -20,10 +26,8 @@ def call(env)
end

mode = new_val ? "Longer battery life" : "Better Performance"

env[:ui].info I18n.t(
"vagrant_parallels.parallels.power_consumption.set_mode",
mode: mode)
env[:ui].info I18n.t("vagrant_parallels.parallels.power_consumption.set_mode",
mode: mode)
env[:machine].provider.driver.set_power_consumption_mode(new_val)

@app.call(env)
Expand Down

0 comments on commit c65097b

Please # to comment.