thirdeye 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: eba23d4e5f504a93924158f51be2039fd97ab63b
4
+ data.tar.gz: a4165000e86857108bf74786b9c274d27912972e
5
+ SHA512:
6
+ metadata.gz: bc719999cfbbbce3e54466e61b36859d363b4972f7ddb474ecc796dd9637db0b6c3ea68b2da36c00e18bdfbbbdf0c5773df7a95455b2bbc4e58db8646bba4b71
7
+ data.tar.gz: ac4f2cc163536b097c2e844c1445c9a99153680c879d9eacfadc3b8744c1754d95bcfd0151c7276e2f25fd87cf4eb7967ddf2135b5f47a057be129b63cb1a75a
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in thirdeye.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Drew Fradette
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,29 @@
1
+ # Thirdeye
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'thirdeye'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install thirdeye
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+ require 'thirdeye'
3
+
4
+ module Thirdeye
5
+ Window.all.tap do |windows|
6
+ dmenu(windows.collect{|w| w.name}).tap do |selection|
7
+ exit 0 if selection.nil?
8
+ run "[con_id=#{windows.detect{|w| w.name == selection}.id}] focus"
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ #!/usr/bin/env ruby
4
+ require 'thirdeye'
5
+
6
+ module Thirdeye
7
+ Window.all.each{|w| puts w.name}
8
+ end
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ require 'thirdeye'
3
+
4
+ module Thirdeye
5
+ run "workspace #{dmenu(Workspace.list)}"
6
+ end
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'thirdeye'
4
+
5
+ module Thirdeye
6
+ Workspace.all.select{|ws| ws.visible?}.tap do |workspaces|
7
+ unless workspaces.size == 2
8
+ puts "ERR: #{$0} is intended to work with exactly two workspaces"
9
+ exit 1
10
+ end
11
+
12
+ workspaces.each do |workspace|
13
+ run "workspace #{workspace.name}, move workspace to output right"
14
+ end
15
+
16
+ run "workspace #{workspaces.detect{|ws| ws.focused?}.name}"
17
+ end
18
+ end
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'thirdeye'
4
+
5
+ puts Thirdeye::Workspace.all.collect{|ws| ws.name || ws.num}.join("\n")
@@ -0,0 +1,17 @@
1
+ require 'i3-ipc'
2
+
3
+ require "thirdeye/version"
4
+ require 'thirdeye/base'
5
+ require 'thirdeye/workspace'
6
+ require 'thirdeye/output'
7
+ require 'thirdeye/window'
8
+
9
+ module Thirdeye
10
+ def self.run(cmd)
11
+ I3::IPC.new.command(cmd)
12
+ end
13
+
14
+ def self.dmenu(list = nil)
15
+ `echo -e "#{list.join("\n")}" | dmenu -i`.strip
16
+ end
17
+ end
@@ -0,0 +1,13 @@
1
+ module Thirdeye
2
+ class Base
3
+ class << self
4
+ def i3
5
+ @@i3 ||= I3::IPC.new
6
+ end
7
+ end
8
+
9
+ def i3
10
+ @i3 ||= I3::IPC.new
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,36 @@
1
+ module Thirdeye
2
+ class Output < Base
3
+ class << self
4
+ def all
5
+ i3.get_outputs.collect do |op|
6
+ self.new op['name']
7
+ end
8
+ end
9
+ end
10
+
11
+ attr_accessor :name
12
+
13
+ def initialize(name)
14
+ @name = name
15
+ end
16
+
17
+ def active?
18
+ data['active']
19
+ end
20
+
21
+ def primary?
22
+ data['primary']
23
+ end
24
+
25
+ def current_workspace
26
+ data['current_workspace']
27
+ end
28
+
29
+ protected
30
+ def data
31
+ i3.get_outputs.detect do |op|
32
+ op['name'] == name
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,3 @@
1
+ module Thirdeye
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,42 @@
1
+ module Thirdeye
2
+ class Window < Base
3
+ class << self
4
+ def all
5
+ self.collect_nodes i3.get_tree['nodes']
6
+ end
7
+
8
+ protected
9
+ def collect_nodes(nodes)
10
+ windows = []
11
+ nodes.each do |node|
12
+ next if node['name'].start_with?('i3bar for output')
13
+ windows << Window.new(node) if node['window']
14
+ windows.concat(self.collect_nodes(node['nodes'])) unless node['nodes'].empty?
15
+ end
16
+ windows
17
+ end
18
+ end
19
+
20
+ attr_accessor :data
21
+
22
+ def initialize(node)
23
+ @data = node
24
+ end
25
+
26
+ def id
27
+ data['id']
28
+ end
29
+
30
+ def name
31
+ data['name']
32
+ end
33
+
34
+ def focus
35
+ i3.command "[con_id=#{window_id}] focus"
36
+ end
37
+
38
+ def data
39
+ @data
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,57 @@
1
+ module Thirdeye
2
+ class Workspace < Base
3
+ class << self
4
+ def all
5
+ i3.get_workspaces.collect do |ws|
6
+ self.new(ws['num'] || ws['name'])
7
+ end
8
+ end
9
+
10
+ def list
11
+ self.all.collect{|ws| ws.name || ws.num}
12
+ end
13
+ end
14
+
15
+ attr_accessor :id
16
+
17
+ def initialize(id)
18
+ @id = id
19
+ end
20
+
21
+ def focused?
22
+ data['focused']
23
+ end
24
+
25
+ def exists?
26
+ !data.nil?
27
+ end
28
+
29
+ def visible?
30
+ data['visible']
31
+ end
32
+
33
+ def urgent?
34
+ data['urgent']
35
+ end
36
+
37
+ def output
38
+ data['output']
39
+ end
40
+
41
+ def num
42
+ data['num']
43
+ end
44
+
45
+ def name
46
+ data['name']
47
+ end
48
+
49
+ protected
50
+
51
+ def data
52
+ i3.get_workspaces.detect do |ws|
53
+ [ws['num'],ws['name']].include? id
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'thirdeye/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "thirdeye"
8
+ spec.version = Thirdeye::VERSION
9
+ spec.authors = ["Drew Fradette"]
10
+ spec.email = ["drew.fradette@gmail.com"]
11
+ spec.description = 'A ruby framework for scripting i3wm'
12
+ spec.summary = 'A ruby framework for scripting i3wm'
13
+ spec.homepage = "https://github.com/drewfradette/i3-thirdeye"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "pry"
24
+
25
+ spec.add_dependency 'i3-ipc'
26
+ end
metadata ADDED
@@ -0,0 +1,122 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: thirdeye
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Drew Fradette
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-11-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: i3-ipc
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: A ruby framework for scripting i3wm
70
+ email:
71
+ - drew.fradette@gmail.com
72
+ executables:
73
+ - i3-window-jump
74
+ - i3-windows
75
+ - i3-workspace-jump
76
+ - i3-workspace-swap
77
+ - i3-workspaces
78
+ extensions: []
79
+ extra_rdoc_files: []
80
+ files:
81
+ - .gitignore
82
+ - Gemfile
83
+ - LICENSE.txt
84
+ - README.md
85
+ - Rakefile
86
+ - bin/i3-window-jump
87
+ - bin/i3-windows
88
+ - bin/i3-workspace-jump
89
+ - bin/i3-workspace-swap
90
+ - bin/i3-workspaces
91
+ - lib/thirdeye.rb
92
+ - lib/thirdeye/base.rb
93
+ - lib/thirdeye/output.rb
94
+ - lib/thirdeye/version.rb
95
+ - lib/thirdeye/window.rb
96
+ - lib/thirdeye/workspace.rb
97
+ - thirdeye.gemspec
98
+ homepage: https://github.com/drewfradette/i3-thirdeye
99
+ licenses:
100
+ - MIT
101
+ metadata: {}
102
+ post_install_message:
103
+ rdoc_options: []
104
+ require_paths:
105
+ - lib
106
+ required_ruby_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ required_rubygems_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - '>='
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ requirements: []
117
+ rubyforge_project:
118
+ rubygems_version: 2.1.10
119
+ signing_key:
120
+ specification_version: 4
121
+ summary: A ruby framework for scripting i3wm
122
+ test_files: []