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

Constant Summary collapse

EXTENSION =
"./appmatcher@iberianpig.dev"

Instance Method Summary collapse

Methods included from UserSwitcher

#as_user, #drop_priv, login_user

Instance Method Details

#gnome_shell_extension_pathObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/fusuma/plugin/appmatcher/gnome_extensions/installer.rb', line 16

def gnome_shell_extension_path
  output = `gnome-shell --version`
  version = output.match(/GNOME Shell (\d+\.\d+)/)

  if version
    version_number = version[1].to_f
    if version_number >= 45.0
      "./appmatcher45@iberianpig.dev"
    else
      "./appmatcher@iberianpig.dev"
    end
  else
    "./appmatcher@iberianpig.dev"
  end
end

#installObject



32
33
34
35
36
37
38
39
# File 'lib/fusuma/plugin/appmatcher/gnome_extensions/installer.rb', line 32

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)


51
52
53
# File 'lib/fusuma/plugin/appmatcher/gnome_extensions/installer.rb', line 51

def installed?
  File.exist?(install_path)
end

#uninstallObject



41
42
43
44
45
46
47
48
49
# File 'lib/fusuma/plugin/appmatcher/gnome_extensions/installer.rb', line 41

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