├── images ├── oh.png ├── oh@2x.png ├── hidden.png ├── visible.png ├── hidden@2x.png └── visible@2x.png ├── .gitignore ├── package.json ├── README.md └── index.js /images/oh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/siddharthkp/toggle-icons/HEAD/images/oh.png -------------------------------------------------------------------------------- /images/oh@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/siddharthkp/toggle-icons/HEAD/images/oh@2x.png -------------------------------------------------------------------------------- /images/hidden.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/siddharthkp/toggle-icons/HEAD/images/hidden.png -------------------------------------------------------------------------------- /images/visible.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/siddharthkp/toggle-icons/HEAD/images/visible.png -------------------------------------------------------------------------------- /images/hidden@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/siddharthkp/toggle-icons/HEAD/images/hidden@2x.png -------------------------------------------------------------------------------- /images/visible@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/siddharthkp/toggle-icons/HEAD/images/visible@2x.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | *.log 3 | npm-debug.log* 4 | 5 | # Dependency directories 6 | node_modules/ 7 | 8 | # Optional npm cache directory 9 | .npm 10 | 11 | # dotenv environment variables file 12 | .env 13 | 14 | releases 15 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "toggle-icons", 3 | "productName": "Toggle Icons", 4 | "version": "1.0.0", 5 | "description": "", 6 | "main": "index.js", 7 | "dependencies": { 8 | "execa": "0.10.0", 9 | "menubar": "5.2.3" 10 | }, 11 | "devDependencies": { 12 | "electron": "2.0.4", 13 | "electron-packager": "12.1.0", 14 | "electron-reload": "1.2.5" 15 | }, 16 | "scripts": { 17 | "dev": "electron .", 18 | "build": "electron-packager . --out releases --overwrite --files=[images/*] --icon=build/icon.icns" 19 | }, 20 | "keywords": [], 21 | "author": "siddharthkp", 22 | "license": "MIT" 23 | } 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 |

4 | show/hide icons on your desktop 5 |
6 |

7 | 8 |   9 | 10 | #### install 11 | 12 | [Grab the app from releases](https://github.com/siddharthkp/toggle-icons/releases) 13 | 14 |   15 | 16 | #### usage 17 | 18 | ![demo](https://user-images.githubusercontent.com/1863771/42634092-ec2f1596-85ff-11e8-8afb-55991ed4b191.gif) 19 | 20 |   21 | 22 | - Click to toggle 23 | - Right click to quit 24 | 25 |   26 | 27 | #### like it? 28 | 29 | :star: this repo 30 | 31 |   32 | 33 | #### license 34 | 35 | MIT © [siddharthkp](https://github.com/siddharthkp) 36 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const { Menu } = require('electron') 2 | const menubar = require('menubar') 3 | const path = require('path') 4 | const execa = require('execa') 5 | 6 | // require('electron-reload')(__dirname, { 7 | // electron: path.join(__dirname, 'node_modules', '.bin', 'electron') 8 | // }) 9 | 10 | const mb = menubar({ width: 1, height: 1 }) 11 | const imagesPath = path.join(__dirname, 'images') 12 | 13 | mb.on('ready', function ready() { 14 | const defaults = execa.shellSync( 15 | 'defaults read com.apple.finder CreateDesktop' 16 | ).stdout 17 | 18 | let visible = defaults === 'true' 19 | 20 | setIcon(visible) 21 | 22 | mb.tray.on('right-click', () => { 23 | mb.tray.setImage(`${imagesPath}/oh.png`) 24 | setTimeout(_ => mb.app.quit(), 500) 25 | }) 26 | 27 | mb.tray.on('click', () => { 28 | visible = !visible 29 | toggleIcons(visible) 30 | setIcon(visible) 31 | }) 32 | }) 33 | 34 | const toggleIcons = visible => { 35 | /* change defaults */ 36 | execa.shellSync(`defaults write com.apple.finder CreateDesktop ${visible}`) 37 | /* kill Finder, it will auto restart */ 38 | execa.shellSync('killall Finder') 39 | } 40 | 41 | const setIcon = visible => { 42 | mb.tray.setImage( 43 | visible ? `${imagesPath}/visible.png` : `${imagesPath}/hidden.png` 44 | ) 45 | mb.tray.setHighlightMode('never') 46 | } 47 | --------------------------------------------------------------------------------