Class: Backlight::Settings
- Inherits:
-
Object
- Object
- Backlight::Settings
- Defined in:
- lib/backlight.rb
Overview
Class to edit backlight settings on intel-based systems
Instance Attribute Summary collapse
-
#max ⇒ Object
Returns the value of attribute max.
-
#output ⇒ Object
Returns the value of attribute output.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#get ⇒ Object
Gets the backlight brightness as a percentage.
-
#initialize(output = '/sys/class/backlight/intel_backlight/brightness', max = '/sys/class/backlight/intel_backlight/max_brightness') ⇒ Settings
constructor
Initalizes a new Settings instance.
-
#set(percent) ⇒ Object
Sets the backlight brightness as a percentage.
Constructor Details
#initialize(output = '/sys/class/backlight/intel_backlight/brightness', max = '/sys/class/backlight/intel_backlight/max_brightness') ⇒ Settings
Initalizes a new Settings instance
Attributes
-
output
- The file to write the backlight value to -
max
- The file (or numeric value) to use for the max brightness
18 19 20 21 22 23 24 25 |
# File 'lib/backlight.rb', line 18 def initialize(output = '/sys/class/backlight/intel_backlight/brightness', max = '/sys/class/backlight/intel_backlight/max_brightness') self.output = output self.max = max @value = IO.read(@output).to_i # NOTE: we don't call self.value= here, because this would make it # impossible to recover from a bad value being written in the file end |
Instance Attribute Details
#max ⇒ Object
Returns the value of attribute max.
7 8 9 |
# File 'lib/backlight.rb', line 7 def max @max end |
#output ⇒ Object
Returns the value of attribute output.
6 7 8 |
# File 'lib/backlight.rb', line 6 def output @output end |
#value ⇒ Object
Returns the value of attribute value.
8 9 10 |
# File 'lib/backlight.rb', line 8 def value @value end |
Instance Method Details
#get ⇒ Object
Gets the backlight brightness as a percentage
83 84 85 |
# File 'lib/backlight.rb', line 83 def get 100 * @value / @max end |
#set(percent) ⇒ Object
Sets the backlight brightness as a percentage
76 77 78 |
# File 'lib/backlight.rb', line 76 def set(percent) self.value = percent * @max / 100 end |