i3-ipc 0.1.3 → 0.1.4

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.
@@ -58,11 +58,11 @@ There are 3 arguments passed to the block:
58
58
  To send data to the socket, you need to use `em.send_data`.
59
59
  * `type` is the received message type.
60
60
  This could be one of
61
- * MESSAGE_REPLY_COMMAND
62
- * MESSAGE_REPLY_GET_WORKSPACES
63
- * MESSAGE_REPLY_SUBSCRIBE
64
- * MESSAGE_REPLY_GET_OUTPUTS
65
- * EVENT_WORKSPACE
61
+ * MESSAGE\_REPLY\_COMMAND
62
+ * MESSAGE\_REPLY\_GET\_WORKSPACES
63
+ * MESSAGE\_REPLY\_SUBSCRIBE
64
+ * MESSAGE\_REPLY\_GET\_OUTPUTS
65
+ * EVENT\_WORKSPACE
66
66
  * `data` is the received data, already parsed.
67
67
 
68
68
  For example you can use the following code to get the actual focused screen:
data/Rakefile CHANGED
@@ -6,7 +6,7 @@ begin
6
6
  task :gem => :package
7
7
 
8
8
  desc "Push a new version to Gemcutter and publish docs."
9
- task :publish => :gemcutter do
9
+ task :publish => [:test, :gemcutter] do
10
10
  require File.dirname(__FILE__) + '/lib/i3-ipc/version'
11
11
 
12
12
  sh "git tag v#{I3::Version}"
@@ -8,7 +8,7 @@ require 'i3-ipc/version'
8
8
  module I3
9
9
  class IPC
10
10
  MAGIC_STRING = "i3-ipc"
11
- SOCKET_PATH = "/tmp/i3-ipc.sock"
11
+ SOCKET_PATH = File.expand_path("~/.i3/ipc.sock")
12
12
 
13
13
  MESSAGE_TYPE_COMMAND = 0
14
14
  MESSAGE_TYPE_GET_WORKSPACES = 1
@@ -4,15 +4,16 @@ require 'pp'
4
4
  module I3
5
5
  module Runner
6
6
  extend self
7
+ OUTPUT = $stdout
7
8
 
8
9
  def format_output(object, output)
9
10
  if output == :pretty_print
10
- pp object
11
+ PP.pp(object, OUTPUT)
11
12
  elsif output == :json
12
13
  require 'json'
13
- puts object.to_json
14
+ OUTPUT.puts object.to_json
14
15
  else
15
- p object
16
+ OUTPUT.puts object.inspect
16
17
  end
17
18
  end
18
19
 
@@ -29,7 +30,7 @@ module I3
29
30
  end
30
31
 
31
32
  def execute(*args)
32
- socket_file = '/tmp/i3-ipc.sock'
33
+ socket_file = File.expand_path('~/.i3/ipc.sock')
33
34
  type = 0
34
35
  quiet = false
35
36
  output = :default
@@ -37,9 +38,9 @@ module I3
37
38
  opts = OptionParser.new do |opts|
38
39
  opts.banner = "Usage: i3-ipc [options] [message]"
39
40
 
40
- s_desc = 'Set socket file, defaults to /tmp/i3-ipc.sock'
41
- opts.on('-s', '--socket', s_desc) do |s|
42
- socket_file = s
41
+ s_desc = 'Set socket file, defaults to ~/.i3/ipc.sock'
42
+ opts.on('-s SOCKET', '--socket SOCKET', s_desc) do |s|
43
+ socket_file = File.expand_path(s)
43
44
  end
44
45
 
45
46
  t_desc = 'Set type, 0 = command, 1 = workspace list, 2 = subscribe to workspace event, 3 = output list, default: 0'
@@ -64,7 +65,7 @@ module I3
64
65
  end
65
66
 
66
67
  opts.on('-h', '--help', 'Display this screen') do
67
- puts opts
68
+ OUTPUT.puts opts
68
69
  exit
69
70
  end
70
71
  end
@@ -80,8 +81,7 @@ module I3
80
81
  end
81
82
 
82
83
  payload = args.shift
83
-
84
- puts s.command(payload) unless quiet
84
+ OUTPUT.puts s.command(payload).inspect unless quiet
85
85
  when I3::IPC::MESSAGE_TYPE_GET_WORKSPACES
86
86
  format_output s.get_workspaces, output
87
87
  when I3::IPC::MESSAGE_REPLY_SUBSCRIBE
@@ -1,3 +1,3 @@
1
1
  module I3
2
- Version = '0.1.3'
2
+ Version = '0.1.4'
3
3
  end
