Class: Depot::DesktopEntry

Inherits:
Object
  • Object
show all
Defined in:
lib/depot/desktop_entry.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app_id:, name:, exec_path:, icon_name: nil) ⇒ DesktopEntry

Returns a new instance of DesktopEntry.



9
10
11
12
13
14
# File 'lib/depot/desktop_entry.rb', line 9

def initialize(app_id:, name:, exec_path:, icon_name: nil)
  @app_id = app_id
  @name = name
  @exec_path = exec_path
  @icon_name = icon_name
end

Instance Attribute Details

#app_idObject (readonly)

Returns the value of attribute app_id.



7
8
9
# File 'lib/depot/desktop_entry.rb', line 7

def app_id
  @app_id
end

#exec_pathObject (readonly)

Returns the value of attribute exec_path.



7
8
9
# File 'lib/depot/desktop_entry.rb', line 7

def exec_path
  @exec_path
end

#icon_nameObject (readonly)

Returns the value of attribute icon_name.



7
8
9
# File 'lib/depot/desktop_entry.rb', line 7

def icon_name
  @icon_name
end

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/depot/desktop_entry.rb', line 7

def name
  @name
end

Instance Method Details

#contentsObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/depot/desktop_entry.rb', line 16

def contents
  lines = [
    "[Desktop Entry]",
    "Type=Application",
    "Version=1.0",
    "Name=#{escape(name)}",
    "Exec=#{Util.desktop_exec_quote(exec_path)}",
    "Terminal=false",
    "Categories=Utility;",
    "X-Depot-AppID=#{escape(app_id)}"
  ]
  lines << "Icon=#{escape(icon_name)}" if icon_name && !icon_name.empty?
  lines.join("\n") + "\n"
end