This repository has been archived by the owner on Jan 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
295 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ node_modules | |
dist | ||
.DS_Store | ||
.idea | ||
electron-builder.yml |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,43 @@ | ||
const {app, Tray: Index, Menu, BrowserWindow, globalShortcut} = require('electron'); | ||
const makeScreenshot = require('./shot'); | ||
const { app, Tray: Index, Menu, BrowserWindow, globalShortcut, shell } = require('electron'); | ||
const makeScreenshot = require('./src/shot'); | ||
const shortcut = require('./src/shortcut'); | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
|
||
const iconPath = path.join(__dirname, 'assets', 'icon.png'); | ||
let appIcon = null; | ||
let window = null; | ||
app.on('ready', () => { | ||
try { | ||
/** | ||
* Do not show app in Dock | ||
*/ | ||
app.dock.hide(); | ||
|
||
app.on('ready', function(){ | ||
app.dock.hide(); | ||
/** | ||
* Create hidden app window | ||
*/ | ||
let window = new BrowserWindow({show: false}); | ||
|
||
window = new BrowserWindow({show: false}); | ||
appIcon = new Index(iconPath); | ||
/** | ||
* Set up icon | ||
*/ | ||
const iconPath = path.join(__dirname, 'assets', 'tray-icon-Template.png'), | ||
appIcon = new Index(iconPath); | ||
|
||
const contextMenu = Menu.buildFromTemplate([ | ||
{ | ||
label: 'Quit', | ||
accelerator: 'Command+Q', | ||
selector: 'terminate:', | ||
} | ||
]); | ||
appIcon.setContextMenu(contextMenu); | ||
/** | ||
* Prepare context menu | ||
*/ | ||
const menuItems = require('./src/menu'), | ||
contextMenu = Menu.buildFromTemplate(menuItems); | ||
|
||
appIcon.setToolTip('Upload a shot to capella.pics: CMD+SHIFT+CTRL+5'); | ||
appIcon.setContextMenu(contextMenu); | ||
|
||
globalShortcut.register('Command+Shift+Control+5', () => { | ||
makeScreenshot(); | ||
}) | ||
/** | ||
* Define global shortcut | ||
*/ | ||
globalShortcut.register(shortcut, () => { | ||
makeScreenshot(); | ||
}); | ||
} catch (e) { | ||
console.log('e', e); | ||
app.quit(); | ||
} | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,45 @@ | ||
{ | ||
"name": "shotcapella", | ||
"version": "1.0.0", | ||
"description": "", | ||
"description": "Upload screenshot to Capella and get a link to uploaded image into your clipboard", | ||
"main": "index.js", | ||
"scripts": { | ||
"start": "electron .", | ||
"build": "electron-builder" | ||
"build": "electron-builder", | ||
"ship": "electron-builder -m -p always" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"author": { | ||
"name": "Taly Guryn", | ||
"url": "https://github.com/talyguryn" | ||
}, | ||
"repository": { | ||
"url": "https://github.com/codex-team/shotcapella" | ||
}, | ||
"bugs": "https://github.com/codex-team/shotcapella/issues/new", | ||
"license": "MIT", | ||
"dependencies": { | ||
"@codexteam/capella-pics": "^1.0.1", | ||
"about-window": "^1.12.1", | ||
"auto-launch": "^5.0.5", | ||
"copy-paste": "^1.3.0", | ||
"shelljs": "^0.8.2" | ||
}, | ||
"devDependencies": { | ||
"electron": "^2.0.6", | ||
"electron-builder": "^20.26.1" | ||
}, | ||
"publish": [ | ||
{ | ||
"provider": "github", | ||
"owner": "codex-team", | ||
"repo": "shotcapella" | ||
} | ||
], | ||
"build": { | ||
"appId": "pics.capella.mac-app" | ||
"appId": "pics.capella.mac-app", | ||
"dmg": { | ||
"title": "shotcapella" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const openAboutWindow = require('about-window').default; | ||
const path = require('path'); | ||
|
||
module.exports = () => { | ||
openAboutWindow({ | ||
icon_path: path.join(__dirname, 'assets', 'icon.png'), | ||
bug_report_url: process.env.npm_package_bugs_url, | ||
bug_link_text: 'Report a bug', | ||
description: process.env.npm_package_description, | ||
license: 'MIT', | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const AutoLaunch = require('auto-launch'); | ||
const { app } = require('electron'); | ||
|
||
/** | ||
* Compose path to app | ||
*/ | ||
const appPath = app.getPath('exe').replace(/\.app\/Content.*/, '.app'); | ||
|
||
/** | ||
* Get launch instance | ||
*/ | ||
let launch = new AutoLaunch({ name: 'shotcapella', path: appPath, isHidden: false }); | ||
|
||
/** | ||
* State toggler | ||
*/ | ||
const launchToggle = () => { | ||
launch.isEnabled().then(enabled => { | ||
if (!enabled) { | ||
launch.enable() | ||
} else { | ||
launch.disable() | ||
} | ||
}) | ||
}; | ||
|
||
module.exports = launchToggle; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
const path = require('path'); | ||
const { app } = require('electron'); | ||
const openAboutWindow = require('./about-window'); | ||
const makeScreenshot = require('./shot'); | ||
const shortcut = require('./shortcut'); | ||
const launchToggle = require('./auto-launch'); | ||
|
||
let launch; | ||
|
||
module.exports = [ | ||
// { | ||
// label: 'About', | ||
// click() { | ||
// shell.openExternal(process.env.npm_package_repository_url); | ||
// } | ||
// }, | ||
// { | ||
// type: 'separator' | ||
// }, | ||
{ | ||
label: 'Make a shot', | ||
accelerator: shortcut, | ||
click() { | ||
makeScreenshot(); | ||
} | ||
}, | ||
{ | ||
type: 'separator' | ||
}, | ||
{ | ||
label: 'Open at Login', | ||
type: 'checkbox', | ||
checked: app.getLoginItemSettings().openAtLogin, | ||
click: launchToggle, | ||
}, | ||
{ | ||
type: 'separator' | ||
}, | ||
{ | ||
label: 'Quit', | ||
accelerator: 'Command+Q', | ||
selector: 'terminate:', | ||
} | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
const { Notification } = require('electron'); | ||
|
||
/** | ||
* {@link https://electronjs.org/docs/api/notification#new-notificationoptions-experimental} | ||
* | ||
* @typedef {Object} notificationOptions | ||
* @property {string} title - A title for the notification, which will be shown at the top of the notification window when it is shown. | ||
* @property {string} [subtitle] - A subtitle for the notification, which will be displayed below the title. | ||
* @property {string} body - The body text of the notification, which will be displayed below the title or subtitle. | ||
* @property {boolean} [silent] - Whether or not to emit an OS notification noise when showing the notification. | ||
* @property {string|NativeImage} [icon] - An icon to use in the notification. | ||
* @property {boolean} [hasReply] - Whether or not to add an inline reply option to the notification. | ||
* @property {string} [replyPlaceholder] - The placeholder to write in the inline reply input field. | ||
* @property {string} [sound] - The name of the sound file to play when the notification is shown. | ||
* @property {NotificationAction[]} [actions] - Actions to add to the notification. Please read the available actions and limitations in the NotificationAction documentation. | ||
* @property {string} [closeButtonText] - A custom title for the close button of an alert. An empty string will cause the default localized text to be used. | ||
*/ | ||
|
||
/** | ||
* Wrapper for showing notifications | ||
* | ||
* @param {notificationOptions} options | ||
* @param {function|null} callback | ||
*/ | ||
const showNotification = (options, callback) => { | ||
/** | ||
* Show notification | ||
*/ | ||
let notification = new Notification(options); | ||
|
||
if (callback) { | ||
notification.on('click', callback); | ||
} | ||
|
||
notification.show(); | ||
}; | ||
|
||
module.exports = showNotification; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = 'Command+Shift+Control+5'; |
Oops, something went wrong.