Will change this commit message to mean something later

This commit is contained in:
Breadway 2026-07-22 19:53:25 +08:00
parent f1c8b3d0e3
commit 40da0b3517
55 changed files with 55 additions and 17 deletions

View file

@ -1,13 +1,7 @@
<script lang="ts">
let {
label,
value = $bindable(),
suggestions = [],
}: { label: string; value: string[]; suggestions?: string[] } = $props();
let { label, value = $bindable() }: { label: string; value: string[] } = $props();
let text = $state("");
const listId = $props.id();
let available = $derived(suggestions.filter((s) => !value.includes(s)));
function commit() {
const v = text.trim();
@ -42,15 +36,8 @@
<button type="button" class="remove" onclick={() => remove(name)} aria-label={`Remove ${name}`}>×</button>
</span>
{/each}
<input type="text" bind:value={text} onkeydown={onKeydown} placeholder="Type and press Enter…" list={available.length ? listId : undefined} />
<input type="text" bind:value={text} onkeydown={onKeydown} placeholder="Type and press Enter…" />
</div>
{#if available.length}
<datalist id={listId}>
{#each available as s (s)}
<option value={s}></option>
{/each}
</datalist>
{/if}
</div>
<style>

View file

@ -9,6 +9,7 @@
import SelectField from "$lib/components/SelectField.svelte";
import NumberField from "$lib/components/NumberField.svelte";
import TagsField from "$lib/components/TagsField.svelte";
import ChipPickerField from "$lib/components/ChipPickerField.svelte";
import SaveButton from "$lib/components/SaveButton.svelte";
interface BreadConfig {
@ -32,9 +33,14 @@
}
let cfg = $state<BreadConfig | null>(null);
// The daemon's 4 compiled-in modules plus every *.lua file actually
// sitting in the configured module directory — real installed modules,
// not a guess, so picking one to disable is a click.
let knownModules = $state<string[]>([]);
onMount(async () => {
cfg = await invoke<BreadConfig>("get_bread_config");
knownModules = await invoke<string[]>("list_bread_modules");
});
async function save() {
@ -58,10 +64,11 @@
<Group title="Modules">
<SwitchField label="Load built-in modules" bind:value={cfg.modules_builtin} />
<TagsField
<ChipPickerField
label="Disabled modules"
bind:value={cfg.modules_disable}
suggestions={["bread.monitors", "bread.devices", "bread.workspaces", "bread.binds"]}
options={knownModules}
emptyOptionsHint="No other modules found to disable."
/>
</Group>

View file

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 6.8 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 974 B

After

Width:  |  Height:  |  Size: 974 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 7.6 KiB

After

Width:  |  Height:  |  Size: 7.6 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 903 B

After

Width:  |  Height:  |  Size: 903 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 8.4 KiB

After

Width:  |  Height:  |  Size: 8.4 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 2 KiB

After

Width:  |  Height:  |  Size: 2 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 85 KiB

After

Width:  |  Height:  |  Size: 85 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Before After
Before After

View file

@ -55,6 +55,49 @@ pub fn get_bread_config() -> BreadConfig {
}
}
/// Real, pickable module names for the "Disabled modules" field: breadd's
/// four compiled-in modules (bread/breadd/src/lua/mod.rs's `BUILTIN_*`
/// registry — these aren't files on disk, so a directory scan alone would
/// miss them) plus every `.lua` file actually sitting in the configured
/// module directory (the user's own custom widgets/modules — the common
/// case in practice, going by real configs seen in the wild).
#[tauri::command]
pub fn list_bread_modules() -> Vec<String> {
let mut modules = vec![
"bread.monitors".to_string(),
"bread.devices".to_string(),
"bread.workspaces".to_string(),
"bread.binds".to_string(),
];
let doc = config::load_doc(&config_path());
let configured = config::get_str(&doc, &["lua", "module_path"]);
let module_dir = expand_home(configured.as_deref().filter(|s| !s.is_empty()).unwrap_or("~/.config/bread/modules"));
if let Ok(entries) = std::fs::read_dir(&module_dir) {
let mut found: Vec<String> = entries
.filter_map(|e| e.ok())
.filter(|e| e.path().extension().and_then(|s| s.to_str()) == Some("lua"))
.filter_map(|e| e.file_name().into_string().ok())
.collect();
found.sort();
modules.extend(found);
}
modules
}
/// Expands a leading `~/` against `$HOME` — breadd's own config resolution
/// (`Config::lua_module_path`) does the same for this exact field.
fn expand_home(path: &str) -> std::path::PathBuf {
if let Some(rest) = path.strip_prefix("~/") {
if let Some(home) = std::env::var_os("HOME") {
return std::path::PathBuf::from(home).join(rest);
}
}
std::path::PathBuf::from(path)
}
#[tauri::command]
pub fn save_bread_config(cfg: BreadConfig) -> Result<(), String> {
let path = config_path();

View file

@ -19,6 +19,7 @@ pub fn run() {
commands::breadclip::open_breadclip,
commands::bread::get_bread_config,
commands::bread::save_bread_config,
commands::bread::list_bread_modules,
commands::breadpad::get_breadpad_config,
commands::breadpad::save_breadpad_config,
commands::breadsearch::get_breadsearch_config,