├── demo-big.gif ├── demo-focus.gif ├── demo.gif ├── index.js ├── package.json └── readme.md /demo-big.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lucleray/hyper-opacity/01320a30a6aeacff9cc05b7999ec952835cf6beb/demo-big.gif -------------------------------------------------------------------------------- /demo-focus.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lucleray/hyper-opacity/01320a30a6aeacff9cc05b7999ec952835cf6beb/demo-focus.gif -------------------------------------------------------------------------------- /demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lucleray/hyper-opacity/01320a30a6aeacff9cc05b7999ec952835cf6beb/demo.gif -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const defaultConfig = { 2 | focus: 0.9, 3 | blur: 0.9 4 | } 5 | 6 | let opacityConfig = null 7 | const browserWindowQueue = [] 8 | const browserWindows = [] 9 | 10 | const setOpacity = win => { 11 | if (!win.isDestroyed()) { 12 | if (win.isFocused()) { 13 | win.setOpacity(opacityConfig.focus) 14 | } else { 15 | win.setOpacity(opacityConfig.blur) 16 | } 17 | win.on('blur', () => { 18 | win.setOpacity(opacityConfig.blur) 19 | }) 20 | win.on('focus', () => { 21 | win.setOpacity(opacityConfig.focus) 22 | }) 23 | } 24 | } 25 | 26 | const trySetOpacity = () => { 27 | if (opacityConfig) { 28 | let _win 29 | while ((_win = browserWindowQueue.shift())) { 30 | setOpacity(_win) 31 | } 32 | } 33 | } 34 | 35 | module.exports.decorateConfig = config => { 36 | let _opacityConfig = config.opacity 37 | 38 | if (typeof _opacityConfig === 'number') { 39 | _opacityConfig = { focus: _opacityConfig, blur: _opacityConfig } 40 | } else if (typeof _opacityConfig !== 'object') { 41 | _opacityConfig = {} 42 | } 43 | 44 | opacityConfig = Object.assign({}, defaultConfig, _opacityConfig) 45 | 46 | browserWindowQueue.push(...browserWindows) 47 | trySetOpacity() 48 | 49 | return config 50 | } 51 | 52 | module.exports.onWindow = win => { 53 | browserWindowQueue.push(win) 54 | browserWindows.push(win) 55 | trySetOpacity() 56 | } 57 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hyper-opacity", 3 | "version": "1.0.0", 4 | "keywords": ["hyper", "hyper-plugin", "opacity"], 5 | "description": "Set the opacity of your hyper window", 6 | "main": "index.js", 7 | "files": ["index.js"], 8 | "license": "MIT", 9 | "author": "lucleray", 10 | "homepage": "https://github.com/lucleray/hyper-opacity#readme", 11 | "bugs": { 12 | "url": "https://github.com/lucleray/hyper-opacity/issues" 13 | }, 14 | "repository": { 15 | "type": "git", 16 | "url": "https://github.com/lucleray/hyper-opacity.git" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | ## hyper-opacity 2 | 3 | Set the opacity of your Hyper terminal 4 | 5 | * Works on **Windows** and **MacOS** 6 | * Compatible with any theme 7 | * Simple configuration in `.hyper.js` 8 | 9 |
10 |

11 | demo 12 |

13 |
14 | 15 | ### Install 16 | 17 | `hyper i hyper-opacity` 18 | 19 | ### Configure 20 | 21 | Add a line to your hyper configuration (`~/.hyper.js`) : 22 | 23 | ```js 24 | module.exports = { 25 | config: { 26 | // rest of the config 27 | opacity: 0.85 28 | } 29 | // rest of the file 30 | } 31 | ``` 32 | 33 | ### Configure the opacity for focused/unfocused windows 34 | 35 | ```js 36 | module.exports = { 37 | config: { 38 | // rest of the config 39 | opacity: { 40 | focus: 0.9, 41 | blur: 0.5 42 | } 43 | } 44 | // rest of the file 45 | } 46 | ``` 47 | 48 |
49 |

50 | demo focused window 51 |

52 |
53 | 54 | ### More 55 | 56 | **hyper-opacity** uses [BrowserWindow.setOpacity()](https://electronjs.org/docs/api/browser-window#winsetopacityopacity-windows-macos). 57 | --------------------------------------------------------------------------------