♻️ refactor(app): use single type/object declaration for generalConfig

this is much better
This commit is contained in:
retrozinndev
2025-08-03 15:08:19 -03:00
parent 1d5fe06f8a
commit 3083a58e07
+27 -49
View File
@@ -22,66 +22,44 @@ import AstalNotifd from "gi://AstalNotifd";
import GLib from "gi://GLib?version=2.0"; import GLib from "gi://GLib?version=2.0";
type ConfigEntries = { const generalConfigDefaults = {
workspaces?: Partial<{ notifications: {
timeout_low: 4000,
timeout_normal: 6000,
timeout_critical: 0
},
night_light: {
/** whether to save night light values to disk */
save_on_shutdown: true
},
workspaces: {
/** breaks `enable_helper`, makes all workspaces show their respective ID
* by default */
always_show_id: false,
/** this is the function that shows the Workspace's IDs /** this is the function that shows the Workspace's IDs
* around the current workspace if one breaks the crescent order. * around the current workspace if one breaks the crescent order.
* It basically helps keyboard navigation between workspaces. * It basically helps keyboard navigation between workspaces.
* --- * ---
* Example: 1(empty, current, shows ID), 2(empty, does not appear(makes * Example: 1(empty, current, shows ID), 2(empty, does not appear(makes
* the previous not to be in a crescent order)), 3(not empty, shows ID) */ * the previous not to be in a crescent order)), 3(not empty, shows ID) */
enable_helper: boolean; enable_helper: true
/** breaks `enable_helper`, makes all workspaces show their respective ID },
* by default */
always_show_id: boolean;
}>;
clock?: Partial<{ clock: {
/** use the same format as gnu's `date` command */ /** use the same format as gnu's `date` command */
date_format: string; date_format: "%A %d, %H:%M"
}>; },
notifications?: Partial<{ misc: {
timeout_low: number; play_bell_on_volume_change: true
timeout_normal: number; }
timeout_critical: number;
}>;
night_light?: Partial<{
/** whether to save night light values to disk */
save_on_shutdown: boolean;
}>;
misc?: Partial<{
play_bell_on_volume_change: boolean;
}>;
}; };
export const generalConfig = new Config<keyof ConfigEntries, ConfigEntries[keyof ConfigEntries]>( export const generalConfig = new Config<keyof typeof generalConfigDefaults,
`${GLib.get_user_config_dir()}/colorshell/config.json`, { typeof generalConfigDefaults[keyof typeof generalConfigDefaults]>(
notifications: { `${GLib.get_user_config_dir()}/colorshell/config.json`, generalConfigDefaults
timeout_low: 4000,
timeout_normal: 6000,
timeout_critical: 0
},
night_light: {
save_on_shutdown: true
},
workspaces: {
always_show_id: false,
enable_helper: true
},
clock: {
date_format: "%A %d, %H:%M"
},
misc: {
play_bell_on_volume_change: true
}
}
); );
export const appScope: Scope = new Scope(null); export const appScope: Scope = new Scope(null);