Skip to content

Commit

Permalink
better timer + added prompt icon and readme pics
Browse files Browse the repository at this point in the history
  • Loading branch information
Fraasi committed Jul 20, 2018
1 parent dadf90d commit d96c68f
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 20 deletions.
Binary file added 2018-07-20_1531.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 2018-07-20_1532.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
### Sää

Electron app to show city temperature in the notification area.
Electron app to show weather temperature in the notification area/system tray.
Right click icon for more weather info and to change city.

#### todo
[ ] timer
[ ] better 'font'
- [ ] better 'font'

Tray
![Tray pic](2018-07-20_1531.png)

On right click
![right click](2018-07-20_1532.png)
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "saeae",
"productName": "saeae",
"version": "0.0.2",
"description": "My Electron application description",
"version": "0.5.5",
"description": "Weather app in your tray",
"main": "src/index.js",
"scripts": {
"start": "electron-forge start",
Expand Down Expand Up @@ -53,7 +53,7 @@
"dependencies": {
"dotenv": "^6.0.0",
"electron-compile": "^6.4.3",
"electron-prompt": "^0.5.0",
"electron-prompt": "^1.0.0",
"electron-squirrel-startup": "^1.0.0",
"electron-store": "^2.0.0",
"merge-img": "^2.1.2",
Expand Down
Binary file added src/assets/weather-cloudy-black.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 10 additions & 10 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ if (require('electron-squirrel-startup')) { // eslint-disable-line global-requir
let mainWindow
let tray = null
let city = store.get('weatherCity')
let interval

function parseTime(time) {
return (time < 10) ? `0${time}` : time
Expand All @@ -39,6 +40,7 @@ function promptCity() {
type: 'text',
placeholder: 'City',
},
icon: path.join(__dirname, 'assets/weather-cloudy-black.png'),
})
.then((input) => {
// null if window was closed or user clicked Cancel
Expand Down Expand Up @@ -105,10 +107,9 @@ function updateTrayIcon(numString) {

mergeImg(numberPaths, { margin: '0 5 0 0' })
.then((img) => {
// maybe put numicon at app.getPath('userData') ?
const numericalIcon = path.join(app.getPath('userData'), 'numerical-icon.png')
img.write(numericalIcon, () => {
tray.setImage(numericalIcon)
const numericalIconPath = path.join(app.getPath('userData'), 'numerical-icon.png')
img.write(numericalIconPath, () => {
tray.setImage(numericalIconPath)
})
})
}
Expand All @@ -122,16 +123,19 @@ function fetchWeather() {
return response.json()
})
.then((json) => {
clearInterval(interval)
tray.setToolTip('Sää')
updateTrayIcon(Math.round(json.main.temp).toString())
buildContextMenu(json)
interval = setInterval(fetchWeather, 1000 * 60 * 20)
})
.catch(() => {
const contextMenu = Menu.buildFromTemplate([
{ label: 'Bad Weather at the intertubes' },
{ label: 'Something went terribly wrong fetching weather data' },
// { label: err.message }, // needed?
{ label: 'Try restarting the app and/or check your internet connection' },
{ label: `Or maybe you just misspelled your city wrong (${city})` },
{ label: `Or maybe you just misspelled your city (${city})` },
{ type: 'separator' },
{
label: 'You can file a bug report at github.com/Fraasi/Saeae',
Expand Down Expand Up @@ -166,7 +170,6 @@ function createTray() {
width: 100,
height: 100,
show: false,
icon: path.join(__dirname, 'assets/numerical-icon.png'), // not working?
})
// mainWindow.loadURL(`file://${__dirname}/index.html`) // not needed!
// mainWindow.webContents.openDevTools()
Expand All @@ -176,10 +179,7 @@ function createTray() {

const trayIconPath = path.join(__dirname, './assets/weather-cloudy.png')
tray = new Tray(trayIconPath)
tray.setToolTip('Sää')
setTimeout(() => {
fetchWeather()
}, 1000)
fetchWeather()
}

app.on('ready', createTray)
Expand Down

0 comments on commit d96c68f

Please sign in to comment.