summaryrefslogtreecommitdiff
path: root/src/config
diff options
context:
space:
mode:
Diffstat (limited to 'src/config')
-rw-r--r--src/config/defaults.ts59
-rw-r--r--src/config/funcs.ts24
-rw-r--r--src/config/types.ts34
3 files changed, 66 insertions, 51 deletions
diff --git a/src/config/defaults.ts b/src/config/defaults.ts
index c67d140..570ed16 100644
--- a/src/config/defaults.ts
+++ b/src/config/defaults.ts
@@ -10,43 +10,44 @@ export default {
bar: {
vertical: true,
style: "gaps", // One of "gaps", "panel", "embedded"
- modules: {
- osIcon: {
- enabled: true,
- },
- activeWindow: {
- enabled: true,
- },
- mediaPlaying: {
- enabled: true,
+ layout: {
+ type: "centerbox", // One of "centerbox", "flowbox"
+ centerbox: {
+ start: ["osIcon", "activeWindow", "mediaPlaying", "brightnessSpacer"],
+ center: ["workspaces"],
+ end: [
+ "volumeSpacer",
+ "tray",
+ "statusIcons",
+ "pkgUpdates",
+ "notifCount",
+ "battery",
+ "dateTime",
+ "power",
+ ],
},
+ flowbox: [
+ "osIcon",
+ "workspaces",
+ "brightnessSpacer",
+ "activeWindow",
+ "volumeSpacer",
+ "dateTime",
+ "tray",
+ "battery",
+ "statusIcons",
+ "notifCount",
+ "power",
+ ],
+ },
+ modules: {
workspaces: {
- enabled: true,
shown: 5,
},
- tray: {
- enabled: true,
- },
- statusIcons: {
- enabled: true,
- },
- pkgUpdates: {
- enabled: true,
- },
- notifCount: {
- enabled: true,
- },
- battery: {
- enabled: true,
- },
dateTime: {
- enabled: true,
format: "%d/%m/%y %R",
detailedFormat: "%c",
},
- power: {
- enabled: true,
- },
},
},
launcher: {
diff --git a/src/config/funcs.ts b/src/config/funcs.ts
index 253164e..5b9efa4 100644
--- a/src/config/funcs.ts
+++ b/src/config/funcs.ts
@@ -25,16 +25,20 @@ const isCorrectType = (v: any, type: string | string[] | number[], path: string)
try {
// Recursively check type
const type = JSON.parse(arrType);
- const valid = v.filter((item, i) =>
- Object.entries(type).some(([k, t]) => {
- if (!item[k]) {
- console.warn(`Invalid shape for ${path}[${i}]: ${JSON.stringify(item)} != ${arrType}`);
- return false;
- }
- return !isCorrectType(item[k], t as any, `${path}[${i}].${k}`);
- })
- );
- v.splice(0, v.length, ...valid); // In-place filter
+ if (Array.isArray(type)) {
+ v.splice(0, v.length, ...v.filter((item, i) => isCorrectType(item, type, `${path}[${i}]`)));
+ } else {
+ const valid = v.filter((item, i) =>
+ Object.entries(type).some(([k, t]) => {
+ if (!item[k]) {
+ console.warn(`Invalid shape for ${path}[${i}]: ${JSON.stringify(item)} != ${arrType}`);
+ return false;
+ }
+ return !isCorrectType(item[k], t as any, `${path}[${i}].${k}`);
+ })
+ );
+ v.splice(0, v.length, ...valid); // In-place filter
+ }
} catch {
const valid = v.filter((item, i) => {
if (typeof item !== arrType) {
diff --git a/src/config/types.ts b/src/config/types.ts
index c5baf99..f5ca03a 100644
--- a/src/config/types.ts
+++ b/src/config/types.ts
@@ -1,9 +1,25 @@
const BOOL = "boolean";
const STR = "string";
const NUM = "number";
-const ARR = (type: string) => `array of ${type}`;
+const ARR = (type: string | string[]) => `array of ${typeof type === "string" ? type : JSON.stringify(type)}`;
const OBJ_ARR = (shape: object) => ARR(JSON.stringify(shape));
+const barModules = [
+ "osIcon",
+ "activeWindow",
+ "mediaPlaying",
+ "brightnessSpacer",
+ "workspaces",
+ "volumeSpacer",
+ "tray",
+ "statusIcons",
+ "pkgUpdates",
+ "notifCount",
+ "battery",
+ "dateTime",
+ "power",
+];
+
export default {
"style.transparency": ["off", "normal", "high"],
"style.borders": BOOL,
@@ -11,20 +27,14 @@ export default {
// Bar
"bar.vertical": BOOL,
"bar.style": ["gaps", "panel", "embedded"],
- "bar.modules.osIcon.enabled": BOOL,
- "bar.modules.activeWindow.enabled": BOOL,
- "bar.modules.mediaPlaying.enabled": BOOL,
- "bar.modules.workspaces.enabled": BOOL,
+ "bar.layout.type": ["centerbox", "flowbox"],
+ "bar.layout.centerbox.start": ARR(barModules),
+ "bar.layout.centerbox.center": ARR(barModules),
+ "bar.layout.centerbox.end": ARR(barModules),
+ "bar.layout.flowbox": ARR(barModules),
"bar.modules.workspaces.shown": NUM,
- "bar.modules.tray.enabled": BOOL,
- "bar.modules.statusIcons.enabled": BOOL,
- "bar.modules.pkgUpdates.enabled": BOOL,
- "bar.modules.notifCount.enabled": BOOL,
- "bar.modules.battery.enabled": BOOL,
- "bar.modules.dateTime.enabled": BOOL,
"bar.modules.dateTime.format": STR,
"bar.modules.dateTime.detailedFormat": STR,
- "bar.modules.power.enabled": BOOL,
// Launcher
"launcher.style": ["lines", "round"],
"launcher.actionPrefix": STR,