Sha256: 17b644c80a5741fa3b393b2b117132c650eccfaaa6b34ad4e85cdaddaec15389

Contents?: true

Size: 986 Bytes

Versions: 5

Compression:

Stored size: 986 Bytes

Contents

# frozen_string_literal: true

require "fusuma/plugin/appmatcher/version"

require "fusuma/plugin/appmatcher/x11"
require "fusuma/plugin/appmatcher/gnome"
require "fusuma/plugin/appmatcher/gnome_extension"
require "fusuma/plugin/appmatcher/gnome_extensions/installer"
require "fusuma/plugin/appmatcher/unsupported_backend"

module Fusuma
  module Plugin
    # Detect focused applications.
    module Appmatcher
      module_function

      # @return [Class]
      def backend_klass
        case xdg_session_type
        when /x11/
          return X11
        when /wayland/
          case xdg_current_desktop
          when /GNOME/
            return GnomeExtension if GnomeExtensions::Installer.new.installed?

            return Gnome
          end
        end

        UnsupportedBackend
      end

      def xdg_session_type
        ENV.fetch("XDG_SESSION_TYPE", "")
      end

      def xdg_current_desktop
        ENV.fetch("XDG_CURRENT_DESKTOP", "")
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

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