Sha256: 6d3c807173dff2fdf2093bfdd993b5ce1a2c2d22c38d88b8e4be9f0b54c904ad

Contents?: true

Size: 1.56 KB

Versions: 3

Compression:

Stored size: 1.56 KB

Contents

module Launchy::Detect
  #
  # Detect the current desktop environment for *nix machines
  # Currently this is Linux centric. The detection is based upon the detection
  # used by xdg-open from http://portland.freedesktop.org/wiki/XdgUtils
  class NixDesktopEnvironment
    class NotFoundError < Launchy::Error; end

    extend ::Launchy::DescendantTracker

    # Detect the current *nix desktop environment
    #
    # If the current dekstop environment be detected, the return
    # NixDekstopEnvironment::Unknown
    def self.detect
      found = find_child( :is_current_desktop_environment? )
      Launchy.log("Current Desktop environment not flound. #{Launchy.bug_report_message}") unless found
      return found
    end

    def self.fallback_browsers
      %w[ firefox seamonkey opera mozilla netscape galeon ]
    end

    #---------------------------------------
    # The list of known desktop environments
    #---------------------------------------

    class Kde < NixDesktopEnvironment
      def self.is_current_desktop_environment?
        ENV['KDE_FULL_SESSION']
      end

      def self.browser
        'kfmclient'
      end
    end

    class Gnome < NixDesktopEnvironment
      def self.is_current_desktop_environment?
        ENV['GNOME_DESKTOP_SESSION_ID']
      end

      def self.browser
        'gnome-open'
      end
    end

    class Xfce < NixDesktopEnvironment
      def self.is_current_desktop_environment?
        %x[ xprop -root _DT_SAVE_MODE | grep ' = \"xfce\"$' ].strip.size > 0
      end

      def self.browser
        'exo-open'
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
launchy-2.0.5-java lib/launchy/detect/nix_desktop_environment.rb
wijet-launchy-2.0.6 lib/launchy/detect/nix_desktop_environment.rb
launchy-2.0.5 lib/launchy/detect/nix_desktop_environment.rb