Skip to content

Commit

Permalink
update node-notifier. Remove assistive acces automatic settings for a…
Browse files Browse the repository at this point in the history
…ll versions (for sierra not allowed), Notify if assistive acces has to be set.
  • Loading branch information
Maigo Erit committed Feb 19, 2017
1 parent 05e432d commit ca1d69a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 28 deletions.
40 changes: 15 additions & 25 deletions app/background.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,6 @@ BackgroundService.onResume = function () {
isSleeping = false;
};

var isOsxScriptRunned = false;

BackgroundService.saveForegroundWindowTitle = function () {

//'darwin', 'freebsd', 'linux', 'sunos' or 'win32'
Expand All @@ -305,18 +303,16 @@ BackgroundService.saveForegroundWindowTitle = function () {
//log.debug('Script saveForegroundWindowTitle file: ' + script);

var child = exec(script, {timeout: 1000});

child.stdout.on("data", (data)=> {
let stdout = data.toString();
log.debug('Foreground window: ' + stdout);

isOsxScriptRunned = true;//some applications does not have app, check only when started

var active = {};
var active_a = stdout.split(",");

if (typeof active_a[0] !== "undefined") {
active.app = active_a[0];
// isElCapitanScriptRunned = true;//some applications doe not have app, check only when started
}


Expand All @@ -337,36 +333,30 @@ BackgroundService.saveForegroundWindowTitle = function () {
saveActiveWindow(active);
});

let firstErrorPart = true;
child.stderr.setEncoding('utf8');
child.stderr.on("data", (data) => {

let error = data.toString();

log.error('saveForegroundWindowTitle error: ' + error);

if (process.platform === 'darwin' && isOsxScriptRunned === false) {

var access_script = "osascript " + path.join(__dirname, "assistive-access-el-capitan.osa");
var curVer = require('os').release();
if (compareVersion(curVer, '10.11.0') === -1) {
access_script = "osascript " + path.join(__dirname, "assistive-access-osx.osa");
}
isOsxScriptRunned = true;
// For sierra writing to TCC.db is not allowed
if (compareVersion(curVer, '10.12.0') === -1) {
console.log('Running ' + access_script);
exec(access_script, function (error, stdout, stderr) {
console.log('Assistive access: ', stdout, error, stderr);
});
} else {
console.log('Not running ' + access_script);
}
if (!firstErrorPart) {
log.error('Multipart error, ignoring rest');
return;
}

firstErrorPart = false;
log.error('saveForegroundWindowTitle error: ' + error);

if (error.includes('UnauthorizedAccess') || error.includes('AuthorizationManager check failed')) {
error = 'Choose [A] Always run in opened command prompt.';
execSync('start cmd.exe /K' + script);
}

if (error.includes('assistive')
|| error.includes('get-foreground-window-title')
|| error.includes('390')) {
error = 'Tockler is not allowed assistive access. Security & Privacy -> Accessibility -> enable tockler.app';
}

UserMessages.showError('Error getting window title', error);
return;

Expand Down
4 changes: 2 additions & 2 deletions app/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ config.windows = {
width: 1200,
height: 1000,
maximize: true,
show: true, // Show window, default: true
show: false, // Show window, default: true
showDevtools: true, // Show devtools, default: true (Only in development mode)
title: 'Tockler',
title: 'Tockler'
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"menubar": "^5.1.0",
"moment": "^2.15.1",
"multiline": "^1.0.2",
"node-notifier": "^4.6.1",
"node-notifier": "^5.0.2",
"os-locale": "^1.4.0",
"q": "^1.4.1",
"randomcolor": "^0.4.4",
Expand Down

0 comments on commit ca1d69a

Please sign in to comment.