From fdd23b89df78b16043beb85e181cfb4ce2eb423b Mon Sep 17 00:00:00 2001 From: aminnairi <18418459+aminnairi@users.noreply.github.com> Date: Mon, 10 Apr 2023 23:17:22 +0200 Subject: [PATCH] using an external settings file for the openweathermap api key --- i3/i3status/index.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/i3/i3status/index.js b/i3/i3status/index.js index 3c4509c..74c0388 100644 --- a/i3/i3status/index.js +++ b/i3/i3status/index.js @@ -1,11 +1,24 @@ import { URL } from "url"; import { request } from "https"; import { readFile } from "fs/promises"; -import { cpus as cpuInfo } from "os"; +import { cpus as cpuInfo, homedir } from "os"; import { exec } from "child_process"; import { createInterface } from "readline/promises"; import { stdin as input, stdout as output } from "process"; import { createRenderer } from "@aminnairi/i3status"; +import { join } from "path"; + +// SETTINGS + +const settings = await readFile(join(homedir(), ".config/i3/i3status/settings.json")).then(fileContent => { + return JSON.parse(fileContent); +}).catch(() => { + return { + weather: { + appid: "" + } + }; +}); // HELPERS