if (process.type === 'browser') { try { require('source-map-support').install(); } catch(ignored) {} }var log = require('common/utils/logger').debugLogger(__filename); var logError = require('common/utils/logger').errorLogger(__filename, false); var logFatal = require('common/utils/logger').errorLogger(__filename, true);'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _regenerator = require('babel-runtime/regenerator');

var _regenerator2 = _interopRequireDefault(_regenerator);

var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');

var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);

var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');

var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);

var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);

var _createClass2 = require('babel-runtime/helpers/createClass');

var _createClass3 = _interopRequireDefault(_createClass2);

var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');

var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);

var _inherits2 = require('babel-runtime/helpers/inherits');

var _inherits3 = _interopRequireDefault(_inherits2);

var _fsExtraPromise = require('fs-extra-promise');

var _fsExtraPromise2 = _interopRequireDefault(_fsExtraPromise);

var _electron = require('electron');

var _path = require('path');

var _path2 = _interopRequireDefault(_path);

var _base = require('browser/components/auto-launcher/base');

var _base2 = _interopRequireDefault(_base);

var _files = require('common/utils/files');

var _files2 = _interopRequireDefault(_files);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var autoStartDir = _path2.default.join(_electron.app.getPath('home'), '.config', 'autostart');
var desktopFilePath = _path2.default.join(autoStartDir, global.manifest.name + '.desktop');
var initialDesktopPath = _path2.default.join(_electron.app.getAppPath(), 'startup.desktop');

var LinuxAutoLauncher = function (_BaseAutoLauncher) {
  (0, _inherits3.default)(LinuxAutoLauncher, _BaseAutoLauncher);

  function LinuxAutoLauncher() {
    (0, _classCallCheck3.default)(this, LinuxAutoLauncher);
    return (0, _possibleConstructorReturn3.default)(this, (LinuxAutoLauncher.__proto__ || (0, _getPrototypeOf2.default)(LinuxAutoLauncher)).apply(this, arguments));
  }

  (0, _createClass3.default)(LinuxAutoLauncher, [{
    key: 'enable',
    value: function () {
      var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee() {
        return _regenerator2.default.wrap(function _callee$(_context) {
          while (1) {
            switch (_context.prev = _context.next) {
              case 0:
                log('enabling linux auto-launch');
                log('creating autolaunch .desktop');
                _context.next = 4;
                return _files2.default.replaceFile(desktopFilePath, function () {
                  return _fsExtraPromise2.default.copyAsync(initialDesktopPath, desktopFilePath);
                });

              case 4:
              case 'end':
                return _context.stop();
            }
          }
        }, _callee, this);
      }));

      function enable() {
        return _ref.apply(this, arguments);
      }

      return enable;
    }()
  }, {
    key: 'disable',
    value: function () {
      var _ref2 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee2() {
        return _regenerator2.default.wrap(function _callee2$(_context2) {
          while (1) {
            switch (_context2.prev = _context2.next) {
              case 0:
                log('disabling linux auto-launch');
                log('removing autolaunch .desktop');
                _context2.next = 4;
                return _fsExtraPromise2.default.removeAsync(desktopFilePath);

              case 4:
              case 'end':
                return _context2.stop();
            }
          }
        }, _callee2, this);
      }));

      function disable() {
        return _ref2.apply(this, arguments);
      }

      return disable;
    }()
  }, {
    key: 'isEnabled',
    value: function () {
      var _ref3 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee3() {
        return _regenerator2.default.wrap(function _callee3$(_context3) {
          while (1) {
            switch (_context3.prev = _context3.next) {
              case 0:
                log('checking linux auto-launch');
                _context3.next = 3;
                return _files2.default.isFileExists(desktopFilePath);

              case 3:
              case 'end':
                return _context3.stop();
            }
          }
        }, _callee3, this);
      }));

      function isEnabled() {
        return _ref3.apply(this, arguments);
      }

      return isEnabled;
    }()
  }]);
  return LinuxAutoLauncher;
}(_base2.default);

exports.default = LinuxAutoLauncher;
//# sourceMappingURL=data:application/json;charset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