monitor_manager 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -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,5 @@
1
+ source "http://rubygems.org"
2
+
3
+
4
+ gem "ruby-wmctrl"
5
+ gem "sinatra"
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Guillermo Álvarez
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.
data/README ADDED
@@ -0,0 +1,22 @@
1
+
2
+
3
+ MONITOR MANAGER
4
+ ===============
5
+
6
+ Monitor Manager is a web interface for the window manager.
7
+
8
+ This app was develop to controll wall panels remotly, and make it easy to play arround it
9
+
10
+
11
+ USAGE
12
+ =====
13
+
14
+ monitor_manager -p 8080
15
+
16
+
17
+ INSTALL
18
+ =======
19
+
20
+ apt-get install libx11-dev libglib2.0-dev libxmu-dev
21
+ gem install monitor_manager
22
+
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # MonitorManager
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'monitor_manager'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install monitor_manager
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 'Added some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env ruby
2
+
3
+
4
+ pid = nil
5
+ Signal.trap("INT") do
6
+ if pid
7
+ Process.kill("INT", pid)
8
+ Process.kill("TERM", pid)
9
+ Process.wait pid
10
+ end
11
+ exit
12
+ end
13
+
14
+ loop do
15
+ pid = fork do
16
+ file = File.dirname(File.dirname($0)) + "/lib/monitor_manager/app.rb"
17
+ require 'monitor_manager/app'
18
+ MonitorManager.run!
19
+
20
+ end
21
+ Process.wait pid
22
+ sleep 1
23
+ end
24
+
25
+
@@ -0,0 +1,85 @@
1
+ require 'sinatra/base'
2
+ require 'wmctrl'
3
+ require 'cgi'
4
+
5
+
6
+ WM = WMCtrl.new
7
+ CHILDS = []
8
+
9
+ class MonitorManager < Sinatra::Base
10
+ settings.root = File.dirname(File.dirname(File.dirname(__FILE__)))
11
+ set :environment, :production
12
+
13
+
14
+ get '/' do
15
+ @desktops = WM.list_desktops rescue []
16
+ @windows = WM.list_windows(true) rescue []
17
+ @windows.each do |window|
18
+ window[:comm] = File.read("/proc/#{window[:pid]}/comm")
19
+ window[:cmdline] = File.read("/proc/#{window[:pid]}/cmdline")
20
+ window[:fullscreen] = (window[:state] || []).include?("_NET_WM_STATE_FULLSCREEN")
21
+ end
22
+
23
+ erb :home
24
+ end
25
+
26
+ post '/activate/:id' do
27
+ windows = WM.list_windows rescue []
28
+ window = windows.find{|window| window[:id] == params[:id].to_i}
29
+ WM.switch_desktop(window[:desktop]) rescue nil if window
30
+ WM.action_window(params[:id].to_i) rescue nil
31
+ redirect back
32
+ end
33
+
34
+ post '/close/:id' do
35
+ WM.action_window(params[:id].to_i, :close) rescue nil
36
+ redirect back
37
+ end
38
+
39
+ post '/fullscreen/:id' do
40
+ WM.action_window(params[:id].to_i,:change_state, "toggle", "fullscreen") rescue nil
41
+ redirect back
42
+ end
43
+
44
+ post '/activate_desktop/:id' do
45
+ WM.switch_desktop(params[:id].to_i) rescue nil
46
+ redirect back
47
+ end
48
+
49
+ post '/activate_desktop' do
50
+ WM.switch_desktop(params[:id].to_i) rescue nil
51
+ redirect back
52
+ end
53
+
54
+ post '/command' do
55
+ CHILDS << fork do
56
+ exec params[:command]
57
+ end
58
+ redirect back
59
+ end
60
+
61
+
62
+ post '/browse' do
63
+ CHILDS << fork do
64
+ url = params[:url]
65
+ url = "http://www.youtube.com/v/#{$1}?autoplay=1&loop=1" if url =~ /youtube\.com\/.*v=([^\?]+)/
66
+ exec %{google-chrome --kiosk "#{url}"}
67
+ end
68
+
69
+ redirect back
70
+ end
71
+
72
+
73
+ if ARGV.any?
74
+ require 'optparse'
75
+ OptionParser.new { |op|
76
+ op.on('-p port', 'set the port (default is 4567)') { |val| set :port, Integer(val) }
77
+ op.on('-o addr', 'set the host (default is 0.0.0.0)') { |val| set :bind, val }
78
+ op.on('-e env', 'set the environment (default is development)') { |val| set :environment, val.to_sym }
79
+ op.on('-s server', 'specify rack server/handler (default is thin)') { |val| set :server, val }
80
+ op.on('-x', 'turn on the mutex lock (default is off)') { set :lock, true }
81
+ }.parse!(ARGV.dup)
82
+ end
83
+
84
+ end
85
+ require 'monitor_manager/version'
@@ -0,0 +1,3 @@
1
+ class MonitorManager
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,17 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/monitor_manager/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Guillermo Álvarez"]
6
+ gem.email = ["guillermo@cientifico.net"]
7
+ gem.description = %q{Monitor Manager}
8
+ gem.summary = %q{Control the window manager from a web interface}
9
+ gem.homepage = ""
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "monitor_manager"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = MonitorManager::VERSION
17
+ end
@@ -0,0 +1,18 @@
1
+
2
+ tr.active {
3
+ background: #5BB75B !important;
4
+ }
5
+
6
+ tr.active td {
7
+ background: #5BB75B !important;
8
+ }
9
+
10
+ form.action {
11
+ display: inline-block;
12
+ margin: 0;
13
+ }
14
+
15
+ .desktop-list {
16
+ text-align: center;
17
+ }
18
+