class FluxboxAppsMenu::DesktopFile

Public Class Methods

new(filename, cfg = nil) click to toggle source
# File lib/fluxbox_apps_menu/desktop_file.rb, line 7
def initialize(filename, cfg = nil)
  @ini = IniParse.parse(File.read(filename))
  @cfg = cfg.nil? ? FluxboxAppsMenu::Config.new : cfg
  @filename = filename
end

Public Instance Methods

banned_file?() click to toggle source
# File lib/fluxbox_apps_menu/desktop_file.rb, line 29
def banned_file?
  @cfg.banned_files.each { |r| return true if @filename =~ Regexp.new(r) }
  false
end
categories() click to toggle source
# File lib/fluxbox_apps_menu/desktop_file.rb, line 42
def categories
  cat = @ini['Desktop Entry']['Categories']
  cat.split(';') unless cat.nil?
end
exec() click to toggle source
# File lib/fluxbox_apps_menu/desktop_file.rb, line 47
def exec
  com = @ini['Desktop Entry']['Exec'].to_s
    .gsub(/((?:"){,1})%c\1/, "\\1#{name}\\1")
    .gsub(/((?:"){,1})(%F|%i|%U|%f|%m|%u)\1/, '')
    .gsub(/[ ]{2,}/, ' ').gsub(/\ }/, '}').strip

  terminal? ? @cfg.terminal + ' ' + com : com
end
hidden?() click to toggle source
# File lib/fluxbox_apps_menu/desktop_file.rb, line 24
def hidden?
  @cfg.unhide_files.each { |r| return false if @filename =~ Regexp.new(r) }
   %w(true 1).include? @ini['Desktop Entry']['NoDisplay'].to_s
end
icon() click to toggle source
# File lib/fluxbox_apps_menu/desktop_file.rb, line 34
def icon
  @cfg.expand_icon(name(false), @ini['Desktop Entry']['Icon'])
end
name(lang = true) click to toggle source
# File lib/fluxbox_apps_menu/desktop_file.rb, line 13
def name(lang = true)
  if lang
    name = @ini['Desktop Entry']["Name[#{@cfg.lang[:short]}]"]
    name = @ini['Desktop Entry']["Name[#{@cfg.lang[:long]}]"] if name.nil?
  end

  name = @ini['Desktop Entry']['Name'] if name.nil?

  name
end
terminal?() click to toggle source
# File lib/fluxbox_apps_menu/desktop_file.rb, line 38
def terminal?
  %w(true 1).include? @ini['Desktop Entry']['Terminal'].to_s
end