🔧 chore(scripts/config): stop using singleton instance, add type declarations(for completion)
this will make easier to work with multiple configuration files at the same time
This commit is contained in:
+64
-3
@@ -19,6 +19,70 @@ import { Scope } from "/usr/share/ags/js/gnim/src/jsx/scope";
|
||||
import App from "ags/gtk4/app"
|
||||
import GObject from "ags/gobject";
|
||||
import AstalNotifd from "gi://AstalNotifd";
|
||||
import GLib from "gi://GLib?version=2.0";
|
||||
|
||||
|
||||
type ConfigEntries = {
|
||||
workspaces?: Partial<{
|
||||
/** this is the function that shows the Workspace's IDs
|
||||
* around the current workspace if one breaks the crescent order.
|
||||
* It basically helps keyboard navigation between workspaces.
|
||||
* ---
|
||||
* 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) */
|
||||
enable_helper: boolean;
|
||||
/** breaks `enable_helper`, makes all workspaces show their respective ID
|
||||
* by default */
|
||||
always_show_id: boolean;
|
||||
}>;
|
||||
|
||||
clock?: Partial<{
|
||||
/** use the same format as gnu's `date` command */
|
||||
date_format: string;
|
||||
}>;
|
||||
|
||||
notifications?: Partial<{
|
||||
timeout_low: number;
|
||||
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]>(
|
||||
`${GLib.get_user_config_dir()}/colorshell/config.json`, {
|
||||
notifications: {
|
||||
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);
|
||||
|
||||
@@ -46,9 +110,6 @@ App.start({
|
||||
console.log(`Colorshell: initialized instance as: "${ App.instanceName || "astal" }"`);
|
||||
connections.set(App, App.connect("shutdown", () => appScope.dispose()));
|
||||
|
||||
console.log("Config: initializing configuration file");
|
||||
Config.getDefault();
|
||||
|
||||
Stylesheet.getDefault().compileApply();
|
||||
|
||||
// Init clipboard module
|
||||
|
||||
Reference in New Issue
Block a user