conquer-dzen 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/lib/conquer/dzen.rb +2 -0
- data/lib/conquer/dzen/interaction.rb +23 -0
- data/lib/conquer/dzen/interaction/callback_listener.rb +22 -0
- data/lib/conquer/dzen/interaction/tooltip_listener.rb +38 -0
- data/lib/conquer/dzen/positioning.rb +10 -2
- data/lib/conquer/dzen/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e78581b0223c20b705c7fc522b81781d1850677
|
4
|
+
data.tar.gz: 6db26158a7cf9aeee8644bf81d8dc70fc3b4acf7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a53f3df751e5ec2bb3d3ccb31c9396f8b1b27ee7e33ab8d15646c9b46ee7c958dc1a8ead65f971abbf557f3095357f8201845c2f1da5ac142fa448ae4dedcc1d
|
7
|
+
data.tar.gz: f88fa0b2dd9a82e956922ee2747e725ef3741cf80c5ab8f72c2bac532769b65457915d7336709bb06944ede49b386e4a3709e952fb20c3436a608c4e9fbaf8eb
|
data/.gitignore
CHANGED
data/lib/conquer/dzen.rb
CHANGED
@@ -3,11 +3,13 @@ require 'conquer/dzen/version'
|
|
3
3
|
require 'conquer/dzen/color'
|
4
4
|
require 'conquer/dzen/graphics'
|
5
5
|
require 'conquer/dzen/positioning'
|
6
|
+
require 'conquer/dzen/interaction'
|
6
7
|
|
7
8
|
module Conquer
|
8
9
|
module Helpers
|
9
10
|
extend Dzen::Color
|
10
11
|
extend Dzen::Graphics
|
11
12
|
extend Dzen::Positioning
|
13
|
+
extend Dzen::Interaction
|
12
14
|
end
|
13
15
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'conquer/dzen/interaction/callback_listener'
|
2
|
+
require 'conquer/dzen/interaction/tooltip_listener'
|
3
|
+
|
4
|
+
module Conquer
|
5
|
+
module Dzen
|
6
|
+
module Interaction
|
7
|
+
def show_tooltip(*args)
|
8
|
+
Celluloid.publish('tooltip', *args)
|
9
|
+
end
|
10
|
+
|
11
|
+
def button(button, callback, *args)
|
12
|
+
rpc_call = { method: :event, params: ['button', callback, *args] }
|
13
|
+
command = "echo -n '#{rpc_call.to_json}' | socat stdin '#{RPC_SOCKET}'"
|
14
|
+
"^ca(#{button}, #{command})#{yield}^ca()"
|
15
|
+
end
|
16
|
+
|
17
|
+
Conquer.on_startup do
|
18
|
+
CallbackListener.supervise
|
19
|
+
TooltipListener.supervise
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'celluloid/current'
|
2
|
+
|
3
|
+
module Conquer
|
4
|
+
module Dzen
|
5
|
+
module Interaction
|
6
|
+
class CallbackListener
|
7
|
+
include Celluloid
|
8
|
+
include Celluloid::Notifications
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
subscribe('button', :run_callback)
|
12
|
+
end
|
13
|
+
|
14
|
+
def run_callback(_, callback, *args)
|
15
|
+
Celluloid::Future.new do
|
16
|
+
Helpers.send(callback, *args)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'celluloid/current'
|
2
|
+
|
3
|
+
module Conquer
|
4
|
+
module Dzen
|
5
|
+
module Interaction
|
6
|
+
class TooltipListener
|
7
|
+
include Celluloid
|
8
|
+
include Celluloid::Notifications
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
@current_tooltip = nil
|
12
|
+
subscribe('tooltip', :show_tooltip)
|
13
|
+
end
|
14
|
+
|
15
|
+
def show_tooltip(_, title, text, width = 150)
|
16
|
+
Process.kill('TERM', @current_tooltip) if @current_tooltip
|
17
|
+
|
18
|
+
lines = text.lines.size
|
19
|
+
mouse = `xdotool getmouselocation`.match(
|
20
|
+
/^x:(?<x>\d+) y:(?<y>\d+) screen:(?<screen>\d+)/
|
21
|
+
)
|
22
|
+
dzen_command = [
|
23
|
+
'dzen2', '-x', mouse[:x], '-y', mouse[:y], '-l', lines.to_s,
|
24
|
+
'-w', width.to_s, '-e', 'onstart=uncollapse;button1=exit',
|
25
|
+
'-xs', mouse[:screen]
|
26
|
+
]
|
27
|
+
pipe = ::IO.popen(dzen_command, 'w+')
|
28
|
+
@current_tooltip = pipe.pid
|
29
|
+
|
30
|
+
pipe.puts title
|
31
|
+
pipe.puts text
|
32
|
+
pipe.flush
|
33
|
+
pipe.pid
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -1,6 +1,14 @@
|
|
1
1
|
module Conquer
|
2
2
|
module Dzen
|
3
3
|
module Positioning
|
4
|
+
def ignore_bg(state = :on)
|
5
|
+
if block_given?
|
6
|
+
"^ib(1)#{yield}^ib(0)"
|
7
|
+
else
|
8
|
+
"^ib(#{state == :on ? 0 : 1})"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
4
12
|
def lock_x(options = {})
|
5
13
|
if block_given?
|
6
14
|
"#{'^ib(1)' if options[:ignore_bg]}" \
|
@@ -15,8 +23,8 @@ module Conquer
|
|
15
23
|
'^p(_UNLOCK_X)'
|
16
24
|
end
|
17
25
|
|
18
|
-
def shift(x, y)
|
19
|
-
return "#{shift(x, y)}#{yield}#{shift(-x
|
26
|
+
def shift(x, y = 0)
|
27
|
+
return "#{shift(x, y)}#{yield}#{shift(-x)}^p()" if block_given?
|
20
28
|
x = x.round
|
21
29
|
y = y.round
|
22
30
|
x = nil if x == 0
|
data/lib/conquer/dzen/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: conquer-dzen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joakim Reinert
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06-
|
11
|
+
date: 2016-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -93,6 +93,9 @@ files:
|
|
93
93
|
- lib/conquer/dzen/graphics/progress_bar.rb
|
94
94
|
- lib/conquer/dzen/graphics/rectangle.rb
|
95
95
|
- lib/conquer/dzen/graphics/rectangle_outline.rb
|
96
|
+
- lib/conquer/dzen/interaction.rb
|
97
|
+
- lib/conquer/dzen/interaction/callback_listener.rb
|
98
|
+
- lib/conquer/dzen/interaction/tooltip_listener.rb
|
96
99
|
- lib/conquer/dzen/positioning.rb
|
97
100
|
- lib/conquer/dzen/version.rb
|
98
101
|
homepage: https://github.com/jreinert/conquer-dzen
|