Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/electron/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ const { autoUpdater } = require('electron-updater');
const { onFirstRunMaybe } = require('./first-run');
const path = require('node:path');
const log = require('electron-log');
const fs = require('node:fs');
const os = require('node:os');

log.initialize();
autoUpdater.logger = log;
Expand Down Expand Up @@ -51,6 +53,11 @@ const contextMenu = Menu.buildFromTemplate([
accelerator:
process.platform === 'darwin' ? 'Alt+Cmd+I' : 'Ctrl+Shift+I',
},
{
label: 'Take Screenshot',
accelerator: 'CommandOrControl+S',
click: () => takeScreenshot(),
},
{
label: 'Reset App',
click: () => {
Expand Down Expand Up @@ -176,6 +183,18 @@ app.whenReady().then(async () => {
});
});

function takeScreenshot() {
const date = new Date();
const dateStr = date.toISOString().replace(/:/g, '-');

const capturedPicFilePath = `${os.homedir()}/${dateStr}-gitify-screenshot.png`;
mb.window.capturePage().then((img) => {
fs.writeFile(capturedPicFilePath, img.toPNG(), () =>
log.info(`Screenshot saved ${capturedPicFilePath}`),
);
});
}

function resetApp() {
const cancelButtonId = 0;

Expand Down