Sha256: 2365929f910500fde8f3ca8843fc5f477760ee66965ae262488da2b4c8f28d3d

Contents?: true

Size: 1.39 KB

Versions: 3

Compression:

Stored size: 1.39 KB

Contents

# frozen_string_literal: true

require "open3"
require_relative "user_switcher"
require "fusuma/multi_logger"
require "fusuma/custom_process"

module Fusuma
  module Plugin
    module Appmatcher
      # Dummy for unsupported Backend
      class UnsupportedBackend
        include UserSwitcher

        attr_reader :reader, :writer

        def initialize
          # need IO object for IO.select()
          @reader, @writer = IO.pipe
        end

        # fork process and watch signal
        # @return [Integer] Process id
        def watch_start
          @watch_start ||= begin
            pid = as_user(proctitle: self.class.name.underscore) do
              @reader.close
              sleep # stop indefinitely without using CPU
            end
            pid
          end
        end

        class Matcher
          def initialize
          end

          def running_applications
            warn
            nil
          end

          def active_application
            warn
            nil
          end

          private

          def warn
            MultiLogger.warn(
              <<~MSG
                appmatcher doesn't support
                XDG_CURRENT_DESKTOP: '#{Appmatcher.xdg_current_desktop}'
                XDG_SESSION_TYPE: '#{Appmatcher.xdg_session_type}'

                using dummy backend instead
              MSG
            )
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fusuma-plugin-appmatcher-0.7.1 lib/fusuma/plugin/appmatcher/unsupported_backend.rb
fusuma-plugin-appmatcher-0.7.0 lib/fusuma/plugin/appmatcher/unsupported_backend.rb
fusuma-plugin-appmatcher-0.6.1 lib/fusuma/plugin/appmatcher/unsupported_backend.rb