@@ -1,7 +1,7 @@
1
- .\" generated with Ronn/v0.4.1
1
+ .\" generated with Ronn/v0.5
2
2
  .\" http://github.com/rtomayko/ronn/
3
3
  .
4
- .TH "I3\-IPC" "1" "March 2010" "badboy" "i3-ipc Manual"
4
+ .TH "I3\-IPC" "1" "April 2010" "badboy" "i3-ipc Manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBi3\-ipc\fR \-\- inter\-process communication with i3
@@ -25,7 +25,16 @@ Currently implemented message types of i3 are the following:
25
25
  .TP
26
26
  \fB1 (GET_WORKSPACES)\fR
27
27
  Gets the current workspaces.
28
- The reply will be a JSON\-encoded list of workspaces (see the reply section).
28
+ The reply will be a JSON\-encoded list of workspaces.
29
+ .
30
+ .TP
31
+ \fB2 (SUBSCRIBE)\fR
32
+ Subscribes your connection to the \fBworkspace\fR event.
33
+ .
34
+ .TP
35
+ \fB3 (GET_OUTPUTS)\fR
36
+ Gets the current outputs.
37
+ The reply will be a JSON\-encoded list of outputs.
29
38
  .
30
39
  .SH "OPTIONS"
31
40
  \fBi3\-ipc\fR's default mode of operation is to send the command (type 0) specified on the command line.
@@ -35,11 +44,12 @@ These options can be used to change this behavior:
35
44
  .
36
45
  .TP
37
46
  \fB\-s\fR, \fB\-\-socket\fR
38
- Set the socket file, defaults to /tmp/i3\-ipc.sock
47
+ Set the socket file, defaults to ~/.i3/ipc.sock
39
48
  .
40
49
  .TP
41
50
  \fB\-t\fR, \fB\-\-type\fR
42
- Set the type. Passing a type of 0 is the default and will send the specified command, type 1 gets the current workspace list.
51
+ Set the type. Passing a type of 0 is the default and will send the specified command, type 1 gets the current workspace list,
52
+ type 2 subscribes to the workspace stream, type 3 gets the current output list.
43
53
  .
44
54
  .TP
45
55
  \fB\-p\fR, \fB\-\-pretty\-print\fR
@@ -71,9 +81,10 @@ Display this man page.
71
81
  .SH "EXAMPLES"
72
82
  .
73
83
  .nf
84
+
74
85
  $ i3\-ipc \-t 1
75
- $ i3\-ipc \-t 1 \-p
76
- $ i3\-ipc \-t 1 \-j
86
+ $ i3\-ipc \-t 2 \-p
87
+ $ i3\-ipc \-t 3 \-j
77
88
  $ i3\-ipc "exec xterm"
78
89
  .
79
90
  .fi
@@ -2,7 +2,7 @@
2
2
  <html>
3
3
  <head>
4
4
  <meta http-equiv='content-type' value='text/html;charset=utf8'>
5
- <meta name='generator' value='Ronn/v0.4.1'>
5
+ <meta name='generator' value='Ronn/v0.5'>
6
6
  <title>i3-ipc(1) -- inter-process communication with i3</title>
7
7
  <style type='text/css'>
8
8
  body {margin:0}
@@ -81,7 +81,10 @@
81
81
  The command will be executed directly after receiving it.
82
82
  The reply will be always {"succes":true} for now.</dd>
83
83
  <dt><code>1 (GET_WORKSPACES)</code></dt><dd> Gets the current workspaces.
84
- The reply will be a JSON-encoded list of workspaces (see the reply section).</dd>
84
+ The reply will be a JSON-encoded list of workspaces.</dd>
85
+ <dt><code>2 (SUBSCRIBE)</code></dt><dd> Subscribes your connection to the <code>workspace</code> event.</dd>
86
+ <dt><code>3 (GET_OUTPUTS)</code></dt><dd> Gets the current outputs.
87
+ The reply will be a JSON-encoded list of outputs.</dd>
85
88
  </dl>
86
89
 
87
90
 
@@ -92,8 +95,9 @@
92
95
  <p>These options can be used to change this behavior:</p>
93
96
 
94
97
  <dl>
95
- <dt><code>-s</code>, <code>--socket</code></dt><dd><p>Set the socket file, defaults to /tmp/i3-ipc.sock</p></dd>
96
- <dt><code>-t</code>, <code>--type</code></dt><dd><p>Set the type. Passing a type of 0 is the default and will send the specified command, type 1 gets the current workspace list.</p></dd>
98
+ <dt><code>-s</code>, <code>--socket</code></dt><dd><p>Set the socket file, defaults to ~/.i3/ipc.sock</p></dd>
99
+ <dt><code>-t</code>, <code>--type</code></dt><dd><p>Set the type. Passing a type of 0 is the default and will send the specified command, type 1 gets the current workspace list,
100
+ type 2 subscribes to the workspace stream, type 3 gets the current output list.</p></dd>
97
101
  <dt><code>-p</code>, <code>--pretty-print</code></dt><dd><p>This will pretty print the received reply. Useful for the workspace list.</p></dd>
