self.uptime

in lib/gdk/machine.rb [92:104]


    def self.uptime
      if linux?
        File.read('/proc/uptime').split.first.to_i
      elsif macos?
        boottime = GDK::Shellout.new(%w[sysctl -n kern.boottime]).run.match(/sec = (\d+)/)[1].to_i
        return nil unless boottime

        (Time.now - boottime).to_i
      end
    rescue Errno::ENOENT
      nil
    end