active_gfx 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +5 -0
  3. data/LICENSE +21 -0
  4. data/bin/active_gfx +60 -0
  5. metadata +47 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9c940a72789c58f11ce86f55272deb967a59fb4d
4
+ data.tar.gz: a227b99d841ad6bbd72e312cf0034d93aaacd6e4
5
+ SHA512:
6
+ metadata.gz: 9ae328431950bce5230e2347b412f03141eeab8187f7bfb87626bae3455894362f7c27ae78168f960797b0125928b9e113379b900c7cf1efb5b53899bd86f621
7
+ data.tar.gz: 8d33e17ae3c159b23a661d2af4ca97f4de25994fbd96d34da665396bb7de1bab4e0dab81a2b9f2887b51c9981f170f4908ad134f7ccfd5a584edf4d7092cdf51
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+ source "https://rubygems.org"
3
+
4
+ # gem "rails"
5
+ gem 'plist'
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2016 Andreas Ganske
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/bin/active_gfx ADDED
@@ -0,0 +1,60 @@
1
+ #!/usr/local/bin/ruby
2
+
3
+ require 'rubygems'
4
+ require 'plist'
5
+ require 'optparse'
6
+
7
+ Options = Struct.new(:pretty, :all)
8
+
9
+ class Parser
10
+ Version = '0.0.1'
11
+
12
+ def self.parse(options)
13
+ args = Options.new()
14
+
15
+ opt_parser = OptionParser.new do |opts|
16
+ opts.banner = "Usage: active_gfx [options]"
17
+
18
+ opts.on("-a", "--all", "Shows all graphics chips instead of only in use") do |a|
19
+ args.all = a
20
+ end
21
+
22
+ opts.on("-p", "--pretty", "Print the pretty name of graphics card instead of model identifier") do |p|
23
+ args.pretty = p
24
+ end
25
+
26
+ opts.on("-h", "--help", "Prints this help") do
27
+ puts opts
28
+ exit
29
+ end
30
+
31
+ opts.on("-v", "--version", "Show version") do
32
+ puts Version
33
+ exit
34
+ end
35
+ end
36
+
37
+ opt_parser.parse!(options)
38
+ return args
39
+ end
40
+ end
41
+
42
+ options = Parser.parse(ARGV)
43
+
44
+ # calculate video data
45
+ data = `system_profiler SPDisplaysDataType -xml`
46
+ video_data = Plist.parse_xml(data)
47
+
48
+ usedGfx = []
49
+
50
+ for gfxCard in video_data[0]["_items"]
51
+ displays = gfxCard["spdisplays_ndrvs"]
52
+ drivesDisplays = !displays.nil? && !displays.empty?
53
+ field = options.pretty ? "sppci_model" : "_name"
54
+ if drivesDisplays || options.all
55
+ name = gfxCard[field]
56
+ usedGfx += [name]
57
+ end
58
+ end
59
+
60
+ puts usedGfx
metadata ADDED
@@ -0,0 +1,47 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: active_gfx
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Andreas Ganske
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-12-18 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email: active_gfx@chaosspace.de
15
+ executables:
16
+ - active_gfx
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - Gemfile
21
+ - LICENSE
22
+ - bin/active_gfx
23
+ homepage: http://rubygems.org/gems/active_gfx
24
+ licenses:
25
+ - MIT
26
+ metadata: {}
27
+ post_install_message:
28
+ rdoc_options: []
29
+ require_paths:
30
+ - lib
31
+ required_ruby_version: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
36
+ required_rubygems_version: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ requirements: []
42
+ rubyforge_project:
43
+ rubygems_version: 2.5.2
44
+ signing_key:
45
+ specification_version: 4
46
+ summary: active_gfx shows the graphics card currently in use by you macOS system
47
+ test_files: []