intel-backlight 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/backlight +17 -0
- data/lib/backlight.rb +87 -0
- metadata +132 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 872d4e7b17212889512318bbf6f14bd727e557b1
|
4
|
+
data.tar.gz: c522632cf08c37a5921154f0daeb0864e6eaf9f5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2f22d73c7f34e0c3477c95094290403148c1da38c47287e8184d2760516006f5039a5c5395d895accb3ae33c50184ee8851c5402df6961501c49c153bdb5c432
|
7
|
+
data.tar.gz: ba7f6303907bc2a9adb5ec4b4cef2411ace1d11e311b58415d3e03b990ae80e0ae8a0203d1b57f1c6dac42fbbac03765e5208291a60c5bb3b7fafb20f7a0025c
|
data/bin/backlight
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'backlight'
|
4
|
+
|
5
|
+
config = Backlight::Settings.new
|
6
|
+
|
7
|
+
cmd = ARGV[0]
|
8
|
+
|
9
|
+
if cmd.nil? || cmd.empty?
|
10
|
+
puts config.get
|
11
|
+
elsif cmd == "help" || cmd == "--help" || cmd == "-h"
|
12
|
+
puts "Usage: backlight [+/-][PERCENT]"
|
13
|
+
elsif cmd[0] == "+" || cmd[0] == "-"
|
14
|
+
config.set(config.get + cmd.to_i)
|
15
|
+
else
|
16
|
+
config.set cmd.to_i
|
17
|
+
end
|
data/lib/backlight.rb
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
module Backlight
|
2
|
+
##
|
3
|
+
# Class to edit backlight settings on intel-based systems
|
4
|
+
#
|
5
|
+
class Settings
|
6
|
+
attr_reader :output
|
7
|
+
attr_reader :max
|
8
|
+
attr_reader :value
|
9
|
+
|
10
|
+
##
|
11
|
+
# Initalizes a new Settings instance
|
12
|
+
#
|
13
|
+
# ==== Attributes
|
14
|
+
#
|
15
|
+
# * +output+ - The file to write the backlight value to
|
16
|
+
# * +max+ - The file (or numeric value) to use for the max brightness
|
17
|
+
#
|
18
|
+
def initialize(output = '/sys/class/backlight/intel_backlight/brightness',
|
19
|
+
max = '/sys/class/backlight/intel_backlight/max_brightness')
|
20
|
+
self.output = output
|
21
|
+
self.max = max
|
22
|
+
@value = IO.read(@output).to_i
|
23
|
+
# NOTE: we don't call self.value= here, because this would make it
|
24
|
+
# impossible to recover from a bad value being written in the file
|
25
|
+
end
|
26
|
+
|
27
|
+
##
|
28
|
+
# Sets the output file for the backlight settings
|
29
|
+
#
|
30
|
+
# ==== Attributes
|
31
|
+
#
|
32
|
+
# * +file+ - The file to write the backlight value to
|
33
|
+
#
|
34
|
+
def output=(file)
|
35
|
+
raise(ArgumentError, 'Out File Does Not Exist') unless File.exist?(file)
|
36
|
+
@output = file
|
37
|
+
end
|
38
|
+
|
39
|
+
##
|
40
|
+
# Sets the maximum brightness value of the backlight.
|
41
|
+
#
|
42
|
+
# ==== Attributes
|
43
|
+
#
|
44
|
+
# * +max+ - This can either be the filename to read the max from, or a
|
45
|
+
# numeric maximum value.
|
46
|
+
#
|
47
|
+
def max=(max)
|
48
|
+
if max.is_a? Numeric
|
49
|
+
raise(ArgumentError, 'Max Brightness Cannot Be Less Than 0') if max < 0
|
50
|
+
@max = max.to_i
|
51
|
+
elsif max.is_a? String
|
52
|
+
raise(ArgumentError, 'Max File Does Not Exist') unless File.exist?(max)
|
53
|
+
@max = IO.read(max).to_i
|
54
|
+
else
|
55
|
+
raise(ArgumentError, 'Unknown Parameter Type')
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
##
|
60
|
+
# Sets the value of the backlight, from zero to the set maximum
|
61
|
+
#
|
62
|
+
# ==== Attributes
|
63
|
+
#
|
64
|
+
# * +value+ - The value to set to the backlight output file
|
65
|
+
#
|
66
|
+
def value=(value)
|
67
|
+
value = value.to_i
|
68
|
+
raise(ArgumentError, 'Invalid Value') if value < 0 || value > @max
|
69
|
+
IO.write(@output, value)
|
70
|
+
@value = value
|
71
|
+
end
|
72
|
+
|
73
|
+
##
|
74
|
+
# Sets the backlight brightness as a percentage
|
75
|
+
#
|
76
|
+
def set(percent)
|
77
|
+
self.value = percent * @max / 100
|
78
|
+
end
|
79
|
+
|
80
|
+
##
|
81
|
+
# Gets the backlight brightness as a percentage
|
82
|
+
#
|
83
|
+
def get
|
84
|
+
100 * @value / @max
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
metadata
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: intel-backlight
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Caleb Smith
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-01-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rubocop
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.49'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.49'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rdoc
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '4.2'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '4.2'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.15'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.15'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '12.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '12.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: test-unit
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.2'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.2'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: github_changelog_generator
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.14'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.14'
|
97
|
+
description: This gem allows you to update your laptop screen backlight brightness
|
98
|
+
on intel-based systems
|
99
|
+
email: karagenit@outlook.com
|
100
|
+
executables:
|
101
|
+
- backlight
|
102
|
+
extensions: []
|
103
|
+
extra_rdoc_files: []
|
104
|
+
files:
|
105
|
+
- bin/backlight
|
106
|
+
- lib/backlight.rb
|
107
|
+
homepage: https://github.com/karagenit/intel-backlight
|
108
|
+
licenses:
|
109
|
+
- MIT
|
110
|
+
metadata: {}
|
111
|
+
post_install_message:
|
112
|
+
rdoc_options: []
|
113
|
+
require_paths:
|
114
|
+
- lib/
|
115
|
+
- bin/
|
116
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
requirements: []
|
127
|
+
rubyforge_project:
|
128
|
+
rubygems_version: 2.6.12
|
129
|
+
signing_key:
|
130
|
+
specification_version: 4
|
131
|
+
summary: Set Screen Brightness on Intel Laptops
|
132
|
+
test_files: []
|