Class: Fusuma::Plugin::Appmatcher::Cosmic

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

Overview

Search Active Window’s Name for COSMIC desktop via cos-cli (third-party). cos-cli must be installed separately:

cargo install --git https://github.com/estin/cos-cli

Defined Under Namespace

Classes: Matcher

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from UserSwitcher

#as_user, #drop_priv, login_user

Constructor Details

#initializeCosmic

Returns a new instance of Cosmic.



30
31
32
# File 'lib/fusuma/plugin/appmatcher/cosmic.rb', line 30

def initialize
  @reader, @writer = IO.pipe
end

Instance Attribute Details

#readerObject (readonly)

Returns the value of attribute reader.



18
19
20
# File 'lib/fusuma/plugin/appmatcher/cosmic.rb', line 18

def reader
  @reader
end

#writerObject (readonly)

Returns the value of attribute writer.



18
19
20
# File 'lib/fusuma/plugin/appmatcher/cosmic.rb', line 18

def writer
  @writer
end

Class Method Details

.available?Boolean

Search PATH in pure Ruby: the external ‘which` command is not installed on minimal systems (e.g. Arch containers).

Returns:

  • (Boolean)


23
24
25
26
27
28
# File 'lib/fusuma/plugin/appmatcher/cosmic.rb', line 23

def self.available?
  ENV.fetch("PATH", "").split(File::PATH_SEPARATOR).any? do |dir|
    path = File.join(dir, "cos-cli")
    File.executable?(path) && !File.directory?(path)
  end
end

Instance Method Details

#watch_startObject



34
35
36
37
38
39
# File 'lib/fusuma/plugin/appmatcher/cosmic.rb', line 34

def watch_start
  as_user(proctitle: self.class.name.underscore) do |_user|
    @reader.close
    register_on_application_changed(Matcher.new)
  end
end