dmenu 0.0.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +1 -1
- data/lib/dmenu.rb +37 -18
- metadata +23 -42
data/LICENSE
CHANGED
data/lib/dmenu.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require "shellwords"
|
2
1
|
require "dmenu/item"
|
3
2
|
|
4
3
|
# @example A simple menu
|
@@ -7,7 +6,7 @@ require "dmenu/item"
|
|
7
6
|
#
|
8
7
|
# menu.run # this will return a Dmenu::Item, according to what the user selected.
|
9
8
|
class Dmenu
|
10
|
-
VERSION = "0.0
|
9
|
+
VERSION = "1.0.0"
|
11
10
|
|
12
11
|
# @return [Array<#to_s, Item>] Items to display in the menu. Items
|
13
12
|
# that are not an instance of the {Item} class will transparently
|
@@ -50,8 +49,6 @@ class Dmenu
|
|
50
49
|
# @return [Item, nil] Returns the selected item or nil, if the user
|
51
50
|
# didn't make any selection (i.e. pressed ESC)
|
52
51
|
def run
|
53
|
-
command = "dmenu #{args}"
|
54
|
-
puts command
|
55
52
|
pipe = IO.popen(command, "w+")
|
56
53
|
|
57
54
|
items = @items.map {|item|
|
@@ -74,6 +71,7 @@ class Dmenu
|
|
74
71
|
return nil
|
75
72
|
end
|
76
73
|
|
74
|
+
value.chomp!
|
77
75
|
selection = items.find {|item|
|
78
76
|
item.key.to_s == value
|
79
77
|
}
|
@@ -81,19 +79,40 @@ class Dmenu
|
|
81
79
|
return selection
|
82
80
|
end
|
83
81
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
args
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
82
|
+
private
|
83
|
+
|
84
|
+
def command
|
85
|
+
args = ["dmenu"]
|
86
|
+
|
87
|
+
if @position == :bottom
|
88
|
+
args << "-b"
|
89
|
+
end
|
90
|
+
|
91
|
+
if @case_insensitive
|
92
|
+
args << "-i"
|
93
|
+
end
|
94
|
+
|
95
|
+
if @lines > 1
|
96
|
+
args << "-l"
|
97
|
+
args << lines.to_s
|
98
|
+
end
|
99
|
+
|
100
|
+
h = {
|
101
|
+
"fn" => @font,
|
102
|
+
"nb" => @background,
|
103
|
+
"nf" => @foreground,
|
104
|
+
"sb" => @selected_background,
|
105
|
+
"sf" => @selected_foreground,
|
106
|
+
"p" => @prompt,
|
107
|
+
}
|
108
|
+
|
109
|
+
h.each do |flag, value|
|
110
|
+
if value
|
111
|
+
args << "-#{flag}"
|
112
|
+
args << value
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
return args
|
97
117
|
end
|
98
|
-
private :args
|
99
118
|
end
|
metadata
CHANGED
@@ -1,69 +1,50 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: dmenu
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 0
|
8
|
-
- 2
|
9
|
-
version: 0.0.2
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
10
6
|
platform: ruby
|
11
|
-
authors:
|
7
|
+
authors:
|
12
8
|
- Dominik Honnef
|
13
9
|
autorequire:
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
|
-
|
17
|
-
date: 2010-10-03 00:00:00 +02:00
|
18
|
-
default_executable:
|
12
|
+
date: 2014-05-10 00:00:00.000000000 Z
|
19
13
|
dependencies: []
|
20
|
-
|
21
14
|
description: A Ruby OOP wrapper around dmenu.
|
22
15
|
email: dominikh@fork-bomb.org
|
23
16
|
executables: []
|
24
|
-
|
25
17
|
extensions: []
|
26
|
-
|
27
18
|
extra_rdoc_files: []
|
28
|
-
|
29
|
-
files:
|
30
|
-
- lib/dmenu/item.rb
|
19
|
+
files:
|
31
20
|
- lib/dmenu.rb
|
21
|
+
- lib/dmenu/item.rb
|
32
22
|
- README
|
33
23
|
- LICENSE
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
24
|
+
homepage:
|
25
|
+
licenses:
|
26
|
+
- BSD
|
38
27
|
post_install_message:
|
39
28
|
rdoc_options: []
|
40
|
-
|
41
|
-
require_paths:
|
29
|
+
require_paths:
|
42
30
|
- lib
|
43
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
31
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
44
32
|
none: false
|
45
|
-
requirements:
|
46
|
-
- -
|
47
|
-
- !ruby/object:Gem::Version
|
48
|
-
segments:
|
49
|
-
- 1
|
50
|
-
- 9
|
51
|
-
- 1
|
33
|
+
requirements:
|
34
|
+
- - ! '>='
|
35
|
+
- !ruby/object:Gem::Version
|
52
36
|
version: 1.9.1
|
53
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
37
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
38
|
none: false
|
55
|
-
requirements:
|
56
|
-
- -
|
57
|
-
- !ruby/object:Gem::Version
|
58
|
-
|
59
|
-
- 0
|
60
|
-
version: "0"
|
39
|
+
requirements:
|
40
|
+
- - ! '>='
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
61
43
|
requirements: []
|
62
|
-
|
63
44
|
rubyforge_project:
|
64
|
-
rubygems_version: 1.
|
45
|
+
rubygems_version: 1.8.23
|
65
46
|
signing_key:
|
66
47
|
specification_version: 3
|
67
48
|
summary: A Ruby OOP wrapper around dmenu.
|
68
49
|
test_files: []
|
69
|
-
|
50
|
+
has_rdoc: yard
|