Compare commits
24 Commits
Author | SHA1 | Date |
---|---|---|
cupcakearmy | d1485e18ee | |
cupcakearmy | caa7a35aef | |
Nicco | 22f704e41d | |
cupcakearmy | e9cd600fd7 | |
cupcakearmy | 6f365fb9f6 | |
cupcakearmy | 791cc57177 | |
cupcakearmy | d7b5b6b73e | |
cupcakearmy | 7eddb6a592 | |
cupcakearmy | 9333af5369 | |
cupcakearmy | 62a8999f47 | |
cupcakearmy | 69da7b2364 | |
cupcakearmy | 9e5eaf1b3d | |
cupcakearmy | aa56ad6ce7 | |
cupcakearmy | dc03c1b1ce | |
cupcakearmy | 893c0fcc5c | |
cupcakearmy | 1b691949a3 | |
cupcakearmy | 14ac96366e | |
cupcakearmy | 622bfc914e | |
cupcakearmy | 1b48709a1d | |
cupcakearmy | 8398dccac3 | |
cupcakearmy | 82142ccb14 | |
cupcakearmy | 8854566336 | |
cupcakearmy | 447726e6cc | |
cupcakearmy | beb5572fb7 |
|
@ -1,7 +1,9 @@
|
|||
name: Main
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
tags:
|
||||
- "v*.*.*"
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
@ -12,9 +14,12 @@ jobs:
|
|||
- uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: "14"
|
||||
- name: PNPM
|
||||
run: npm i -g pnpm
|
||||
- name: Install dependencies
|
||||
run: yarn install --frozen-lockfile
|
||||
run: pnpm install --frozen-lockfile
|
||||
- name: Build
|
||||
run: yarn run dist
|
||||
run: pnpm run dist
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
EP_PRE_RELEASE: true
|
||||
|
|
36
CHANGELOG.md
36
CHANGELOG.md
|
@ -5,32 +5,54 @@ All notable changes to this project will be documented in this file.
|
|||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [1.3.2] - 2022-01-21
|
||||
|
||||
### Changed
|
||||
|
||||
- Moved to pnpm
|
||||
|
||||
### Security
|
||||
|
||||
- Updated all dependencies.
|
||||
|
||||
## [1.3.1] - 2021-06-17
|
||||
|
||||
### Fixed
|
||||
|
||||
- Pause on Mic/Camera was not working correctly.
|
||||
|
||||
## [1.3.0] - 2021-06-10
|
||||
|
||||
### Added
|
||||
|
||||
- [macOS] Pause on Mic/Camera.
|
||||
|
||||
## [1.2.0] - 2021-06-01
|
||||
|
||||
### Added
|
||||
|
||||
- Progress bar
|
||||
- Progress bar.
|
||||
|
||||
## [1.1.2] - 2021-05-31
|
||||
|
||||
### Fixed
|
||||
|
||||
- Bug with update window when banner is currently open
|
||||
- Bug with update window when banner is currently open.
|
||||
|
||||
## [1.1.1] - 2021-05-28
|
||||
|
||||
### Added
|
||||
|
||||
- Restore focus to previous window when closing banner
|
||||
- Responsive image
|
||||
- Restore focus to previous window when closing banner.
|
||||
- Responsive image.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Settings page not opening
|
||||
- Settings page not opening.
|
||||
|
||||
## [1.1.0] - 2021-05-15
|
||||
|
||||
### Added
|
||||
|
||||
- Only pause for a limited time
|
||||
- Volume slider for the sound
|
||||
- Only pause for a limited time.
|
||||
- Volume slider for the sound.
|
||||
|
|
|
@ -25,10 +25,10 @@ Head to the [release page](https://github.com/cupcakearmy/unpixel/releases) and
|
|||
## 🛠 Building / Development
|
||||
|
||||
1. Clone the repo
|
||||
2. `yarn install`
|
||||
3. `yarn dist` to build for all platforms
|
||||
2. `pnpm install`
|
||||
3. `pnpm dist` to build for all platforms
|
||||
|
||||
Alternatively you can run `yarn build` and the `yarn electron-builder -m` for `macOS`, `-l` fir `linux` or `-w` for `windows`.
|
||||
Alternatively you can run `pnpm build` and the `pnpm electron-builder -m` for `macOS`, `-l` fir `linux` or `-w` for `windows`.
|
||||
|
||||
## 📦 Release
|
||||
|
||||
|
|
42
package.json
42
package.json
|
@ -11,19 +11,25 @@
|
|||
"repository": {
|
||||
"url": "https://github.com/cupcakearmy/unpixel"
|
||||
},
|
||||
"version": "1.2.0",
|
||||
"version": "1.3.2",
|
||||
"main": "./dist/back/index.js",
|
||||
"engines": {
|
||||
"node": "14",
|
||||
"npm": "please-use-pnpm",
|
||||
"yarn": "please-use-pnpm"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "electron .",
|
||||
"watch:front": "parcel watch --target front --no-hmr --no-cache ./src/front/*/index.html",
|
||||
"watch:back": "parcel watch --target back --no-hmr --no-cache ./src/back/index.ts",
|
||||
"watch:front": "parcel watch --target front --no-hmr ./src/front/*/index.html",
|
||||
"watch:back": "parcel watch --target back --no-hmr ./src/back/index.ts",
|
||||
"dev": "run-p watch:*",
|
||||
"build:front": "parcel build --target front ./src/front/*/index.html",
|
||||
"build:back": "parcel build --target back ./src/back/index.ts",
|
||||
"build": "run-s build:*",
|
||||
"pack": "electron-builder -mwl",
|
||||
"pack:dev": "electron-builder -m dir && open ./out/mac/UnPixel.app",
|
||||
"dist": "rm -rf .parcel-cache dist && run-s build pack"
|
||||
"dist": "run-s clean build pack",
|
||||
"clean": "rm -rf .parcel-cache dist out"
|
||||
},
|
||||
"browserslist": [
|
||||
"last 2 Chrome versions"
|
||||
|
@ -41,10 +47,10 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"auto-launch": "^5.0.5",
|
||||
"axios": "^0.21.1",
|
||||
"dayjs": "^1.10.4",
|
||||
"electron-log": "^4.3.2",
|
||||
"electron-store": "^7.0.2",
|
||||
"axios": "^0.25.0",
|
||||
"dayjs": "^1.10.7",
|
||||
"electron-log": "^4.4.5",
|
||||
"electron-store": "^8.0.1",
|
||||
"ms": "^2.1.3",
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2",
|
||||
|
@ -53,17 +59,17 @@
|
|||
"tachyons": "^4.12.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.0.0-0",
|
||||
"@types/auto-launch": "^5.0.1",
|
||||
"@babel/core": "^7.16.10",
|
||||
"@types/auto-launch": "^5.0.2",
|
||||
"@types/ms": "^0.7.31",
|
||||
"@types/react": "^17.0.3",
|
||||
"@types/react-dom": "^17.0.3",
|
||||
"@types/semver": "^7.3.4",
|
||||
"electron": "^12.0.0",
|
||||
"electron-builder": "^22.10.5",
|
||||
"@types/react": "^17.0.38",
|
||||
"@types/react-dom": "^17.0.11",
|
||||
"@types/semver": "^7.3.9",
|
||||
"electron": "^11.5.0",
|
||||
"electron-builder": "^22.14.5",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"parcel": "^2.0.0-beta.3.1",
|
||||
"postcss": "^8.2.10",
|
||||
"typescript": "^4.2.3"
|
||||
"parcel": "^2.2.1",
|
||||
"postcss": "^8.4.5",
|
||||
"typescript": "^4.5.5"
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,13 +1,11 @@
|
|||
import { join } from 'path'
|
||||
import os from 'os'
|
||||
import { app, BrowserWindow, BrowserWindowConstructorOptions, ipcMain } from 'electron'
|
||||
import dayjs from 'dayjs'
|
||||
import logger from 'electron-log'
|
||||
import ms from 'ms'
|
||||
|
||||
import { DEV } from '.'
|
||||
import Settings from './settings'
|
||||
import TrayUtility from './tray'
|
||||
import { InputDevicesStatus } from './utils'
|
||||
|
||||
export default class Banner {
|
||||
static interval: ReturnType<typeof setInterval>
|
||||
|
@ -22,18 +20,21 @@ export default class Banner {
|
|||
})
|
||||
}
|
||||
|
||||
static shouldShow(): boolean {
|
||||
const [paused, interval] = Settings.getStatus()
|
||||
if (paused || interval > 1000) return false
|
||||
if (InputDevicesStatus.areCameraOrMicrophoneActive()) return false
|
||||
return true
|
||||
}
|
||||
|
||||
static check() {
|
||||
TrayUtility.build()
|
||||
const [paused, interval] = Settings.getStatus()
|
||||
if (!paused && interval < 1000) {
|
||||
Banner.open()
|
||||
}
|
||||
if (Banner.shouldShow()) Banner.open()
|
||||
}
|
||||
|
||||
static open() {
|
||||
if (this.window) return
|
||||
|
||||
logger.debug('Showing banner')
|
||||
const options: BrowserWindowConstructorOptions = {
|
||||
frame: false,
|
||||
webPreferences: {
|
||||
|
|
|
@ -5,12 +5,15 @@ import TrayUtility from './tray'
|
|||
import Settings from './settings'
|
||||
import Banner from './banner'
|
||||
import Updater from './updater'
|
||||
import { InputDevicesStatus } from './utils'
|
||||
|
||||
export const DEV = !app.isPackaged
|
||||
|
||||
// Enforce single instance
|
||||
const isMain = app.requestSingleInstanceLock()
|
||||
if (!isMain) app.quit()
|
||||
if (!app.requestSingleInstanceLock()) {
|
||||
logger.warn('Another instance is already running. Exiting.')
|
||||
app.quit()
|
||||
}
|
||||
|
||||
// Disable gpu
|
||||
app.disableHardwareAcceleration()
|
||||
|
@ -27,6 +30,7 @@ app
|
|||
Settings.init()
|
||||
Banner.init()
|
||||
Updater.init()
|
||||
InputDevicesStatus.init()
|
||||
logger.log('Done')
|
||||
})
|
||||
.catch((e) => {
|
||||
|
|
|
@ -19,6 +19,7 @@ const defaults = {
|
|||
lastRun: 0,
|
||||
autoClose: false,
|
||||
volume: 100,
|
||||
skipOnCameraOrMic: true,
|
||||
}
|
||||
export type SettingKeys = keyof typeof defaults
|
||||
const IntNormalizer = (x: any) => parseInt(x)
|
||||
|
@ -31,6 +32,7 @@ const normalizers: Record<SettingKeys, (x: any) => any> = {
|
|||
paused: IntNormalizer,
|
||||
lastRun: IntNormalizer,
|
||||
volume: IntNormalizer,
|
||||
skipOnCameraOrMic: BoolNormalizer,
|
||||
}
|
||||
|
||||
export default class Settings {
|
||||
|
@ -66,7 +68,7 @@ export default class Settings {
|
|||
if (this.win) return
|
||||
this.win = new BrowserWindow({
|
||||
width: 400,
|
||||
height: 630,
|
||||
height: 690,
|
||||
center: true,
|
||||
resizable: false,
|
||||
webPreferences: {
|
||||
|
|
|
@ -4,13 +4,15 @@ import ms from 'ms'
|
|||
|
||||
import Banner from './banner'
|
||||
import Settings from './settings'
|
||||
import { InputDevicesStatus } from './utils'
|
||||
|
||||
export default class TrayUtility {
|
||||
static tray: Tray | null = null
|
||||
|
||||
static build() {
|
||||
const [paused, interval] = Settings.getStatus()
|
||||
const status = paused ? `Paused for: ${ms(interval)}` : `Next break: ${ms(interval)}`
|
||||
let status = paused ? `Paused for: ${ms(interval)}` : `Next break: ${ms(interval)}`
|
||||
if (InputDevicesStatus.areCameraOrMicrophoneActive()) status = `Paused: Mic/Camera Active`
|
||||
|
||||
const template: Parameters<typeof Menu['buildFromTemplate']>[0] = [
|
||||
{ label: status, type: 'normal', enabled: false },
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
import cp from 'child_process'
|
||||
import { promisify } from 'util'
|
||||
|
||||
import Settings from './settings'
|
||||
|
||||
const exec = promisify(cp.exec)
|
||||
|
||||
export async function isCameraActive(): Promise<boolean> {
|
||||
// Not reliable
|
||||
if (process.platform === 'darwin') {
|
||||
// Check number of processes using the camera
|
||||
const out = await exec(`lsof -n | grep "AppleCamera"`)
|
||||
const processesUsingCamera = out.stdout.trim().split('\n').length
|
||||
return processesUsingCamera > 1 // One is the apple daemon that is always active
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
export async function isMicrophoneActive(): Promise<boolean> {
|
||||
if (process.platform === 'darwin') {
|
||||
const out = await exec(`ioreg -c AppleHDAEngineInput | grep "IOAudioEngineState"`)
|
||||
const parsed = parseInt(out.stdout.trim().replace(/[^\d]/gim, ''))
|
||||
return parsed > 0
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
export class InputDevicesStatus {
|
||||
static status = {
|
||||
mic: false,
|
||||
camera: false,
|
||||
}
|
||||
|
||||
static update() {
|
||||
// TODO: Update electron version as soon as issue is resolved https://github.com/electron/electron/issues/26143
|
||||
isMicrophoneActive().then((result) => (InputDevicesStatus.status.mic = result))
|
||||
isCameraActive().then((result) => (InputDevicesStatus.status.camera = result))
|
||||
}
|
||||
|
||||
static init() {
|
||||
setInterval(InputDevicesStatus.update, 2000)
|
||||
}
|
||||
|
||||
static areCameraOrMicrophoneActive(): boolean {
|
||||
if (Settings.load('skipOnCameraOrMic')) {
|
||||
return InputDevicesStatus.status.mic
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
@import 'tachyons/css/tachyons.css';
|
||||
@import '../../../node_modules/tachyons/css/tachyons.css';
|
||||
|
||||
body {
|
||||
background-color: #111;
|
||||
|
|
|
@ -8,6 +8,6 @@
|
|||
</head>
|
||||
<body>
|
||||
<main></main>
|
||||
<script src="./index.tsx"></script>
|
||||
<script type="module" src="./index.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
@import 'spectre.css/dist/spectre.min.css';
|
||||
@import 'tachyons/css/tachyons.min.css';
|
||||
@import '../../node_modules/spectre.css/dist/spectre.css';
|
||||
@import '../../node_modules/tachyons/css/tachyons.css';
|
||||
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans',
|
||||
|
|
|
@ -7,6 +7,7 @@ const labels = {
|
|||
boot: ['Start on boot'],
|
||||
autoClose: ['Close window after countdown'],
|
||||
volume: ['Chime Volume'],
|
||||
skipOnCameraOrMic: ['Pause when Mic is active'],
|
||||
}
|
||||
|
||||
const ranges: Partial<Record<keyof typeof labels, [number, number]>> = {
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
import React from 'react'
|
||||
|
||||
import '../base.css'
|
||||
|
||||
import Field from './Field'
|
||||
|
||||
const Settings = () => {
|
||||
|
@ -15,6 +13,10 @@ const Settings = () => {
|
|||
<Field setting="volume" />
|
||||
<Field setting="autoClose" />
|
||||
<Field setting="boot" />
|
||||
<Field setting="skipOnCameraOrMic" />
|
||||
<small className="ml4" style={{ position: 'relative', top: '-0.5em' }}>
|
||||
experimental & only on <i>macOS</i>
|
||||
</small>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
@ -4,9 +4,10 @@
|
|||
<meta charset="UTF-8" />
|
||||
<title>Settings</title>
|
||||
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';" />
|
||||
<link href="../base.css" rel="stylesheet" charset="utf-8" />
|
||||
</head>
|
||||
<body>
|
||||
<main></main>
|
||||
<script src="./index.tsx"></script>
|
||||
<script type="module" src="./index.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
import React from 'react'
|
||||
import { render } from 'react-dom'
|
||||
|
||||
import '../base.css'
|
||||
|
||||
import About from './About'
|
||||
import Settings from './Settings'
|
||||
import Footer from './Footer'
|
||||
|
|
Loading…
Reference in New Issue