98
102
  <dt><code>-j</code>, <code>--json</code></dt><dd><p>This will print the received reply as raw json-encoded data. Useful to pass to another script.</p></dd>
99
103
  <dt><code>-q</code>, <code>--quiet</code></dt><dd><p>Turn off the output. Useful for command mode.</p></dd>
@@ -112,8 +116,8 @@
112
116
  <h2>EXAMPLES</h2>
113
117
 
114
118
  <pre><code>$ i3-ipc -t 1
115
- $ i3-ipc -t 1 -p
116
- $ i3-ipc -t 1 -j
119
+ $ i3-ipc -t 2 -p
120
+ $ i3-ipc -t 3 -j
117
121
  $ i3-ipc "exec xterm"
118
122
  </code></pre>
119
123
 
@@ -132,7 +136,7 @@ $ i3-ipc "exec xterm"
132
136
 
133
137
  <ol class='foot man'>
134
138
  <li class='tl'>badboy</li>
135
- <li class='tc'>March 2010</li>
139
+ <li class='tc'>April 2010</li>
136
140
  <li class='tr'>i3-ipc(1)</li>
137
141
  </ol>
138
142
 
@@ -14,12 +14,18 @@ Currently implemented message types of i3 are the following:
14
14
 
15
15
  * `0 (COMMAND)`:
16
16
  The payload of the message is a command for i3
17
- (like the commands you can bind to keys in the configuration file)
17
+ (like the commands you can bind to keys in the configuration file)
18
18
  The command will be executed directly after receiving it.
19
19
  The reply will be always {"succes":true} for now.
20
20
  * `1 (GET_WORKSPACES)`:
21
- Gets the current workspaces.
22
- The reply will be a JSON-encoded list of workspaces (see the reply section).
21
+ Gets the current workspaces.
22
+ The reply will be a JSON-encoded list of workspaces.
23
+ * `2 (SUBSCRIBE)`:
24
+ Subscribes your connection to the `workspace` event.
25
+ * `3 (GET_OUTPUTS)`:
26
+ Gets the current outputs.
27
+ The reply will be a JSON-encoded list of outputs.
28
+
23
29
 
24
30
  ## OPTIONS
25
31
 
@@ -28,10 +34,11 @@ Currently implemented message types of i3 are the following:
28
34
  These options can be used to change this behavior:
29
35
 
30
36
  * `-s`, `--socket`:
31
- Set the socket file, defaults to /tmp/i3-ipc.sock
37
+ Set the socket file, defaults to ~/.i3/ipc.sock
32
38
 
33
39
  * `-t`, `--type`:
34
- Set the type. Passing a type of 0 is the default and will send the specified command, type 1 gets the current workspace list.
40
+ Set the type. Passing a type of 0 is the default and will send the specified command, type 1 gets the current workspace list,
41
+ type 2 subscribes to the workspace stream, type 3 gets the current output list.
35
42
 
36
43
  * `-p`, `--pretty-print`:
37
44
  This will pretty print the received reply. Useful for the workspace list.
@@ -56,8 +63,8 @@ You may additionally ask for help:
56
63
  ## EXAMPLES
57
64
 
58
65
  $ i3-ipc -t 1
59
- $ i3-ipc -t 1 -p
60
- $ i3-ipc -t 1 -j
66
+ $ i3-ipc -t 2 -p
67
+ $ i3-ipc -t 3 -j
61
68
  $ i3-ipc "exec xterm"
62
69
 
63
70
  ## BUGS
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 3
9
- version: 0.1.3
8
+ - 4
9
+ version: 0.1.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jan-Erik Rediger
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-04-08 00:00:00 +02:00
17
+ date: 2010-04-16 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -43,7 +43,7 @@ dependencies:
43
43
  - 10
44
44
  - 3
45
45
  version: 2.10.3
46
- type: :runtime
46
+ type: :development
47
47
  version_requirements: *id002
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: mocha
@@ -57,7 +57,7 @@ dependencies:
57
57
  - 9
58
58
  - 8
59
59
  version: 0.9.8
60
- type: :runtime
60
+ type: :development
61
61
  version_requirements: *id003
62
62
  description: " uses the ipc socket of i3 to send commands or get information directly from the window manager. Useful for scripting the window manager.'\n"
63
63
  email: badboy@archlinux.us