dynmenu 0.1.1 → 0.1.2

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.
data/bin/dynmenu CHANGED
@@ -2,13 +2,17 @@
2
2
 
3
3
  require 'yaml'
4
4
 
5
+ $debug = false
5
6
  $subtle = true
6
7
  $lines = 20
8
+ $location = '-b '
9
+ $launcher = false
7
10
  begin
8
11
  require 'subtle/subtlext'
9
12
  rescue LoadError
10
13
  $subtle = false
11
14
  end
15
+ $subtle = false unless `pgrep subtle`.to_i > 0
12
16
  require 'root_menu'
13
17
  require 'command'
14
18
  require 'style'
@@ -34,13 +38,18 @@ Usage: dynmenu [options] file
34
38
  Options: -h --help : Show this help
35
39
  -r : Open the menu as read only and static
36
40
  -l <number> : Show max <number> lines in the menu (default=20)
41
+ -t : Show dynmenu on top and not at the bottom.
42
+ -d : Debug mode. Shows additional information for commands.
43
+ --launcher : Show only a launcher
44
+ (this would normally be under '>> Run' in the Menu)
45
+
37
46
  File: : The menu file to be loaded and saved to.
38
47
  It will be created if not existing.
39
48
  END_USAGE
40
49
 
41
50
  puts license
42
51
 
43
- if ARGV.length > 4 || ARGV.length < 1 || ARGV.include?("-h") || ARGV.include?("--help")
52
+ if ARGV.length > 6 || ARGV.length < 1 || ARGV.include?("-h") || ARGV.include?("--help")
44
53
  puts usage
45
54
  exit
46
55
  elsif ARGV.include? "-l"
@@ -58,9 +67,11 @@ else
58
67
  end
59
68
  end
60
69
  end
70
+ $debug = true if ARGV.include? '-d'
71
+ $location = '' if ARGV.include? '-t'
72
+ $launcher = true if ARGV.include? '--launcher'
61
73
 
62
74
  file = ARGV[ARGV.length - 1]
63
-
64
75
  if File.exist? file
65
76
  menu = YAML::load File.read(file)
66
77
  else
data/lib/command.rb CHANGED
@@ -126,10 +126,14 @@ class Command
126
126
  if $subtle
127
127
  subtle_execute
128
128
  else
129
- system "#{@command} &>/dev/null"
129
+ command = "#{@command} &>/dev/null"
130
+ puts command if $debug
131
+ system command
130
132
  end
131
133
  when URI
132
- system "xdg-open '%s' &>/dev/null" % [ @command.to_s ]
134
+ command = "xdg-open '#{@command.to_s}' &>/dev/null"
135
+ puts command if $debug
136
+ system command
133
137
  if $subtle
134
138
  browser = find_browser
135
139
  browser.focus unless browser.nil?
@@ -139,6 +143,12 @@ class Command
139
143
  end
140
144
 
141
145
  def subtle_execute
146
+ if $debug
147
+ puts "App: #{@app}"
148
+ puts "Tags: #{@tags.to_s}"
149
+ puts "Views: #{@views.to_s}"
150
+ puts "Modes: #{@modes.to_s}"
151
+ end
142
152
  tags = @tags.map do |t|
143
153
  tag = Subtlext::Tag.first(t) || Subtlext::Tag.new(t)
144
154
  tag.save
data/lib/editor.rb CHANGED
@@ -113,7 +113,7 @@ class Editor < Menu
113
113
  colors = [:bg, :fg, :bg_hi, :fg_hi]
114
114
  unless (entries.index selection).nil?
115
115
  if (entries.index selection) < 4
116
- style.color = colors[entries.index selection], show_menu([style.color(colors[entries.index selection])], "Enter a color")
116
+ style.set_color colors[entries.index selection], show_menu([style.color(colors[entries.index selection])], "Enter a color")
117
117
  elsif (entries.index selection) < 5
118
118
  if style.font.nil?
119
119
  selection = show_menu(["default"], "Set font")
data/lib/menu.rb CHANGED
@@ -74,7 +74,7 @@ class Menu
74
74
  unless $read_only || self.is_a?(Dynamic)
75
75
  entries << "> #{Editor.name}"
76
76
  end
77
- command = "echo \"#{entries.join "\n"}\" | dmenu -i -b -l #{$lines} #{get_font_string} -nf \"#{@style.color :fg}\" -nb \"#{@style.color :bg}\" -sf \"#{@style.color :fg_hi}\" -sb \"#{@style.color :bg_hi}\" -p \"#{name}\""
77
+ command = "echo \"#{entries.join "\n"}\" | dmenu -i #{$location}-l #{$lines} #{get_font_string} -nf \"#{@style.color :fg}\" -nb \"#{@style.color :bg}\" -sf \"#{@style.color :fg_hi}\" -sb \"#{@style.color :bg_hi}\" -p \"#{name}\""
78
78
  (`#{command}`).strip
79
79
  end
80
80
 
data/lib/root_menu.rb CHANGED
@@ -12,6 +12,13 @@ class Root_Menu < Menu
12
12
  set_item Run_Menu.new self, @history
13
13
  end
14
14
 
15
+ def execute
16
+ if $launcher
17
+ return Run_Menu.new(self, @history).execute unless @run_menu
18
+ @items.each_value {|item| return item.execute if item.is_a? Run_Menu}
19
+ end
20
+ super
21
+ end
15
22
  def run_menu?
16
23
  @run_menu
17
24
  end
@@ -25,7 +32,6 @@ class Root_Menu < Menu
25
32
  end
26
33
  end
27
34
 
28
-
29
35
  def encode_with coder
30
36
  super
31
37
  coder['run_menu'] = @run_menu
data/lib/style.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  class Style
2
- @@re_color = Regexp.new(/^#[0-9a-fA-F]{6}$/)
2
+ @@re_color = Regexp.new(/^#(([0-9a-fA-F]{6})|([0-9a-fA-F]{3}))$/)
3
3
  def initialize
4
4
  @colors = {
5
5
  :bg => "#202020",
@@ -9,7 +9,7 @@ class Style
9
9
  }
10
10
  end
11
11
 
12
- def color= color, value
12
+ def set_color color, value
13
13
  unless @colors.keys.include? color
14
14
  raise ArgumentError, "Invalid key!"
15
15
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynmenu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: