@@ -11,6 +11,8 @@ const { autoUpdater } = require('electron-updater');
1111const { onFirstRunMaybe } = require ( './first-run' ) ;
1212const path = require ( 'node:path' ) ;
1313const log = require ( 'electron-log' ) ;
14+ const fs = require ( 'node:fs' ) ;
15+ const os = require ( 'node:os' ) ;
1416
1517log . initialize ( ) ;
1618autoUpdater . logger = log ;
@@ -51,6 +53,11 @@ const contextMenu = Menu.buildFromTemplate([
5153 accelerator :
5254 process . platform === 'darwin' ? 'Alt+Cmd+I' : 'Ctrl+Shift+I' ,
5355 } ,
56+ {
57+ label : 'Take Screenshot' ,
58+ accelerator : 'CommandOrControl+S' ,
59+ click : ( ) => takeScreenshot ( ) ,
60+ } ,
5461 {
5562 label : 'Reset App' ,
5663 click : ( ) => {
@@ -176,6 +183,18 @@ app.whenReady().then(async () => {
176183 } ) ;
177184} ) ;
178185
186+ function takeScreenshot ( ) {
187+ const date = new Date ( ) ;
188+ const dateStr = date . toISOString ( ) . replace ( / : / g, '-' ) ;
189+
190+ const capturedPicFilePath = `${ os . homedir ( ) } /${ dateStr } -gitify-screenshot.png` ;
191+ mb . window . capturePage ( ) . then ( ( img ) => {
192+ fs . writeFile ( capturedPicFilePath , img . toPNG ( ) , ( ) =>
193+ log . info ( `Screenshot saved ${ capturedPicFilePath } ` ) ,
194+ ) ;
195+ } ) ;
196+ }
197+
179198function resetApp ( ) {
180199 const cancelButtonId = 0 ;
181200
0 commit comments