Class: Fusuma::Plugin::Appmatcher::GnomeExtensions::Installer

Inherits:
Object
  • Object
show all
Includes:
UserSwitcher
Defined in:
lib/fusuma/plugin/appmatcher/gnome_extensions/installer.rb

Overview

Install Gnome Extension

Instance Method Summary collapse

Methods included from UserSwitcher

#as_user, #drop_priv, login_user

Instance Method Details

#enabled?Boolean

Returns:

  • (Boolean)


38
39
40
41
# File 'lib/fusuma/plugin/appmatcher/gnome_extensions/installer.rb', line 38

def enabled?
  enabled_extensions = YAML.load(`gsettings get org.gnome.shell enabled-extensions`)
  enabled_extensions&.include?(EXTENSION)
end

#installObject



15
16
17
18
19
20
21
22
# File 'lib/fusuma/plugin/appmatcher/gnome_extensions/installer.rb', line 15

def install
  pid = as_user(proctitle: self.class.name.underscore) do |user|
    FileUtils.cp_r(source_path, install_path(user.username))
    puts "Installed Appmatcher Gnome Shell Extension to #{user_extension_dir(user.username)}"
    puts "Restart your session, then activate Appmatcher on gnome-extensions-app"
  end
  Process.waitpid(pid)
end

#installed?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/fusuma/plugin/appmatcher/gnome_extensions/installer.rb', line 34

def installed?
  File.exist?(install_path)
end

#uninstallObject



24
25
26
27
28
29
30
31
32
# File 'lib/fusuma/plugin/appmatcher/gnome_extensions/installer.rb', line 24

def uninstall
  return puts "Appmatcher Gnome Shell Extension is not installed in #{user_extension_dir}/" unless installed?

  pid = as_user(proctitle: self.class.name.underscore) do |user|
    FileUtils.rm_r(install_path(user.username))
    puts "Uninstalled Appmatcher Gnome Shell Extension from #{install_path(user.username)}"
  end
  Process.waitpid(pid)
end