Skip to content

Commit eae763f

Browse files
authored
Merge pull request dfmcphee#1 from davidcornu/toggle-icon
Show a half-opacity icon when the proxy isn't active
2 parents ea45fdb + be5bf88 commit eae763f

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

IconSubduedTemplate.png

1.49 KB
Loading

IconSubduedTemplate@2x.png

2.26 KB
Loading

index.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,16 @@ let menubar = require('menubar');
1919

2020
let server;
2121

22+
const icons = {
23+
active: app.getAppPath() + '/IconTemplate.png',
24+
subdued: app.getAppPath() + '/IconSubduedTemplate.png'
25+
}
26+
2227
let mb = menubar({
2328
preloadWindow: true,
2429
width: 400,
2530
height: 180,
26-
icon: app.getAppPath() + '/IconTemplate.png'
31+
icon: icons.subdued
2732
});
2833

2934
mb.on('ready', function ready () {
@@ -40,17 +45,19 @@ ipc.on('connect', function(event) {
4045
});
4146

4247
ipc.on('start-proxy', function(event, port) {
43-
server = setup(http.createServer());
44-
server.listen(port, function() {
48+
server = setup(http.createServer());
49+
server.listen(port, function() {
50+
mb.tray.setImage(icons.active);
4551
var port = server.address().port;
4652
console.log('HTTP(s) proxy server listening on port %d', port);
4753
});
4854
});
4955

5056
ipc.on('stop-proxy', function(event, port) {
51-
server.close(function() {
52-
console.log('proxy stopped')
53-
});
57+
server.close(function() {
58+
mb.tray.setImage(icons.subdued);
59+
console.log('proxy stopped')
60+
});
5461
});
5562

5663
let options = {

0 commit comments

Comments
 (0)