fluxbox_apps_menu 1.3.0 → 1.4.0
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/fluxbox_apps_menu.gemspec +1 -1
- data/lib/fluxbox_apps_menu.rb +19 -35
- data/lib/fluxbox_apps_menu.yaml +9 -5
- data/lib/fluxbox_apps_menu/cli.rb +9 -0
- data/lib/fluxbox_apps_menu/config.rb +16 -13
- data/lib/fluxbox_apps_menu/desktop_file.rb +3 -3
- data/lib/fluxbox_apps_menu/menu.rb +1 -1
- data/lib/fluxbox_apps_menu/utils.rb +95 -22
- data/lib/fluxbox_apps_menu/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dbe89b0ebddb88a2ad0b7d136d23d92033e23122
|
4
|
+
data.tar.gz: 4d9a9f61fe7e78d89d5fe166c356bd7272b01e1b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03563fe3b2285cf53d134e7163a431eb609fd7b682013777beaed6a4b57a1a17b40d9d597be329cf85e21504ab0b9a825d383ab46a9e649b4d9b5a059660021a
|
7
|
+
data.tar.gz: a5bb559edcbfad3a7bd40bf74b00ddb4a753cf872c1f7aa001dc9bdc4448c6d049f2b299244deca1e4a98dd2aaa0b7850cbe9cb33b7b2980fa1334d3b89452a9
|
data/Gemfile.lock
CHANGED
data/fluxbox_apps_menu.gemspec
CHANGED
@@ -21,6 +21,6 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.6"
|
22
22
|
spec.add_development_dependency "rake"
|
23
23
|
|
24
|
-
spec.add_runtime_dependency "
|
24
|
+
spec.add_runtime_dependency "iniparse"
|
25
25
|
spec.add_runtime_dependency "thor"
|
26
26
|
end
|
data/lib/fluxbox_apps_menu.rb
CHANGED
@@ -17,11 +17,8 @@ module FluxboxAppsMenu
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def create_menu
|
20
|
-
|
21
|
-
if File.exists?(File.expand_path("~/.fluxbox/#{@filename}"))
|
22
|
-
STDERR.puts 'Fatal Error! '.bold.red "The file #{@filename} already exists!"
|
23
|
-
exit
|
24
|
-
end
|
20
|
+
unless @overwrite
|
21
|
+
raise FileExists, "~/.fluxbox/#{@filename}" if File.exists?(File.expand_path("~/.fluxbox/#{@filename}"))
|
25
22
|
end
|
26
23
|
|
27
24
|
scan_app_folder
|
@@ -31,10 +28,7 @@ module FluxboxAppsMenu
|
|
31
28
|
|
32
29
|
def init_config
|
33
30
|
unless @overwrite
|
34
|
-
if File.exists?(File.expand_path("~/.fluxbox/fluxbox_apps_menu.yaml"))
|
35
|
-
STDERR.puts 'Fatal Error! '.bold.red + "The file 'fluxbox_apps_menu.yaml' already exists in '#{File.expand_path('~/.fluxbox')}'"
|
36
|
-
exit
|
37
|
-
end
|
31
|
+
raise FileExists, '~/.fluxbox/fluxbox_apps_menu.yaml' if File.exists?(File.expand_path("~/.fluxbox/fluxbox_apps_menu.yaml"))
|
38
32
|
end
|
39
33
|
FileUtils.copy(File.dirname(__FILE__) + '/fluxbox_apps_menu.yaml', File.expand_path('~/.fluxbox/'))
|
40
34
|
end
|
@@ -46,6 +40,8 @@ module FluxboxAppsMenu
|
|
46
40
|
|
47
41
|
Dir.glob(File.expand_path(d + '/*.desktop')) do |f|
|
48
42
|
|
43
|
+
Messages.examining f if @verbose
|
44
|
+
|
49
45
|
ini = DesktopFile.new(f, @cfg)
|
50
46
|
|
51
47
|
next if ini.banned_file?
|
@@ -53,47 +49,35 @@ module FluxboxAppsMenu
|
|
53
49
|
name = ini.name
|
54
50
|
|
55
51
|
if ini.hidden?
|
56
|
-
|
52
|
+
Messages.hidden(name, f) if @verbose
|
57
53
|
next
|
58
54
|
end
|
59
55
|
|
60
56
|
cat = ini.categories
|
61
57
|
if cat.nil?
|
62
|
-
|
58
|
+
Messages.no_category(name, f) if @verbose
|
63
59
|
next
|
64
60
|
end
|
65
61
|
|
66
|
-
|
67
|
-
submenu = @fmenu.assign_menu(cat, name)
|
68
|
-
rescue NoCategoriesError => e
|
69
|
-
STDERR.puts 'Fatal Error! '.bold.red + "The \"#{e.message}\" menu item doesn't have any category, fix it to your \"fluxbox_menu_apps.yaml\""
|
70
|
-
exit
|
71
|
-
end
|
62
|
+
submenu = @fmenu.assign_menu(cat, name)
|
72
63
|
|
73
|
-
|
74
|
-
|
64
|
+
raise NoMappedCategories, {:name => name, :categories => ini.categories} if submenu.nil?
|
65
|
+
|
66
|
+
icon = ini.icon
|
67
|
+
|
68
|
+
submenu[name] = MenuItem.new(:label => name, :icon => icon, :command => ini.exec)
|
69
|
+
|
70
|
+
if @verbose
|
75
71
|
if icon.nil?
|
76
|
-
|
72
|
+
Messages.no_icon(name, f)
|
73
|
+
else
|
74
|
+
Messages.ok(name, f)
|
77
75
|
end
|
78
|
-
|
79
|
-
submenu[name] = MenuItem.new(:label => name, :icon => icon, :command => ini.exec)
|
80
|
-
puts '[V]'.bold.green + " \"#{name}\" (#{f})" if @verbose
|
81
|
-
else
|
82
|
-
STDERR.puts 'Warning! '.bold.yellow + "\"#{name}\" doesn't have any mapped category among: #{ini.categories.join(', ')}, fix it to your \"fluxbox_menu_apps.yaml\" "
|
83
76
|
end
|
84
77
|
end
|
85
78
|
end
|
86
79
|
|
87
|
-
if @verbose
|
88
|
-
puts ''
|
89
|
-
puts 'Quick Help:'
|
90
|
-
puts ''
|
91
|
-
puts ' [V]: Everything is ok'.bold.green
|
92
|
-
puts ' [H]: Hidden app'.bold.gray
|
93
|
-
puts ' [I]: App without icon'.bold.yellow
|
94
|
-
puts ' [C]: App without categories'.bold.red
|
95
|
-
puts ''
|
96
|
-
end
|
80
|
+
Messages.help if @verbose
|
97
81
|
end
|
98
82
|
|
99
83
|
end
|
data/lib/fluxbox_apps_menu.yaml
CHANGED
@@ -1,6 +1,4 @@
|
|
1
1
|
---
|
2
|
-
# other options: kdesu and gnomesu
|
3
|
-
:switch_user: 'xdg-su'
|
4
2
|
:terminal: 'xdg-terminal'
|
5
3
|
:icons:
|
6
4
|
App Name: 'icon-name'
|
@@ -98,11 +96,15 @@
|
|
98
96
|
:categories:
|
99
97
|
- Yast
|
100
98
|
Hardware:
|
101
|
-
:icon:
|
99
|
+
:icon:
|
100
|
+
- package_yast_hardware
|
101
|
+
- yast-hardware
|
102
102
|
:categories:
|
103
103
|
- X-SuSE-YaST-Hardware
|
104
104
|
Miscellaneous:
|
105
|
-
:icon:
|
105
|
+
:icon:
|
106
|
+
- package_yast_misc
|
107
|
+
- yast-misc
|
106
108
|
:categories:
|
107
109
|
- X-SuSE-YaST-Misc
|
108
110
|
Network Devices:
|
@@ -118,7 +120,9 @@
|
|
118
120
|
:categories:
|
119
121
|
- X-SuSE-YaST-Security
|
120
122
|
System:
|
121
|
-
:icon:
|
123
|
+
:icon:
|
124
|
+
- package_yast_system
|
125
|
+
- yast-system
|
122
126
|
:categories:
|
123
127
|
- X-SuSE-YaST-System
|
124
128
|
Software:
|
@@ -18,13 +18,13 @@ module FluxboxAppsMenu
|
|
18
18
|
|
19
19
|
yaml = YAML.load_file(@filename)
|
20
20
|
|
21
|
-
@banned_files = yaml[:banned_files]
|
22
|
-
@unhide_files = yaml[:unhide_files]
|
23
|
-
@icon_paths = yaml[:icon_paths]
|
24
|
-
@app_paths = yaml[:app_paths]
|
25
|
-
@menu = yaml[:menu]
|
26
|
-
@icons = yaml[:icons]
|
27
|
-
@terminal = yaml[:terminal]
|
21
|
+
@banned_files = yaml[:banned_files] || []
|
22
|
+
@unhide_files = yaml[:unhide_files] || []
|
23
|
+
@icon_paths = yaml[:icon_paths] || []
|
24
|
+
@app_paths = yaml[:app_paths] || []
|
25
|
+
@menu = yaml[:menu] || {}
|
26
|
+
@icons = yaml[:icons] || {}
|
27
|
+
@terminal = yaml[:terminal] || 'xdg-terminal'
|
28
28
|
|
29
29
|
@lang = ENV['LANG'].split('.')[0]
|
30
30
|
@lang = { :short => @lang.split('_')[0], :long => @lang }
|
@@ -35,16 +35,19 @@ module FluxboxAppsMenu
|
|
35
35
|
iname = icon_name if iname.nil?
|
36
36
|
|
37
37
|
return nil if iname.to_s.empty?
|
38
|
-
return iname if iname.
|
38
|
+
return iname if iname.class == String && iname =~ /^\// && File.exists?(iname)
|
39
39
|
|
40
|
-
iname.
|
40
|
+
iname = [iname] if iname.class == String
|
41
41
|
|
42
|
-
|
43
|
-
|
44
|
-
end
|
42
|
+
iname.each do |i|
|
43
|
+
i = File.basename(i, File.extname(i))
|
45
44
|
|
46
|
-
|
45
|
+
@icon_paths.each do |p|
|
46
|
+
return "#{p}/#{i}.png" if File.exists?("#{p}/#{i}.png")
|
47
|
+
end
|
48
|
+
end
|
47
49
|
|
50
|
+
nil
|
48
51
|
end
|
49
52
|
end
|
50
53
|
end
|
@@ -1,11 +1,11 @@
|
|
1
|
-
require '
|
2
|
-
|
1
|
+
require 'iniparse'
|
2
|
+
|
3
3
|
module FluxboxAppsMenu
|
4
4
|
|
5
5
|
class DesktopFile
|
6
6
|
|
7
7
|
def initialize(filename, cfg = nil)
|
8
|
-
@ini =
|
8
|
+
@ini = IniParse.parse(File.read(filename))
|
9
9
|
@cfg = cfg.nil? ? FluxboxAppsMenu::Config.new : cfg
|
10
10
|
@filename = filename
|
11
11
|
end
|
@@ -112,7 +112,7 @@ module FluxboxAppsMenu
|
|
112
112
|
selected, selected_index = result, index unless result.nil?
|
113
113
|
end
|
114
114
|
|
115
|
-
raise
|
115
|
+
raise NoMenuCategories, key unless info.has_key? :categories
|
116
116
|
|
117
117
|
categories = info[:categories].map { |s| s.downcase unless s.nil? }
|
118
118
|
|
@@ -1,24 +1,97 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
1
|
+
module FluxboxAppsMenu
|
2
|
+
|
3
|
+
class ::String
|
4
|
+
def black; "\033[30m#{self}\033[0m" end
|
5
|
+
def red; "\033[31m#{self}\033[0m" end
|
6
|
+
def green; "\033[32m#{self}\033[0m" end
|
7
|
+
def yellow; "\033[33m#{self}\033[0m" end
|
8
|
+
def blue; "\033[34m#{self}\033[0m" end
|
9
|
+
def magenta; "\033[35m#{self}\033[0m" end
|
10
|
+
def cyan; "\033[36m#{self}\033[0m" end
|
11
|
+
def gray; "\033[37m#{self}\033[0m" end
|
12
|
+
def bg_black; "\033[40m#{self}\0330m" end
|
13
|
+
def bg_red; "\033[41m#{self}\033[0m" end
|
14
|
+
def bg_green; "\033[42m#{self}\033[0m" end
|
15
|
+
def bg_brown; "\033[43m#{self}\033[0m" end
|
16
|
+
def bg_blue; "\033[44m#{self}\033[0m" end
|
17
|
+
def bg_magenta; "\033[45m#{self}\033[0m" end
|
18
|
+
def bg_cyan; "\033[46m#{self}\033[0m" end
|
19
|
+
def bg_gray; "\033[47m#{self}\033[0m" end
|
20
|
+
def bold; "\033[1m#{self}\033[22m" end
|
21
|
+
def reverse_color; "\033[7m#{self}\033[27m" end
|
22
|
+
def cr; "\r#{self}" end
|
23
|
+
def clean; "\e[K#{self}" end
|
24
|
+
def new_line; "\n#{self}" end
|
25
|
+
end
|
26
|
+
|
27
|
+
class Messages
|
28
|
+
def self.error(e)
|
29
|
+
if e.class.to_s =~ /^FluxboxAppsMenu/
|
30
|
+
STDERR.puts e.message.new_line
|
31
|
+
else
|
32
|
+
STDERR.puts 'Error! '.bold.red.new_line + e.message
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.examining(filename)
|
37
|
+
print '[-] '.bold.blue + "Examining #{filename}... "
|
38
|
+
STDOUT.flush
|
39
|
+
sleep 0.01
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.hidden(name, filename)
|
43
|
+
puts '[H] '.bold.gray.clean.cr + "\"#{name}\" (#{filename})"
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.no_icon(name, filename)
|
47
|
+
puts '[I] '.bold.yellow.clean.cr + "\"#{name}\" (#{filename})"
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.ok(name, filename)
|
51
|
+
puts '[V]'.bold.green.clean.cr + " \"#{name}\" (#{filename})"
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.no_category(name, filename)
|
55
|
+
puts '[C] '.bold.red.clean.cr + "\"#{name}\" (#{filename})"
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.help
|
59
|
+
puts ''
|
60
|
+
puts 'Quick Help:'
|
61
|
+
puts ''
|
62
|
+
puts ' [V]: Everything is ok'.bold.green
|
63
|
+
puts ' [H]: Hidden app'.bold.gray
|
64
|
+
puts ' [I]: App without icon'.bold.yellow
|
65
|
+
puts ' [C]: App without categories'.bold.red
|
66
|
+
puts ''
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
class NoMenuCategories < StandardError
|
71
|
+
def initialize(item)
|
72
|
+
super 'Error! '.bold.red + "The menu item \"#{item}\" doesn't have any category, fix it to \"fluxbox_apps_menu.yaml\""
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
class NoMappedCategories < StandardError
|
77
|
+
def initialize(params)
|
78
|
+
super 'Error! '.bold.red + "The item \"#{params[:name]}\" doesn't have any mapped category among #{params[:categories].join(', ')}, fix it to \"fluxbox_apps_menu.yaml\""
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
class FileExists < StandardError
|
83
|
+
def initialize(filename)
|
84
|
+
super 'Error! '.bold.red + "The file #{filename} already exists, use the --overwrite switch to avoid this error."
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
class Interruption < StandardError
|
89
|
+
def initialize
|
90
|
+
super '[X] Ok ok... Exiting!'.bold.blue
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
Signal.trap('INT') { raise Interruption }
|
21
95
|
|
22
|
-
|
23
|
-
|
96
|
+
Signal.trap('TERM') { raise Interruption }
|
24
97
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluxbox_apps_menu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fabio Mucciante
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -39,19 +39,19 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: iniparse
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: thor
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|