mirror of
https://github.com/cupcakearmy/unpixel.git
synced 2026-04-02 12:25:22 +00:00
Compare commits
29 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 49afc7fccd | |||
| f1c0ab6dbb | |||
| 53c16e7063 | |||
| 2606214e53 | |||
| f5ecebb61a | |||
| 3129030d00 | |||
| e237eefc94 | |||
| 48cd3f1905 | |||
| 27ec42fecd | |||
| 604f021ce2 | |||
| 6e5cb4ef4f | |||
| 0434d3dc55 | |||
| 1856024419 | |||
| 6fba47a4f8 | |||
|
|
41f1cd691a | ||
| 928b69b4fb | |||
| b17f5db58e | |||
| 064287c34f | |||
| 317c88641d | |||
| 39398da265 | |||
| c045ab43bf | |||
| 67276e0119 | |||
| 50a24f847f | |||
| 72ee5d7641 | |||
| 46704211fa | |||
| 5a5a2755f1 | |||
| f5741e381d | |||
| eeae431e79 | |||
| 30319197c6 |
20
.github/workflows/release.yml
vendored
Normal file
20
.github/workflows/release.yml
vendored
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
name: Main
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: macos-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-node@v2
|
||||||
|
with:
|
||||||
|
node-version: "14"
|
||||||
|
- name: Install dependencies
|
||||||
|
run: yarn install --frozen-lockfile
|
||||||
|
- name: Build
|
||||||
|
run: yarn run dist
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
30
CHANGELOG.md
Normal file
30
CHANGELOG.md
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
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.1.2] - 2021-05-31
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- 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
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Settings page not opening
|
||||||
|
|
||||||
|
## [1.1.0] - 2021-05-15
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Only pause for a limited time
|
||||||
|
- Volume slider for the sound
|
||||||
21
README.md
21
README.md
@@ -14,6 +14,25 @@ To combat and alleviate the symptoms there is the famous 20/20/20 rule that aims
|
|||||||
|
|
||||||
This is not medical advice. Read more [here](https://en.wikipedia.org/wiki/Computer_vision_syndrome) and [here](https://www.aoa.org/healthy-eyes/eye-and-vision-conditions/computer-vision-syndrome).
|
This is not medical advice. Read more [here](https://en.wikipedia.org/wiki/Computer_vision_syndrome) and [here](https://www.aoa.org/healthy-eyes/eye-and-vision-conditions/computer-vision-syndrome).
|
||||||
|
|
||||||
## 📦 Install
|
## 💻 Installation
|
||||||
|
|
||||||
Head to the [release page](https://github.com/cupcakearmy/unpixel/releases) and grab the latest for your platform.
|
Head to the [release page](https://github.com/cupcakearmy/unpixel/releases) and grab the latest for your platform.
|
||||||
|
|
||||||
|
- For `macOS` you can downlaod the `.dmg` image.
|
||||||
|
- For `Windows` download the `.exe`.
|
||||||
|
- For `Linux` either the `.AppImage` or `.deb`, you will know what fits you 😉.
|
||||||
|
|
||||||
|
## 🛠 Building / Development
|
||||||
|
|
||||||
|
1. Clone the repo
|
||||||
|
2. `yarn install`
|
||||||
|
3. `yarn 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`.
|
||||||
|
|
||||||
|
## 📦 Release
|
||||||
|
|
||||||
|
1. Bump version in `package.json`
|
||||||
|
2. Update `CHANGELOG.md`
|
||||||
|
3. Create a draft release with the new version. (e.g. tag with `v1.2.3`).
|
||||||
|
4. Start the publish action and the ci will build and upload assets to the draft matching the version of `package.json` and draft.
|
||||||
|
|||||||
BIN
assets/tray.png
BIN
assets/tray.png
Binary file not shown.
|
Before Width: | Height: | Size: 45 KiB After Width: | Height: | Size: 16 KiB |
@@ -1,14 +1,18 @@
|
|||||||
appId: "io.nicco.app.unpixel"
|
appId: "io.nicco.app.unpixel"
|
||||||
# productName: "UnPixel"
|
|
||||||
files:
|
files:
|
||||||
- assets
|
- assets
|
||||||
- dist
|
- dist
|
||||||
directories:
|
directories:
|
||||||
output: "./out"
|
output: "./out"
|
||||||
mac:
|
mac:
|
||||||
target: "dmg"
|
target:
|
||||||
|
- dmg
|
||||||
identity: null
|
identity: null
|
||||||
win:
|
win:
|
||||||
target: "nsis"
|
target:
|
||||||
|
- nsis
|
||||||
linux:
|
linux:
|
||||||
category: "Utility"
|
category: "Utility"
|
||||||
|
target:
|
||||||
|
- AppImage
|
||||||
|
- deb
|
||||||
16
package.json
16
package.json
@@ -11,18 +11,18 @@
|
|||||||
"repository": {
|
"repository": {
|
||||||
"url": "https://github.com/cupcakearmy/unpixel"
|
"url": "https://github.com/cupcakearmy/unpixel"
|
||||||
},
|
},
|
||||||
"version": "1.0.0",
|
"version": "1.1.2",
|
||||||
"main": "./dist/back/index.js",
|
"main": "./dist/back/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "electron .",
|
"start": "electron .",
|
||||||
"watch:front": "parcel watch --target front --no-hmr --no-cache ./src/front/banner/index.html ./src/front/settings/index.html",
|
"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:back": "parcel watch --target back --no-hmr --no-cache ./src/back/index.ts",
|
||||||
"dev": "run-p watch:*",
|
"dev": "run-p watch:*",
|
||||||
"build:front": "parcel build --target front ./src/front/banner/index.html ./src/front/settings/index.html",
|
"build:front": "parcel build --target front ./src/front/*/index.html",
|
||||||
"build:back": "parcel build --target back ./src/back/index.ts",
|
"build:back": "parcel build --target back ./src/back/index.ts",
|
||||||
"build": "run-s build:*",
|
"build": "run-s build:*",
|
||||||
"pack": "electron-builder -mwl",
|
"pack": "electron-builder -mwl",
|
||||||
"pack:dev": "electron-builder -m",
|
"pack:dev": "electron-builder -m dir && open ./out/mac/UnPixel.app",
|
||||||
"dist": "rm -rf .parcel-cache dist && run-s build pack"
|
"dist": "rm -rf .parcel-cache dist && run-s build pack"
|
||||||
},
|
},
|
||||||
"browserslist": [
|
"browserslist": [
|
||||||
@@ -45,6 +45,7 @@
|
|||||||
"dayjs": "^1.10.4",
|
"dayjs": "^1.10.4",
|
||||||
"electron-log": "^4.3.2",
|
"electron-log": "^4.3.2",
|
||||||
"electron-store": "^7.0.2",
|
"electron-store": "^7.0.2",
|
||||||
|
"ms": "^2.1.3",
|
||||||
"react": "^17.0.2",
|
"react": "^17.0.2",
|
||||||
"react-dom": "^17.0.2",
|
"react-dom": "^17.0.2",
|
||||||
"semver": "^7.3.5",
|
"semver": "^7.3.5",
|
||||||
@@ -53,13 +54,16 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.0.0-0",
|
"@babel/core": "^7.0.0-0",
|
||||||
|
"@types/auto-launch": "^5.0.1",
|
||||||
|
"@types/ms": "^0.7.31",
|
||||||
"@types/react": "^17.0.3",
|
"@types/react": "^17.0.3",
|
||||||
"@types/react-dom": "^17.0.3",
|
"@types/react-dom": "^17.0.3",
|
||||||
|
"@types/semver": "^7.3.4",
|
||||||
"electron": "^12.0.0",
|
"electron": "^12.0.0",
|
||||||
"electron-builder": "^22.10.5",
|
"electron-builder": "^22.10.5",
|
||||||
"npm-run-all": "^4.1.5",
|
"npm-run-all": "^4.1.5",
|
||||||
"parcel": "next",
|
"parcel": "^2.0.0-beta.3.1",
|
||||||
"postcss": "^8.2.9",
|
"postcss": "^8.2.10",
|
||||||
"typescript": "^4.2.3"
|
"typescript": "^4.2.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
import dayjs from 'dayjs'
|
|
||||||
import { BrowserWindow, BrowserWindowConstructorOptions, ipcMain } from 'electron'
|
|
||||||
import { join } from 'path'
|
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 logger from 'electron-log'
|
||||||
|
import ms from 'ms'
|
||||||
|
|
||||||
import { DEV } from '.'
|
import { DEV } from '.'
|
||||||
import Settings from './settings'
|
import Settings from './settings'
|
||||||
@@ -14,24 +16,16 @@ export default class Banner {
|
|||||||
static init() {
|
static init() {
|
||||||
if (this.interval) return
|
if (this.interval) return
|
||||||
this.interval = setInterval(this.check, 1000)
|
this.interval = setInterval(this.check, 1000)
|
||||||
|
this.check()
|
||||||
ipcMain.on('close', () => {
|
ipcMain.on('close', () => {
|
||||||
this.close()
|
this.close()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
static check() {
|
static check() {
|
||||||
const paused: boolean = Settings.load('paused')
|
TrayUtility.build()
|
||||||
if (paused) {
|
const [paused, interval] = Settings.getStatus()
|
||||||
TrayUtility.setStatus('Paused')
|
if (!paused && interval < 1000) {
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const every = Settings.load('every')
|
|
||||||
const now = dayjs()
|
|
||||||
const lastRun = Settings.load('lastRun')
|
|
||||||
const diff = every - now.diff(dayjs(lastRun), 'minutes')
|
|
||||||
TrayUtility.setStatus(`Next break: ${diff}m`)
|
|
||||||
if (diff < 1) {
|
|
||||||
Banner.open()
|
Banner.open()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -48,35 +42,31 @@ export default class Banner {
|
|||||||
},
|
},
|
||||||
width: 1200,
|
width: 1200,
|
||||||
height: 600,
|
height: 600,
|
||||||
}
|
|
||||||
if (!DEV) {
|
|
||||||
Object.assign(options, {
|
|
||||||
resizable: false,
|
|
||||||
movable: false,
|
|
||||||
simpleFullscreen: true,
|
|
||||||
fullscreen: true,
|
fullscreen: true,
|
||||||
transparent: true,
|
simpleFullscreen: os.platform() === 'darwin',
|
||||||
})
|
|
||||||
}
|
}
|
||||||
this.window = new BrowserWindow(options)
|
this.window = new BrowserWindow(options)
|
||||||
|
|
||||||
const entry = join(__dirname, '../front/banner/index.html')
|
const entry = join(__dirname, '../front/banner/index.html')
|
||||||
this.window.loadFile(entry)
|
this.window.loadFile(entry)
|
||||||
|
|
||||||
if (!DEV) {
|
if (DEV) {
|
||||||
this.window.maximize()
|
this.window.webContents.toggleDevTools()
|
||||||
|
} else {
|
||||||
this.window.setAlwaysOnTop(true, 'floating', 99)
|
this.window.setAlwaysOnTop(true, 'floating', 99)
|
||||||
this.window.setVisibleOnAllWorkspaces(true, { visibleOnFullScreen: true })
|
this.window.setVisibleOnAllWorkspaces(true, { visibleOnFullScreen: true })
|
||||||
this.window.setFullScreenable(false)
|
this.window.setMovable(false)
|
||||||
} else {
|
this.window.setResizable(false)
|
||||||
this.window.webContents.toggleDevTools()
|
|
||||||
}
|
|
||||||
this.window.focus()
|
this.window.focus()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static close() {
|
static close() {
|
||||||
if (this.window) {
|
if (this.window) {
|
||||||
Settings.save('lastRun', Date.now())
|
Settings.save('lastRun', Date.now())
|
||||||
|
this.window.minimize()
|
||||||
|
this.window.hide()
|
||||||
|
if (process.platform === 'darwin') app.hide()
|
||||||
this.window.close()
|
this.window.close()
|
||||||
this.window = null
|
this.window = null
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,10 @@ import Updater from './updater'
|
|||||||
|
|
||||||
export const DEV = !app.isPackaged
|
export const DEV = !app.isPackaged
|
||||||
|
|
||||||
|
// Enforce single instance
|
||||||
|
const isMain = app.requestSingleInstanceLock()
|
||||||
|
if (!isMain) app.quit()
|
||||||
|
|
||||||
// Disable gpu
|
// Disable gpu
|
||||||
app.disableHardwareAcceleration()
|
app.disableHardwareAcceleration()
|
||||||
app.commandLine.appendSwitch('disable-software-rasterizer')
|
app.commandLine.appendSwitch('disable-software-rasterizer')
|
||||||
@@ -18,7 +22,7 @@ app
|
|||||||
.whenReady()
|
.whenReady()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
logger.log('Initializing')
|
logger.log('Initializing')
|
||||||
if (!DEV) app.dock.hide()
|
if (!DEV) app.dock?.hide()
|
||||||
TrayUtility.init()
|
TrayUtility.init()
|
||||||
Settings.init()
|
Settings.init()
|
||||||
Banner.init()
|
Banner.init()
|
||||||
|
|||||||
@@ -8,15 +8,17 @@ import { productName } from '../../package.json'
|
|||||||
const autoLaunch = new AutoLaunch({ name: productName, mac: { useLaunchAgent: true } })
|
const autoLaunch = new AutoLaunch({ name: productName, mac: { useLaunchAgent: true } })
|
||||||
|
|
||||||
import { DEV } from '.'
|
import { DEV } from '.'
|
||||||
|
import dayjs from 'dayjs'
|
||||||
|
|
||||||
const store = new Store()
|
const store = new Store()
|
||||||
const defaults = {
|
const defaults = {
|
||||||
every: 20,
|
every: 20,
|
||||||
duration: 20,
|
duration: 20,
|
||||||
boot: true,
|
boot: true,
|
||||||
paused: false,
|
paused: 0,
|
||||||
lastRun: 0,
|
lastRun: 0,
|
||||||
autoClose: false,
|
autoClose: false,
|
||||||
|
volume: 100,
|
||||||
}
|
}
|
||||||
export type SettingKeys = keyof typeof defaults
|
export type SettingKeys = keyof typeof defaults
|
||||||
const IntNormalizer = (x: any) => parseInt(x)
|
const IntNormalizer = (x: any) => parseInt(x)
|
||||||
@@ -26,8 +28,9 @@ const normalizers: Record<SettingKeys, (x: any) => any> = {
|
|||||||
duration: IntNormalizer,
|
duration: IntNormalizer,
|
||||||
boot: BoolNormalizer,
|
boot: BoolNormalizer,
|
||||||
autoClose: BoolNormalizer,
|
autoClose: BoolNormalizer,
|
||||||
paused: BoolNormalizer,
|
paused: IntNormalizer,
|
||||||
lastRun: IntNormalizer,
|
lastRun: IntNormalizer,
|
||||||
|
volume: IntNormalizer,
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class Settings {
|
export default class Settings {
|
||||||
@@ -63,7 +66,7 @@ export default class Settings {
|
|||||||
if (this.win) return
|
if (this.win) return
|
||||||
this.win = new BrowserWindow({
|
this.win = new BrowserWindow({
|
||||||
width: 400,
|
width: 400,
|
||||||
height: 575,
|
height: 630,
|
||||||
center: true,
|
center: true,
|
||||||
resizable: false,
|
resizable: false,
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
@@ -71,14 +74,29 @@ export default class Settings {
|
|||||||
contextIsolation: false,
|
contextIsolation: false,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
this.win.on('closed', () => (this.win = null))
|
||||||
|
|
||||||
const entry = join(__dirname, '../front/settings/index.html')
|
const entry = join(__dirname, '../front/settings/index.html')
|
||||||
Settings.win.loadFile(entry)
|
this.win.loadFile(entry)
|
||||||
|
this.win.setMenu(null)
|
||||||
|
|
||||||
if (DEV) {
|
if (DEV) {
|
||||||
Settings.win.setSize(800, 485)
|
this.win.setSize(800, 485)
|
||||||
Settings.win.setResizable(true)
|
this.win.setResizable(true)
|
||||||
Settings.win.webContents.openDevTools()
|
this.win.webContents.openDevTools()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static getStatus(): [boolean, number] {
|
||||||
|
const paused: number = this.load('paused')
|
||||||
|
const now = Date.now()
|
||||||
|
if (paused > now) {
|
||||||
|
return [true, paused - now]
|
||||||
|
}
|
||||||
|
|
||||||
|
const every = Settings.load('every')
|
||||||
|
const lastRun = Settings.load('lastRun')
|
||||||
|
const diff = every * 60 * 1000 - dayjs(now).diff(dayjs(lastRun), 'ms')
|
||||||
|
return [false, diff]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,64 +1,71 @@
|
|||||||
import { Tray, Menu, nativeImage } from 'electron'
|
import { Tray, Menu, nativeImage } from 'electron'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
|
import ms from 'ms'
|
||||||
|
|
||||||
import Banner from './banner'
|
import Banner from './banner'
|
||||||
import Settings from './settings'
|
import Settings from './settings'
|
||||||
|
|
||||||
enum Items {
|
|
||||||
Status = 'status',
|
|
||||||
Pause = 'pause',
|
|
||||||
Run = 'run',
|
|
||||||
}
|
|
||||||
|
|
||||||
export default class TrayUtility {
|
export default class TrayUtility {
|
||||||
static menu: Parameters<typeof Menu['buildFromTemplate']>[0] = [
|
static tray: Tray | null = null
|
||||||
{ label: 'Status', type: 'normal', enabled: false, id: Items.Status },
|
|
||||||
|
static build() {
|
||||||
|
const [paused, interval] = Settings.getStatus()
|
||||||
|
const status = paused ? `Paused for: ${ms(interval)}` : `Next break: ${ms(interval)}`
|
||||||
|
|
||||||
|
const template: Parameters<typeof Menu['buildFromTemplate']>[0] = [
|
||||||
|
{ label: status, type: 'normal', enabled: false },
|
||||||
{ type: 'separator' },
|
{ type: 'separator' },
|
||||||
{
|
{
|
||||||
label: 'Take a break now',
|
label: 'Take a break now',
|
||||||
type: 'normal',
|
type: 'normal',
|
||||||
id: Items.Run,
|
|
||||||
click: () => Banner.open(),
|
click: () => Banner.open(),
|
||||||
},
|
},
|
||||||
{ label: 'Pause', type: 'checkbox', id: Items.Pause },
|
|
||||||
{ label: 'Settings', type: 'normal', click: () => Settings.open() },
|
|
||||||
{ type: 'separator' },
|
|
||||||
{ label: 'Quit', type: 'normal', role: 'quit' },
|
|
||||||
]
|
]
|
||||||
|
|
||||||
static tray: Tray | null = null
|
template.push(
|
||||||
|
paused
|
||||||
|
? {
|
||||||
|
label: 'Break pause',
|
||||||
|
click: () => {
|
||||||
|
Settings.save('paused', 0)
|
||||||
|
this.build()
|
||||||
|
},
|
||||||
|
}
|
||||||
|
: {
|
||||||
|
label: 'Pause for...',
|
||||||
|
submenu: Menu.buildFromTemplate(
|
||||||
|
// Minutes to pause
|
||||||
|
[10, 30, 60, 120, 360]
|
||||||
|
.map((minutes) => minutes * 60 * 1000)
|
||||||
|
.map((time) => ({
|
||||||
|
label: ms(time),
|
||||||
|
click: () => {
|
||||||
|
Settings.save('paused', Date.now() + time)
|
||||||
|
this.build()
|
||||||
|
},
|
||||||
|
}))
|
||||||
|
),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
static setStatus(status: string) {
|
template.push(
|
||||||
this.menu[0].label = status
|
{ label: 'Settings', click: () => Settings.open() },
|
||||||
this.tray.setContextMenu(this.build())
|
{ type: 'separator' },
|
||||||
}
|
{ label: 'Quit', role: 'quit' }
|
||||||
|
)
|
||||||
|
|
||||||
private static build() {
|
const menu = Menu.buildFromTemplate(template)
|
||||||
const menu = Menu.buildFromTemplate(this.menu)
|
this.tray?.setContextMenu(menu)
|
||||||
for (const item of menu.items) {
|
|
||||||
if (item.id === Items.Pause) {
|
|
||||||
let initial = Settings.load('paused')
|
|
||||||
item.checked = initial
|
|
||||||
item.click = () => {
|
|
||||||
initial = !initial
|
|
||||||
item.checked = initial
|
|
||||||
Settings.save('paused', initial)
|
|
||||||
}
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return menu
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static init() {
|
static init() {
|
||||||
if (!this.tray) {
|
if (!this.tray) {
|
||||||
const file = path.join(__dirname, '../../assets/tray.png')
|
const file = path.join(__dirname, '../../assets/tray.png')
|
||||||
const icon = nativeImage.createFromPath(file).resize({
|
const resized = nativeImage.createFromPath(file).resize({ width: 24, height: 24 })
|
||||||
width: 24,
|
resized.setTemplateImage(true)
|
||||||
height: 24,
|
resized.isMacTemplateImage = true
|
||||||
})
|
this.tray = new Tray(resized)
|
||||||
this.tray = new Tray(icon)
|
this.build()
|
||||||
this.tray.setContextMenu(this.build())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,10 +4,11 @@ import logger from 'electron-log'
|
|||||||
import { dialog, shell } from 'electron'
|
import { dialog, shell } from 'electron'
|
||||||
|
|
||||||
import pkg from '../../package.json'
|
import pkg from '../../package.json'
|
||||||
|
import Banner from './banner'
|
||||||
|
|
||||||
const current = semver.coerce(pkg.version)
|
const current = semver.coerce(pkg.version)
|
||||||
const url = 'https://api.github.com/repos/cupcakearmy/unpixel/tags'
|
const url = 'https://api.github.com/repos/cupcakearmy/unpixel/tags'
|
||||||
const interval = 1000 * 60 * 60 * 10 // 10 Minutes
|
const interval = 1000 * 60 * 15 // 10 Minutes
|
||||||
|
|
||||||
export default class Updater {
|
export default class Updater {
|
||||||
static init() {
|
static init() {
|
||||||
@@ -20,11 +21,14 @@ export default class Updater {
|
|||||||
url,
|
url,
|
||||||
})
|
})
|
||||||
// parse tags and reverse sort them to get the highest
|
// parse tags and reverse sort them to get the highest
|
||||||
const tags = data.map((d) => semver.coerce(d.name)).sort(semver.rcompare)
|
const tags = data.map((d: any) => semver.coerce(d.name)).sort(semver.rcompare)
|
||||||
const latest = tags[0]
|
const latest = tags[0]
|
||||||
|
if (!current) throw new Error('Could not determine current version')
|
||||||
if (semver.lt(current, latest)) {
|
if (semver.lt(current, latest)) {
|
||||||
logger.info('New version available')
|
logger.info('New version available')
|
||||||
|
Banner.close()
|
||||||
dialog
|
dialog
|
||||||
|
// @ts-ignore
|
||||||
.showMessageBox(null, {
|
.showMessageBox(null, {
|
||||||
title: 'Update available',
|
title: 'Update available',
|
||||||
message: 'A newer version is available, please download.',
|
message: 'A newer version is available, please download.',
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
console.log('test')
|
|
||||||
|
|
||||||
import { ipcRenderer } from 'electron'
|
import { ipcRenderer } from 'electron'
|
||||||
import React, { useCallback, useEffect, useRef, useState } from 'react'
|
import React, { useCallback, useEffect, useRef, useState } from 'react'
|
||||||
import { render } from 'react-dom'
|
import { render } from 'react-dom'
|
||||||
@@ -7,15 +5,17 @@ import { render } from 'react-dom'
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import chime from 'url:../assets/chime.mp3'
|
import chime from 'url:../assets/chime.mp3'
|
||||||
|
|
||||||
const useKeyPress = (handler) => {
|
const useKeyPress = (handler: (e: KeyboardEvent) => void) => {
|
||||||
const handlerRef = useRef<(e: KeyboardEvent) => void>()
|
const handlerRef = useRef<typeof handler>()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
handlerRef.current = handler
|
handlerRef.current = handler
|
||||||
}, [handler])
|
}, [handler])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fn = (event) => handlerRef.current(event)
|
const fn = (event: KeyboardEvent) => {
|
||||||
|
if (handlerRef.current) handlerRef.current(event)
|
||||||
|
}
|
||||||
window.addEventListener('keydown', fn)
|
window.addEventListener('keydown', fn)
|
||||||
return () => {
|
return () => {
|
||||||
window.removeEventListener('keydown', fn)
|
window.removeEventListener('keydown', fn)
|
||||||
@@ -50,6 +50,8 @@ const Banner: React.FC = () => {
|
|||||||
setTimeout(() => setCountdown(countdown - 1), 1000)
|
setTimeout(() => setCountdown(countdown - 1), 1000)
|
||||||
} else {
|
} else {
|
||||||
const audio = new Audio(chime)
|
const audio = new Audio(chime)
|
||||||
|
const volume = ipcRenderer.sendSync('load', { key: 'volume' })
|
||||||
|
audio.volume = volume / 100
|
||||||
audio.play()
|
audio.play()
|
||||||
setDone(true)
|
setDone(true)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
/* @import 'hiq/dist/hiq.css'; */
|
|
||||||
@import 'spectre.css/dist/spectre.min.css';
|
@import 'spectre.css/dist/spectre.min.css';
|
||||||
@import 'tachyons/css/tachyons.min.css';
|
@import 'tachyons/css/tachyons.min.css';
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React, { useCallback } from 'react'
|
import React from 'react'
|
||||||
|
|
||||||
import Link from './ExternalLink'
|
import Link from './ExternalLink'
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,18 @@ const labels = {
|
|||||||
duration: ['For', 'seconds'],
|
duration: ['For', 'seconds'],
|
||||||
boot: ['Start on boot'],
|
boot: ['Start on boot'],
|
||||||
autoClose: ['Close window after countdown'],
|
autoClose: ['Close window after countdown'],
|
||||||
|
volume: ['Chime Volume'],
|
||||||
|
}
|
||||||
|
|
||||||
|
const ranges: Partial<Record<keyof typeof labels, [number, number]>> = {
|
||||||
|
every: [1, 60],
|
||||||
|
duration: [1, 60],
|
||||||
|
volume: [0, 100],
|
||||||
|
}
|
||||||
|
|
||||||
|
function getRange(key: keyof typeof labels): [number, number] {
|
||||||
|
const range = ranges[key]
|
||||||
|
return range || [0, 0]
|
||||||
}
|
}
|
||||||
|
|
||||||
const Field: React.FC<{ setting: keyof typeof labels }> = ({ setting: key }) => {
|
const Field: React.FC<{ setting: keyof typeof labels }> = ({ setting: key }) => {
|
||||||
@@ -39,8 +51,8 @@ const Field: React.FC<{ setting: keyof typeof labels }> = ({ setting: key }) =>
|
|||||||
className="mt0 mb3"
|
className="mt0 mb3"
|
||||||
type="range"
|
type="range"
|
||||||
id={key}
|
id={key}
|
||||||
min="1"
|
min={getRange(key)[0]}
|
||||||
max="60"
|
max={getRange(key)[1]}
|
||||||
step="1"
|
step="1"
|
||||||
value={value}
|
value={value}
|
||||||
onChange={(e) => setValue(parseInt(e.target.value))}
|
onChange={(e) => setValue(parseInt(e.target.value))}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ const Footer: React.FC = () => {
|
|||||||
<div className="flex justify-center items-center">
|
<div className="flex justify-center items-center">
|
||||||
<Link link="https://github.com/cupcakearmy" text="Github" />
|
<Link link="https://github.com/cupcakearmy" text="Github" />
|
||||||
<div className="ph1"> - </div>
|
<div className="ph1"> - </div>
|
||||||
<Link link="https://nicco.io/support" text="Support" />
|
<Link link="https://nicco.io/support" text="Support / Donate" />
|
||||||
</div>
|
</div>
|
||||||
<div className="code o-20 mt1">
|
<div className="code o-20 mt1">
|
||||||
<small>version: {version}</small>
|
<small>version: {version}</small>
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ const Settings = () => {
|
|||||||
<fieldset className="ma0 pa0">
|
<fieldset className="ma0 pa0">
|
||||||
<Field setting="every" />
|
<Field setting="every" />
|
||||||
<Field setting="duration" />
|
<Field setting="duration" />
|
||||||
|
<Field setting="volume" />
|
||||||
<Field setting="autoClose" />
|
<Field setting="autoClose" />
|
||||||
<Field setting="boot" />
|
<Field setting="boot" />
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|||||||
72
tsconfig.json
Normal file
72
tsconfig.json
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
/* Visit https://aka.ms/tsconfig.json to read more about this file */
|
||||||
|
|
||||||
|
/* Basic Options */
|
||||||
|
// "incremental": true, /* Enable incremental compilation */
|
||||||
|
"target": "es2018" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */,
|
||||||
|
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */,
|
||||||
|
// "lib": [], /* Specify library files to be included in the compilation. */
|
||||||
|
// "allowJs": true, /* Allow javascript files to be compiled. */
|
||||||
|
// "checkJs": true, /* Report errors in .js files. */
|
||||||
|
"jsx": "react" /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */,
|
||||||
|
// "declaration": true, /* Generates corresponding '.d.ts' file. */
|
||||||
|
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
|
||||||
|
// "sourceMap": true, /* Generates corresponding '.map' file. */
|
||||||
|
// "outFile": "./", /* Concatenate and emit output to single file. */
|
||||||
|
// "outDir": "./", /* Redirect output structure to the directory. */
|
||||||
|
"rootDir": "./src" /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */,
|
||||||
|
// "composite": true, /* Enable project compilation */
|
||||||
|
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
|
||||||
|
// "removeComments": true, /* Do not emit comments to output. */
|
||||||
|
// "noEmit": true, /* Do not emit outputs. */
|
||||||
|
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
|
||||||
|
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
|
||||||
|
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
|
||||||
|
|
||||||
|
/* Strict Type-Checking Options */
|
||||||
|
"strict": true /* Enable all strict type-checking options. */,
|
||||||
|
"noImplicitAny": true /* Raise error on expressions and declarations with an implied 'any' type. */,
|
||||||
|
"strictNullChecks": true /* Enable strict null checks. */,
|
||||||
|
"strictFunctionTypes": true /* Enable strict checking of function types. */,
|
||||||
|
"strictBindCallApply": true /* Enable strict 'bind', 'call', and 'apply' methods on functions. */,
|
||||||
|
"strictPropertyInitialization": true /* Enable strict checking of property initialization in classes. */,
|
||||||
|
"noImplicitThis": true /* Raise error on 'this' expressions with an implied 'any' type. */,
|
||||||
|
"alwaysStrict": true /* Parse in strict mode and emit "use strict" for each source file. */,
|
||||||
|
|
||||||
|
/* Additional Checks */
|
||||||
|
// "noUnusedLocals": true, /* Report errors on unused locals. */
|
||||||
|
// "noUnusedParameters": true, /* Report errors on unused parameters. */
|
||||||
|
"noImplicitReturns": true /* Report error when not all code paths in function return a value. */,
|
||||||
|
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
||||||
|
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
|
||||||
|
// "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */
|
||||||
|
|
||||||
|
/* Module Resolution Options */
|
||||||
|
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
|
||||||
|
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
|
||||||
|
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
|
||||||
|
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
||||||
|
// "typeRoots": [], /* List of folders to include type definitions from. */
|
||||||
|
// "types": [], /* Type declaration files to be included in compilation. */
|
||||||
|
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
||||||
|
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
|
||||||
|
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
|
||||||
|
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
||||||
|
"resolveJsonModule": true,
|
||||||
|
|
||||||
|
/* Source Map Options */
|
||||||
|
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
|
||||||
|
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
||||||
|
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
|
||||||
|
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
|
||||||
|
|
||||||
|
/* Experimental Options */
|
||||||
|
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
|
||||||
|
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
|
||||||
|
|
||||||
|
/* Advanced Options */
|
||||||
|
"skipLibCheck": true /* Skip type checking of declaration files. */,
|
||||||
|
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user