Skip to content
This repository was archived by the owner on Jan 8, 2022. It is now read-only.
Open
Show file tree
Hide file tree
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
16 changes: 4 additions & 12 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,18 @@ jobs:

steps:
- name: Check out Git repository
uses: actions/checkout@v1
uses: actions/checkout@v4

- name: Install Node.js, NPM and Yarn
uses: actions/setup-node@v1
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 12
node-version: 22

- name: Install dependencies
run: npm install

- name: Test
run: npm test

- name: Build/release Electron app
uses: samuelmeuli/action-electron-builder@v1
with:
# GitHub token, automatically provided to the action
# (No need to define this secret in the repo settings)
github_token: ${{ secrets.GITHUB_TOKEN }}

# If the commit is tagged with a version (e.g. "v1.0.0"),
# release the app after building
release: ${{ startsWith(github.ref, 'refs/tags/v') || contains(github.event.head_commit.message, '/release') }}
28 changes: 28 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Build/test

on:
push:
pull_request:

jobs:
test:
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]

steps:
- name: Check out Git repository
uses: actions/checkout@v4

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 22

- name: Install dependencies
run: npm install

- name: Test
run: npm test
4 changes: 2 additions & 2 deletions README-ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ Windowsでは、トレイのアイコンをクリックすると、ウィンド

### グローバルショートカット

<!--Use <kbd>Ctrl+Shift+D</kbd> (or <kbd>Command+Shift+D</kbd> on macOS) to toggle the app.-->
<kbd>Ctrl+Shift+D</kbd> (macOSでは<kbd>Command+Shift+D</kbd>)を押すと、アプリを切り替えします。
<!--Use <kbd>Alt+Space</kbd> to toggle the app.-->
<kbd>Alt+Space</kbd> を押すと、アプリを切り替えします。

## ダウンロード

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Please consider [sponsoring me](http://github.com/sponsors/egoist) to accelerate

### Global shortcut

Use <kbd>Ctrl+Shift+D</kbd> (or <kbd>Command+Shift+D</kbd> on macOS) to toggle the app.
Use <kbd>Alt+Space</kbd> to toggle the app.

## Install

Expand Down
60 changes: 47 additions & 13 deletions app/config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,48 @@
const Config = require('electron-store')

module.exports = new Config({
defaults: {
lastWindowState: {
width: 800,
height: 600
},
shortcut: {
toggleApp: null
},
mode: 'dark'
const path = require('path')
const fs = require('fs')
const { app } = require('electron')

const configPath = path.join(app.getPath('userData'), 'config.json')

const defaults = {
lastWindowState: { width: 800, height: 600 },
shortcut: { toggleApp: 'alt+space' },
mode: 'dark'
}

let data

function load() {
data = { ...defaults }
try {
if (fs.existsSync(configPath)) {
data = { ...defaults, ...JSON.parse(fs.readFileSync(configPath, 'utf8')) }
}
} catch (err) {
console.error('Failed to load config, using defaults:', err.message)
}
}

function save() {
try {
fs.writeFileSync(configPath, JSON.stringify(data, null, 2), 'utf8')
} catch (err) {
console.error('Failed to save config, write error:', err.message)
}
}

load()

module.exports = {
get(key) {
return data[key]
},
set(key, value) {
data[key] = value
save()
},
delete(key) {
delete data[key]
save()
}
})
}
Loading