repozish 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/repozish +119 -0
- data/lib/repozish.rb +0 -0
- metadata +66 -0
data/bin/repozish
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
require 'fileutils'
|
5
|
+
require 'yaml'
|
6
|
+
|
7
|
+
DOLLA_ZERO = File.basename $0
|
8
|
+
DOC_RUN_CONTROL = "~/.#{DOLLA_ZERO}rc"
|
9
|
+
RUN_CONTROL = File.expand_path DOC_RUN_CONTROL
|
10
|
+
USAGE = """
|
11
|
+
`#{DOLLA_ZERO}(1)` -- mac os x window layout utility
|
12
|
+
===============================================
|
13
|
+
|
14
|
+
## synopsis
|
15
|
+
|
16
|
+
#{DOLLA_ZERO} [-hg] [-a <app1>,<app2>,...] [<profile>]
|
17
|
+
|
18
|
+
## description
|
19
|
+
|
20
|
+
nerd alert! `#{DOLLA_ZERO}(1)` repositions the windows of your applications to
|
21
|
+
your preferred layout.
|
22
|
+
|
23
|
+
## getting the positions and sizes of windows:
|
24
|
+
|
25
|
+
executing the following:
|
26
|
+
|
27
|
+
#{DOLLA_ZERO} -g -a Safari,Terminal,Twitter,MacVim
|
28
|
+
|
29
|
+
will get the current positions and sizes of the listed applications, and write
|
30
|
+
them to your `#{DOC_RUN_CONTROL}` file.
|
31
|
+
|
32
|
+
## setting the positions and sizes of windows:
|
33
|
+
|
34
|
+
executing the following:
|
35
|
+
|
36
|
+
#{DOLLA_ZERO}
|
37
|
+
|
38
|
+
will read the positions of the files in `#{DOC_RUN_CONTROL}` and position and
|
39
|
+
size the apps accordingly.
|
40
|
+
|
41
|
+
## other notes
|
42
|
+
|
43
|
+
`#{DOLLA_ZERO}(1)` only operates on the front window of applications. it may
|
44
|
+
not work as desired with applications that have more than one window.
|
45
|
+
|
46
|
+
`#{DOLLA_ZERO}(1)` will first use the application list passed in with the '-a'
|
47
|
+
flag. if the '-a' flag isn't given, it will use the apps listed in
|
48
|
+
`#{DOC_RUN_CONTROL}`. otherwise it'll just like crash or something.
|
49
|
+
|
50
|
+
you may optionally specify a profile name. for instance if you want a different
|
51
|
+
window layout when you're doing a preso or some crap:
|
52
|
+
|
53
|
+
#{DOLLA_ZERO} -ga Safari,Terminal,Twitter,MacVim alt_layout
|
54
|
+
#{DOLLA_ZERO} alt_layout
|
55
|
+
|
56
|
+
when you omit the profile, `#{DOLLA_ZERO}(1)` picks a default profile name
|
57
|
+
that's specific to the monitor configuration. so as long as you've set up
|
58
|
+
profiles for the monitors that are currently plugged in, you can just run:
|
59
|
+
|
60
|
+
#{DOLLA_ZERO}
|
61
|
+
|
62
|
+
and it will choose the appropriate layout for the attached screens.
|
63
|
+
|
64
|
+
## options
|
65
|
+
|
66
|
+
"""
|
67
|
+
|
68
|
+
def set_dims(app, dims)
|
69
|
+
`osascript -e 'tell application "#{app}" to set the bounds of the front window to {#{dims.join ', '}}'`
|
70
|
+
end
|
71
|
+
|
72
|
+
def get_dims(app)
|
73
|
+
`osascript -e 'tell application "#{app}" to get the bounds of the front window'`
|
74
|
+
end
|
75
|
+
|
76
|
+
def displays()
|
77
|
+
display_data = YAML.load(`system_profiler SPDisplaysDataType`)
|
78
|
+
display_data['Graphics/Displays'].map do |d|
|
79
|
+
monitors = d[1]['Displays']
|
80
|
+
if monitors && monitors.length
|
81
|
+
monitors.map{|m| m[1]['Resolution']}.join('').gsub(' ', '')
|
82
|
+
end
|
83
|
+
end.find_all{|d| d}.join "_"
|
84
|
+
end
|
85
|
+
|
86
|
+
mode = 'set'
|
87
|
+
apps = nil
|
88
|
+
|
89
|
+
o = OptionParser.new do |o|
|
90
|
+
o.on('-a', '--apps app1,app2', 'apps to size and reposition') do |apps|
|
91
|
+
apps = apps.split ','
|
92
|
+
end
|
93
|
+
o.on('-g', '--get', "'get' mode -- just write the apps' positions") do
|
94
|
+
mode = 'get'
|
95
|
+
end
|
96
|
+
o.on('-h', '--help', 'print this help message') do
|
97
|
+
puts USAGE + o.summarize.join
|
98
|
+
exit
|
99
|
+
end
|
100
|
+
o.parse! # oh, parse!
|
101
|
+
end
|
102
|
+
|
103
|
+
profile = ARGV[0] || "_default" + displays
|
104
|
+
|
105
|
+
rc = File.exists?(RUN_CONTROL)? YAML::load_file(RUN_CONTROL) : {}
|
106
|
+
rc[profile] = {} unless rc[profile]
|
107
|
+
|
108
|
+
apps = rc[profile].keys unless apps
|
109
|
+
|
110
|
+
apps.each do |app|
|
111
|
+
if mode == 'get'
|
112
|
+
rc[profile][app] = get_dims(app).split(',').map {|s| s.to_i}
|
113
|
+
else
|
114
|
+
set_dims app, rc[profile][app] if rc[profile][app]
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
File.open(RUN_CONTROL, 'w') { |f| f.write(rc.to_yaml) }
|
119
|
+
|
data/lib/repozish.rb
ADDED
File without changes
|
metadata
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: repozish
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 31
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
version: 0.0.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Aaron Stacy
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2012-12-10 00:00:00 Z
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: "\n repozish allows you to move apps where you want them, save their sizes and\n positions to a profile, and then reposition everything to your desired\n layout. profiles by default are specific to the screens attached to your\n computer.\n "
|
22
|
+
email: aaron.r.stacy@gmail.com
|
23
|
+
executables:
|
24
|
+
- repozish
|
25
|
+
extensions: []
|
26
|
+
|
27
|
+
extra_rdoc_files: []
|
28
|
+
|
29
|
+
files:
|
30
|
+
- bin/repozish
|
31
|
+
- lib/repozish.rb
|
32
|
+
homepage: https://github.com/aaronj1335/repozish
|
33
|
+
licenses:
|
34
|
+
- MIT
|
35
|
+
post_install_message:
|
36
|
+
rdoc_options: []
|
37
|
+
|
38
|
+
require_paths:
|
39
|
+
- lib
|
40
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 3
|
46
|
+
segments:
|
47
|
+
- 0
|
48
|
+
version: "0"
|
49
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
hash: 3
|
55
|
+
segments:
|
56
|
+
- 0
|
57
|
+
version: "0"
|
58
|
+
requirements: []
|
59
|
+
|
60
|
+
rubyforge_project:
|
61
|
+
rubygems_version: 1.8.24
|
62
|
+
signing_key:
|
63
|
+
specification_version: 3
|
64
|
+
summary: size and reposition windows in mac os x based on saved profiles
|
65
|
+
test_files: []
|
66
|
+
|