Skip to content

Commit

Permalink
Merge pull request #1 from Kiloku/master
Browse files Browse the repository at this point in the history
Adds Settings file and allows the user to choose save directory
  • Loading branch information
hamilton-lima authored Sep 17, 2018
2 parents dcf6c8f + b2f33a3 commit 3773432
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
17 changes: 15 additions & 2 deletions renderer.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const { desktopCapturer, ipcRenderer } = require("electron");
const { app } = require("electron").remote;
const fs = require('fs');

console.log("desktopCapturer", desktopCapturer);

Expand Down Expand Up @@ -35,6 +36,19 @@ function getDesktop() {
return app.getPath("desktop");
}

function getSavePath() {
console.log("getSavePath()");
let rawData = fs.readFileSync('settings.json');
settings = JSON.parse(rawData); //TODO: Read settings once and store as global var.
console.log("rawData: " + rawData);
console.log(settings);
if (settings.saveDir != "")
{
return settings.saveDir;
}
return getDesktop();
}

function getTimeStampForFileName() {
return new Date()
.toISOString()
Expand All @@ -46,12 +60,11 @@ function getTimeStampForFileName() {

function getFileName() {
const path = require("path");
const result = getDesktop() + path.sep + getTimeStampForFileName() + ".png";
const result = getSavePath() + path.sep + getTimeStampForFileName() + ".png";
return result;
}

function saveImage(data) {
var fs = require("fs");
var base64Data;
var binaryData;

Expand Down
3 changes: 3 additions & 0 deletions settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"saveDir" : ""
}

0 comments on commit 3773432

Please sign in to comment.