chore: Better organize preferences files, b=no-bug, c=compact-mode, folders, glance, kbs, media, mods, split-view, welcome, workspaces

This commit is contained in:
Mr. M
2025-10-10 23:07:42 +02:00
parent 6c3ed1fb80
commit c0b2a779e0
34 changed files with 32 additions and 12 deletions

8
prefs/README.md Normal file
View File

@@ -0,0 +1,8 @@
# Browser Preferences
This directory contains configuration files for Zen. They are divided by folder according to the source / component they belong to and further divided by file according to their purpose.
- `firefox/`: Preferences to override Firefox defaults.
- `zen/`: Preferences to configure Zen-specific features.
- `privatefox/` & `fastfox/`: *Some* of the preferences got extracted from [Betterfox](https://github.com/yokoffing/Betterfox).

View File

@@ -17,3 +17,6 @@
- name: browser.ml.enable
value: false
- name: browser.ml.chat.menu
value: false

View File

@@ -102,10 +102,10 @@
//
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::env;
use std::fs;
use std::path::PathBuf;
use std::collections::HashMap;
const STATIC_PREFS: &str = "../engine/modules/libpref/init/zen-static-prefs.inc";
const FIREFOX_PREFS: &str = "../engine/browser/app/profile/firefox.js";
@@ -136,25 +136,34 @@ fn ordered_prefs(mut prefs: Vec<Preference>) -> Vec<Preference> {
prefs
}
fn load_preferences() -> Vec<Preference> {
let mut prefs = Vec::new();
let config_path = get_config_path();
// Iterate each file in the prefs directory
if let Ok(entries) = fs::read_dir(&config_path) {
fn get_prefs_files_recursively(dir: &PathBuf, files: &mut Vec<PathBuf>) {
if let Ok(entries) = fs::read_dir(dir) {
for entry in entries {
if let Ok(entry) = entry {
if let Some(ext) = entry.path().extension() {
let path = entry.path();
if path.is_dir() {
get_prefs_files_recursively(&path, files);
} else if let Some(ext) = path.extension() {
if ext == "yaml" || ext == "yml" {
let file_path = entry.path();
let content = fs::read_to_string(&file_path).expect("Failed to read file");
let mut parsed_prefs: Vec<Preference> =
serde_yaml::from_str(&content).expect("Failed to parse YAML");
prefs.append(&mut parsed_prefs);
files.push(path);
}
}
}
}
}
}
fn load_preferences() -> Vec<Preference> {
let mut prefs = Vec::new();
let config_path = get_config_path();
let mut pref_files = Vec::new();
get_prefs_files_recursively(&config_path, &mut pref_files);
for file_path in pref_files {
let content = fs::read_to_string(&file_path).expect("Failed to read file");
let mut parsed_prefs: Vec<Preference> =
serde_yaml::from_str(&content).expect("Failed to parse YAML");
prefs.append(&mut parsed_prefs);
}
ordered_prefs(prefs)
}