Sha256: 073d7492e9fbc4ff793898c1ed90071ad2c86b6f64a308166daf81ed812c0d9a
Contents?: true
Size: 1.31 KB
Versions: 1
Compression:
Stored size: 1.31 KB
Contents
require 'linux_win_manager' # Used to determine and run the screensaver command. class Breaktime::Command class OSUnknown < StandardError; end attr_reader :command # Determine the default screensaver command based on the user's OS. # # If Linux, use the LinuxWinManager class to determine the appropriate # command. def self.system_default(log) case RbConfig::CONFIG['target_os'] when 'linux' require 'linux_win_manager' log.debug { "Using Linux, detecting window manager and appropriate command" } Breaktime::LinuxWinManager.detect_command(log) when 'darwin10' log.debug { "Using Mac OSX10" } 'open -a /System/Library/Frameworks/ScreenSaver.framework/Versions/A/Resources/ScreenSaverEngine.app' when /mswin.*$/ log.debug { "Using Windows" } 'rundll32.exe user32.dll,LockWorkStation' else raise OSUnknown, 'Unknown OS' end end # Store the command if specified, or determine the system default. def initialize(command, log) @command = if command.nil? self.class.system_default(log) else log.debug { "User defined command: #{command}" } command end end # Execute the command with Kernel#exec. # # This replaces the current process, exiting when the command exits. def execute exec @command end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
breaktime-0.1.2 | lib/breaktime/command.rb |