read a single json file for appeareance
This commit is contained in:
1 parent
4aa99210a8
commit
a43cd1c0e8
9 files changed
+91
-112
No files matched your search
+10
-51
@@ -100,9 +100,7 @@ export const kernel_name = await Utils.execAsync(`${App.configDir}/scripts/syste
|
||||
export const hostname = await Utils.execAsync(`${App.configDir}/scripts/system.sh --hostname`);
|
||||
export const current_os = await Utils.execAsync(`${App.configDir}/scripts/system.sh --os`);
|
||||
|
||||
export const custom_color_file = `${GLib.get_home_dir()}/dotfiles/.settings/custom-color`;
|
||||
export const generation_scheme_file = `${GLib.get_home_dir()}/dotfiles/.settings/generation-scheme`;
|
||||
export const color_scheme_file = `${GLib.get_home_dir()}/dotfiles/.settings/color-scheme`;
|
||||
export const settings_file = `${GLib.get_home_dir()}/dotfiles/ags/assets/settings.json`;
|
||||
export const wallpaper_cache_file = `${GLib.get_home_dir()}/.cache/current_wallpaper`;
|
||||
|
||||
function checkBrightness() {
|
||||
@@ -116,29 +114,17 @@ export const current_brightness = Variable(100, {
|
||||
poll: [500, checkBrightness]
|
||||
});
|
||||
|
||||
function readFiles() {
|
||||
Utils.readFileAsync(custom_color_file)
|
||||
|
||||
function readSettingsFile() {
|
||||
Utils.readFileAsync(settings_file)
|
||||
.then((out) => {
|
||||
let _out = out;
|
||||
if (_out.startsWith("-")) {
|
||||
_out = _out.substring(1);
|
||||
}
|
||||
theme_settings.color.setValue(_out.trim());
|
||||
const settings = JSON.parse(out);
|
||||
theme_settings.color.setValue(settings["custom-color"].trim());
|
||||
theme_settings.scheme.setValue(settings["generation-scheme"].trim());
|
||||
theme.setValue(settings["color-scheme"].trim());
|
||||
})
|
||||
.catch(print);
|
||||
|
||||
Utils.readFileAsync(generation_scheme_file)
|
||||
.then((out) => {
|
||||
theme_settings.scheme.setValue(out);
|
||||
})
|
||||
.catch(print);
|
||||
|
||||
Utils.readFileAsync(color_scheme_file)
|
||||
.then((out) => {
|
||||
theme.setValue(out.trim());
|
||||
})
|
||||
.catch((err) => {});
|
||||
|
||||
Utils.readFileAsync(wallpaper_cache_file)
|
||||
.then((out) => {
|
||||
current_wallpaper.setValue(out.trim());
|
||||
@@ -147,36 +133,9 @@ function readFiles() {
|
||||
Utils.writeFileSync(current_wallpaper.value, wallpaper_cache_file);
|
||||
});
|
||||
}
|
||||
readFiles();
|
||||
|
||||
Utils.monitorFile(custom_color_file, () => {
|
||||
Utils.readFileAsync(custom_color_file)
|
||||
.then((out) => {
|
||||
let _out = out;
|
||||
if (_out.startsWith("-")) {
|
||||
_out = _out.substring(1);
|
||||
}
|
||||
theme_settings.color.setValue(_out.trim());
|
||||
})
|
||||
.catch((err) => {});
|
||||
});
|
||||
|
||||
Utils.monitorFile(generation_scheme_file, () => {
|
||||
Utils.readFileAsync(generation_scheme_file)
|
||||
.then((out) => {
|
||||
theme_settings.scheme.setValue(out.trim());
|
||||
})
|
||||
.catch((err) => {});
|
||||
});
|
||||
|
||||
Utils.monitorFile(color_scheme_file, () => {
|
||||
Utils.readFileAsync(color_scheme_file)
|
||||
.then((out) => {
|
||||
theme.setValue(out.trim());
|
||||
})
|
||||
.catch((err) => {});
|
||||
});
|
||||
readSettingsFile();
|
||||
|
||||
Utils.monitorFile(settings_file, readSettingsFile);
|
||||
Utils.monitorFile(wallpaper_cache_file, () => {
|
||||
Utils.readFileAsync(wallpaper_cache_file)
|
||||
.then((out) => {
|
||||
|
||||
Reference in new issue
Block a user