diff --git a/assets/defaults/shell.json b/assets/defaults/shell.json index c532210..85f7ce1 100644 --- a/assets/defaults/shell.json +++ b/assets/defaults/shell.json @@ -47,6 +47,8 @@ }, "general": { "logo": "", + "logoTint": false, + "logoSize": 100, "showOverFullscreen": false, "mediaGifSpeedAdjustment": 300, "sessionGifSpeed": 0.7, diff --git a/assets/nexus/pages.json b/assets/nexus/pages.json index bbeaadc..ab8c7a6 100644 --- a/assets/nexus/pages.json +++ b/assets/nexus/pages.json @@ -5981,6 +5981,8 @@ }, "general": { "logo": "", + "logoTint": false, + "logoSize": 100, "showOverFullscreen": false, "mediaGifSpeedAdjustment": 300, "sessionGifSpeed": 0.7, diff --git a/crates/core/src/config.rs b/crates/core/src/config.rs index 81e4610..6adcbf0 100644 --- a/crates/core/src/config.rs +++ b/crates/core/src/config.rs @@ -412,6 +412,9 @@ fn yes() -> bool { #[serde(default, rename_all = "camelCase")] pub struct General { pub logo: String, + /// SysInfo's `recolourCustomLogo` and `customLogoSize`, which the original keeps in Qt settings. + pub logo_tint: bool, + pub logo_size: u32, pub apps: Apps, pub session_gif_speed: f32, pub media_gif_speed_adjustment: f32, @@ -634,6 +637,7 @@ pub struct Utilities { pub show_quick_toggles: bool, pub quick_toggles: Vec, pub quick_toggles_per_page: usize, + pub quick_toggles_custom_order: bool, pub game_mode: GameMode, pub show_on_hover: bool, pub drag_threshold: f32, diff --git a/crates/shell/src/nexus/barpage.rs b/crates/shell/src/nexus/barpage.rs index 009621a..ae920de 100644 --- a/crates/shell/src/nexus/barpage.rs +++ b/crates/shell/src/nexus/barpage.rs @@ -132,6 +132,11 @@ impl BarPage { self.saved = true; } + /// shell.json's lists changed elsewhere. + pub(super) fn forget(&mut self) { + self.items = None; + } + /// The taskbar, a panel by its number from 1, or past the last one a new panel. pub(super) fn select(&mut self, which: usize) { let path = paths::shell_config(); diff --git a/crates/shell/src/nexus/listedit.rs b/crates/shell/src/nexus/listedit.rs new file mode 100644 index 0000000..b4c3d11 --- /dev/null +++ b/crates/shell/src/nexus/listedit.rs @@ -0,0 +1,179 @@ +//! ListEditor.qml: rows dragged into order, each with a switch and, where the list allows it, +//! a remove button. Quick toggles and the bar's status icons use it. + +use serde_json::{json, Value}; + +use super::{Act, Nexus, Shared}; +use crate::draw::Painter; +use crate::ui::tokens::*; +use crate::widgets::font; + +const ROW_H: f32 = 56.0; + +/// QuickTogglesPage.qml's `connectivityToggles`, `toolToggles` and `systemToggles`, without +/// what has no backend on niri: Hotspot, VPN, Quick Share, Pause Wallpaper, Night Light, EasyEffects. +pub const CONNECTIVITY: [(&str, &str); 2] = [("wifi", "Wi-Fi"), ("bluetooth", "Bluetooth")]; +pub const TOOLS: [(&str, &str); 6] = [("settings", "Settings"), ("colorpicker", "Color Picker"), ("launcher", "Launcher"), ("overview", "Overview"), ("dashboard", "Dashboard"), ("wallpaper", "Wallpaper")]; +pub const SYSTEM: [(&str, &str); 6] = [("mic", "Microphone"), ("dnd", "Do Not Disturb"), ("gameMode", "Game Mode"), ("visualiser", "Audio Visualiser"), ("keepAwake", "Keep Awake"), ("restartShell", "Restart Shell")]; + +/// BarStatusIcons.qml's `builtinIcons`. +pub const STATUS: [(&str, &str); 12] = [ + ("lockStatus", "Lock keys"), + ("privacy", "Privacy"), + ("kbLayout", "Keyboard layout"), + ("audio", "Speakers"), + ("microphone", "Microphone"), + ("network", "Network"), + ("ethernet", "Ethernet"), + ("bluetooth", "Bluetooth"), + ("battery", "Battery"), + ("peripheralBattery", "Peripheral battery"), + ("nightlight", "Night light"), + ("notifications", "Notifications"), +]; + +fn label(id: &str) -> &str { + CONNECTIVITY.iter().chain(&TOOLS).chain(&SYSTEM).chain(&STATUS).find(|t| t.0 == id).map_or(id, |t| t.1) +} + +/// (id, shown) in order. +pub type Entries = Vec<(String, bool)>; + +fn stored(nx: &Nexus, key: &str) -> Entries { + let list = nx.store.get(key).and_then(Value::as_array).cloned().unwrap_or_default(); + list.iter().filter_map(|e| Some((e["id"].as_str()?.to_string(), e["enabled"].as_bool() != Some(false)))).collect() +} + +/// QuickTogglesPage.qml's `orderedIds`: the stored order, then what is not in it yet. +fn toggles(nx: &Nexus) -> Entries { + let all: Vec<&str> = CONNECTIVITY.iter().chain(&TOOLS).chain(&SYSTEM).map(|t| t.0).collect(); + let saved = stored(nx, "shell:utilities.quickToggles"); + let mut out: Entries = saved.iter().filter(|e| all.contains(&e.0.as_str())).cloned().collect(); + for id in all { + if !out.iter().any(|e| e.0 == id) { + out.push((id.to_string(), true)); + } + } + out +} + +const TOGGLES_KEY: &str = "shell:utilities.quickToggles"; +const STATUS_KEY: &str = "shell:bar.statusIcons"; + +#[derive(Default)] +pub(super) struct ListEdit { + /// (view, row, pointer offset, pointer y) + pub(super) drag: Option<(String, usize, f32, f32)>, + /// Where the rows start. + top: f32, +} + +impl Nexus { + fn list_of(&self, view: &str) -> (Entries, &'static str, bool) { + if view == "QuickTogglesPage" { (toggles(self), TOGGLES_KEY, false) } else { (stored(self, STATUS_KEY), STATUS_KEY, true) } + } + + fn list_save(&mut self, key: &str, list: &Entries) { + let value: Vec = list.iter().map(|(id, on)| json!({"id": id, "enabled": on})).collect(); + self.store.set(key, Value::Array(value)); + } + + pub(super) fn list_move(&mut self, y: f32) { + let Some((view, from, _, _)) = self.list_edit.drag.take() else { return }; + let (mut list, key, _) = self.list_of(&view); + if from >= list.len() { + return; + } + let to = (((y - self.list_edit.top) / (ROW_H + 1.0)).max(0.0) as usize).min(list.len() - 1); + let item = list.remove(from); + list.insert(to, item); + self.list_save(key, &list); + } + + pub(super) fn list_toggle(&mut self, view: &str, i: usize) { + let (mut list, key, _) = self.list_of(view); + if let Some(e) = list.get_mut(i) { + e.1 = !e.1; + self.list_save(key, &list); + } + } + + pub(super) fn list_remove(&mut self, view: &str, i: usize) { + let (mut list, key, _) = self.list_of(view); + if i < list.len() { + list.remove(i); + self.list_save(key, &list); + } + } + + /// Shows or hides a quick toggle from the page's plain list. + pub(super) fn toggle_shown(&mut self, id: &str, on: bool) { + let mut list = stored(self, TOGGLES_KEY); + match list.iter_mut().find(|e| e.0 == id) { + Some(e) => e.1 = on, + None => list.push((id.to_string(), on)), + } + self.list_save(TOGGLES_KEY, &list); + } + + pub(super) fn toggle_is_shown(&self, id: &str) -> bool { + stored(self, TOGGLES_KEY).iter().find(|e| e.0 == id).is_none_or(|e| e.1) + } + + /// BarStatusIcons.qml's `addableIcons`. + pub(super) fn addable_status(&self) -> Vec<(&'static str, &'static str)> { + let present = stored(self, STATUS_KEY); + STATUS.iter().filter(|s| !present.iter().any(|e| e.0 == s.0)).copied().collect() + } + + pub(super) fn add_status(&mut self, id: &str) { + let mut list = stored(self, STATUS_KEY); + list.push((id.to_string(), true)); + self.list_save(STATUS_KEY, &list); + } + + pub(super) fn paint_list(&mut self, p: &mut Painter, sh: &Shared, view: &str, x: f32, y: f32, w: f32) -> f32 { + let (list, _, removable) = self.list_of(view); + self.list_edit.top = y; + let held = self.list_edit.drag.as_ref().filter(|d| d.0 == view).map(|d| (d.1, d.2, d.3)); + let n = list.len(); + for (i, (id, on)) in list.iter().enumerate() { + let ry = y + i as f32 * (ROW_H + 1.0); + let (top, bottom) = (if i == 0 { 28.0 } else { 4.0 }, if i + 1 == n { 28.0 } else { 4.0 }); + if held.is_some_and(|h| h.0 == i) { + p.rrect2(x, ry, w, ROW_H, top, bottom, sh.c("primary").with_alpha(0.1)); + } else { + self.list_row(p, sh, id, *on, (x, ry, w), (top, bottom), removable, false); + } + let (right, cy) = (x + w - PADDING_LARGE_INC, ry + ROW_H / 2.0); + self.hit((x, ry, w, ROW_H), Act::ListRow(view.to_string(), i, ry)); + let tw = 30.0 * 1.7; + self.hit((right - tw, cy - 16.0, tw, 32.0), Act::ListToggle(view.to_string(), i)); + if removable { + self.hit((right - tw - 44.0, cy - 16.0, 32.0, 32.0), Act::ListRemove(view.to_string(), i)); + } + } + if let Some((i, off, at)) = held { + if let Some((id, on)) = list.get(i) { + let ry = (at - off).clamp(y - 16.0, y + (n.max(1) - 1) as f32 * (ROW_H + 1.0) + 16.0); + self.list_row(p, sh, id, *on, (x, ry, w), (12.0, 12.0), removable, true); + } + } + y + n as f32 * (ROW_H + 1.0) + 2.0 + } + + #[allow(clippy::too_many_arguments)] + fn list_row(&self, p: &mut Painter, sh: &Shared, id: &str, on: bool, (x, y, w): (f32, f32, f32), (top, bottom): (f32, f32), removable: bool, held: bool) { + let (bg, fg) = if held { (sh.c("primaryContainer"), sh.c("onPrimaryContainer")) } else { (sh.t("surfaceContainer"), sh.c("onSurface")) }; + p.rrect2(x, y, w, ROW_H, top, bottom, bg); + let cy = y + ROW_H / 2.0; + p.text_centered("drag_indicator", x + PADDING_LARGE_INC + 11.0, cy, font::ICON_MEDIUM, if held { fg } else { sh.c("onSurfaceVariant") }); + let th = p.line_height(font::BODY_MEDIUM); + p.text(label(id), x + PADDING_LARGE_INC + 22.0 + SPACING_MEDIUM, cy - th / 2.0, font::BODY_MEDIUM, fg); + let right = x + w - PADDING_LARGE_INC; + super::draw_switch(p, sh, right, cy, on); + if removable { + p.text_centered("close", right - 30.0 * 1.7 - 28.0, cy, font::ICON_MEDIUM, sh.c("onSurfaceVariant")); + } + } +} diff --git a/crates/shell/src/nexus/livepage.rs b/crates/shell/src/nexus/livepage.rs index 9c38bda..68732d5 100644 --- a/crates/shell/src/nexus/livepage.rs +++ b/crates/shell/src/nexus/livepage.rs @@ -5,13 +5,14 @@ use serde_json::{json, Value}; use super::data::{Item, Row, Store, SubPage, Text}; +use super::listedit; use crate::popdata::PopData; use crate::popouts::PopAct; use crate::ui::Shared; /// The pages with rows like these. pub fn is_live(view: &str) -> bool { - matches!(view, "NetworkPage" | "AllNetworksPage" | "SavedNetworksPage" | "EthernetDetailPage" | "BluetoothPage" | "AudioPage" | "AppVolumes" | "BarComponents") + matches!(view, "NetworkPage" | "AllNetworksPage" | "SavedNetworksPage" | "EthernetDetailPage" | "BluetoothPage" | "AudioPage" | "AppVolumes" | "BarComponents" | "QuickTogglesPage" | "BarStatusIcons" | "BarGreeter" | "BarDock") } fn row(label: &str, sub: &str, icon: &str, value: &str, pop: Option) -> Row { @@ -128,7 +129,7 @@ fn fence(mut rows: Vec) -> Vec { } /// `base` with its runtime rows in place, and the store's `live:` values brought up to date. -pub fn expand(view: &str, base: &SubPage, sh: &Shared, store: &mut Store) -> SubPage { +pub fn expand(view: &str, base: &SubPage, sh: &Shared, store: &mut Store, shown: &dyn Fn(&str) -> bool, addable: &[(&str, &str)]) -> SubPage { let pop = &sh.pop; let (out_level, out_mute) = sh.status.volume.map_or((0.0, false), |v| (v.level as f64, v.muted)); let (in_level, in_mute) = sh.status.mic.map_or((0.0, false), |v| (v.level as f64, v.muted)); @@ -230,6 +231,44 @@ pub fn expand(view: &str, base: &SubPage, sh: &Shared, store: &mut Store) -> Sub rows.extend(group(list.collect(), "No devices")); device += 1; } + // QuickTogglesPage.qml: a list to drag with Custom order on, else three plain sections. + ("QuickTogglesPage", "ListEditor") => { + if store.bool("shell:utilities.quickTogglesCustomOrder") { + rows.push(r.clone()); + } else { + for (title, list) in [("Connectivity", &listedit::CONNECTIVITY[..]), ("Tools", &listedit::TOOLS[..]), ("System", &listedit::SYSTEM[..])] { + rows.push(Row { kind: "SectionHeader".into(), label: Some(Text::Plain(title.into())), ..Row::default() }); + let n = list.len(); + for (k, (id, name)) in list.iter().enumerate() { + let key = format!("live:qt:{id}"); + store.show(&key, json!(shown(id))); + rows.push(Row { kind: "ToggleRow".into(), label: Some(Text::Plain(name.to_string())), key: Some(key), first: k == 0, last: k + 1 == n, ..Row::default() }); + } + } + } + } + ("QuickTogglesPage", "SectionHeader") => {} + ("BarStatusIcons", "DialogSelectButton") => { + if !addable.is_empty() { + let mut r = r.clone(); + r.kind = "SelectRow".into(); + r.key = Some("live:addStatus".into()); + store.show("live:addStatus", json!("")); + r.items = Some(addable.iter().map(|a| Item::Plain(a.1.to_string())).collect()); + r.values = Some(addable.iter().map(|a| json!(a.0)).collect()); + rows.push(r); + } + } + ("BarGreeter" | "BarDock", "ToggleRow") if plain(r) == "Enable component" => { + let id = if view == "BarDock" { "dock" } else { "greeter" }; + let entries = store.get("shell:bar.entries").and_then(Value::as_array).cloned().unwrap_or_default(); + let on = entries.iter().any(|e| e["id"] == id && e["enabled"] != false); + let key = format!("live:entry:{id}"); + store.show(&key, json!(on)); + let mut r = r.clone(); + r.key = Some(key); + rows.push(r); + } // AppVolumes: a slider and a mute switch for each stream playing. ("AppVolumes", "ItemList") => { if pop.audio.streams.is_empty() { diff --git a/crates/shell/src/nexus/mod.rs b/crates/shell/src/nexus/mod.rs index 7484bf0..d4c4b82 100644 --- a/crates/shell/src/nexus/mod.rs +++ b/crates/shell/src/nexus/mod.rs @@ -10,6 +10,7 @@ mod kdl; mod niri; mod barpage; mod colourpage; +mod listedit; mod livepage; mod ctxpage; mod wallpage; @@ -67,6 +68,10 @@ const NIRI_RULES: &str = "NiriRules"; #[derive(Debug, Clone, PartialEq)] enum Act { + /// ListEditor: a row (and where it is), its switch, its remove button. + ListRow(String, usize, f32), + ListToggle(String, usize), + ListRemove(String, usize), /// A row of live data: the same as the popouts' controls. Pop(crate::popouts::PopAct), Page(usize), @@ -155,6 +160,7 @@ pub struct Nexus { /// Pages with their runtime rows in place. live: HashMap, pop_acts: Vec, + list_edit: listedit::ListEdit, menu_page: ctxpage::MenuPage, bar_page: barpage::BarPage, colours: colourpage::ColourPage, @@ -194,6 +200,7 @@ impl Nexus { niri: niri::Niri::new(), live: HashMap::new(), pop_acts: Vec::new(), + list_edit: listedit::ListEdit::default(), menu_page: ctxpage::MenuPage::default(), bar_page: Default::default(), colours: Default::default(), @@ -292,7 +299,25 @@ impl Nexus { /// What the live rows asked for since the last call: popout actions and commands. pub fn take_live(&mut self) -> (Vec, Vec<(&'static str, Vec)>) { - let commands = std::mem::take(&mut self.store.changed).iter().flat_map(|(k, v)| livepage::apply(k, v)).collect(); + let changed = std::mem::take(&mut self.store.changed); + // These are settings kept in a list, not machine state. + for (k, v) in &changed { + if let Some(id) = k.strip_prefix("live:qt:") { + self.toggle_shown(id, v.as_bool().unwrap_or(true)); + } else if let Some(id) = k.strip_prefix("live:entry:") { + let mut entries = self.store.get("shell:bar.entries").cloned().unwrap_or(Value::Array(Vec::new())); + if let Some(e) = entries.as_array_mut().and_then(|l| l.iter_mut().find(|e| e["id"] == id)) { + e["enabled"] = v.clone(); + } + self.store.set("shell:bar.entries", entries); + self.bar_page.forget(); + } else if k == "live:addStatus" { + if let Some(id) = v.as_str().filter(|i| !i.is_empty()) { + self.add_status(id); + } + } + } + let commands = changed.iter().flat_map(|(k, v)| livepage::apply(k, v)).collect(); (std::mem::take(&mut self.pop_acts), commands) } @@ -478,7 +503,11 @@ impl Nexus { } } else if livepage::is_live(&view) { if let Some(base) = self.data.subpages.get(&view) { - let page = livepage::expand(&view, base, sh, &mut self.store); + let ids: Vec<(String, bool)> = listedit::CONNECTIVITY.iter().chain(&listedit::TOOLS).chain(&listedit::SYSTEM).map(|t| (t.0.to_string(), self.toggle_is_shown(t.0))).collect(); + let shown = move |id: &str| ids.iter().find(|i| i.0 == id).is_none_or(|i| i.1); + let addable = self.addable_status(); + let base = self.data.subpages.get(&view).unwrap_or(base); + let page = livepage::expand(&view, base, sh, &mut self.store, &shown, &addable); self.live.insert(view.clone(), page); } } @@ -620,6 +649,9 @@ impl Nexus { // A list the original builds at runtime (monitors, devices, plugins...). return y; } + if row.kind == "ListEditor" { + return self.paint_list(p, sh, view, x, y, w); + } if row.kind == "AnimatedLogo" { let h = 150.0; if on_screen(h) { @@ -924,6 +956,10 @@ impl Nexus { d.2 = (x, y); return true; } + if let Some(d) = self.list_edit.drag.as_mut() { + d.3 = y; + return true; + } if let Some((view, i, sx, sw)) = self.drag.clone() { self.slide(&view, i, sx, sw, x); return true; @@ -945,6 +981,9 @@ impl Nexus { let (i, rx, ry) = (*i, *rx, *ry); self.bar_page.drag = Some((i, (x - rx, y - ry), (x, y))); } + if let Some(Hit { act: Act::ListRow(view, i, ry), .. }) = self.pressed.and_then(|i| self.hits.get(i)) { + self.list_edit.drag = Some((view.clone(), *i, y - *ry, y)); + } if let Some(Hit { act: Act::MenuRow(i, (rx, ry)), .. }) = self.pressed.and_then(|i| self.hits.get(i)) { let (i, rx, ry) = (*i, *rx, *ry); self.menu_page.drag = Some((i, (x - rx, y - ry), (x, y))); @@ -968,6 +1007,15 @@ impl Nexus { self.bar_page.drop_at(x, y); return; } + // A press on a row's switch or remove button is that, not a drag. + if self.pressed.and_then(|i| self.hits.get(i)).is_some_and(|h| matches!(h.act, Act::ListToggle(..) | Act::ListRemove(..))) { + self.list_edit.drag = None; + } + if self.list_edit.drag.is_some() { + self.pressed = None; + self.list_move(y); + return; + } if self.drag.take().is_some() { self.pressed = None; return; @@ -1170,7 +1218,9 @@ impl Nexus { self.store.reload(); } Act::Pop(a) => self.pop_acts.push(a), - Act::Slider(..) | Act::None => {} + Act::ListToggle(view, i) => self.list_toggle(&view, i), + Act::ListRemove(view, i) => self.list_remove(&view, i), + Act::ListRow(..) | Act::Slider(..) | Act::None => {} } } @@ -1581,6 +1631,12 @@ fn add_niri_pages(data: &mut Data) { ("BarDock", &["Preview window on desktop"]), // Nothing here reads it: the frame and bar are always one piece. ("AppearancePage", &["Islands"]), + // Moved under Panels, at the user's request; the original splits them. + ("UtilitiesPage", &["Utilities panel", "Quick toggles"]), + // These wait for the sidebar's AI and News tabs. + ("SidebarPanel", &["Sidebar Tabs", "Open on", "Show News tab", "Show Caelestia Mode"]), + // The Quick Share card is not ported. + ("UtilitiesPanelPage", &["Quick Share"]), ("BarWorkspaces", &["Windows on special workspaces", "Per monitor"]), ] { if let Some(p) = data.subpages.get_mut(page) { @@ -1640,6 +1696,34 @@ fn add_niri_pages(data: &mut Data) { p.rows.extend(slideshow); } // Game mode drives niri here. + // Panels → Quick toggle holds everything about the panel: its general rows, the cards it + // shows, and the page of toggles. + let cards = data.subpages.get("UtilitiesPanelPage").map(|p| p.rows.clone()).unwrap_or_default(); + if let Some(page) = data.subpages.get_mut("UtilitiesPanel") { + if let Some(last) = page.rows.last_mut() { + last.last = true; + } + page.rows.extend(cards); + page.rows.push(Row { kind: "SectionHeader".into(), label: Some(Text::Plain("Toggles".into())), ..Row::default() }); + page.rows.push(Row { kind: "NavRow".into(), first: true, last: true, icon: Some(Text::Plain("toggle_on".into())), label: Some(Text::Plain("Quick toggles".into())), target: Some(Value::String("QuickTogglesPage".into())), ..Row::default() }); + } + // SysInfo's custom logo settings, kept in shell.json here, shown only with a custom logo. + if let Some(page) = data.subpages.get_mut("LauncherPanel") { + for r in &mut page.rows { + let name = match &r.label { + Some(Text::Plain(t)) => t.as_str(), + _ => "", + }; + if name == "Tint custom logo" { + r.key = Some("shell:general.logoTint".into()); + r.visible_if = Some("shell:general.logo".into()); + } else if name == "Logo size (%)" { + r.key = Some("shell:general.logoSize".into()); + r.visible_if = Some("shell:general.logo".into()); + (r.from, r.to, r.step) = (Some(50.0), Some(200.0), Some(10.0)); + } + } + } // swaylock is the lock screen here: what it can do, plus when the screen locks and sleeps. if let Some(page) = data.subpages.get_mut("LockScreenPage") { let row = |kind: &str, label: &str, sub: &str, key: &str| Row { diff --git a/crates/shell/src/ui.rs b/crates/shell/src/ui.rs index 17c850d..354055d 100644 --- a/crates/shell/src/ui.rs +++ b/crates/shell/src/ui.rs @@ -2673,7 +2673,7 @@ pub fn draw_bar_logo(p: &mut Painter, shared: &Shared, cx: f32, cy: f32, size: f let img = shared.icons.borrow_mut().as_mut().and_then(|i| i.get(&name, px).cloned()); match img { Some(img) => { - let s = size; + let s = if setting.is_empty() { size } else { size * shared.cfg.general.logo_size.clamp(50, 200) as f32 / 100.0 }; // The distribution's own logo is drawn as a white symbolic silhouette. let img = if setting.is_empty() { let mut white = img.clone(); @@ -2682,6 +2682,8 @@ pub fn draw_bar_logo(p: &mut Painter, shared: &Shared, cx: f32, cy: f32, size: f *px = tiny_skia::PremultipliedColorU8::from_rgba(a, a, a, a).unwrap_or(*px); } white + } else if shared.cfg.general.logo_tint { + crate::draw::colourised(&img, shared.c("primary")) } else { img }; diff --git a/crates/shell/src/utilities.rs b/crates/shell/src/utilities.rs index ef76070..6bddd40 100644 --- a/crates/shell/src/utilities.rs +++ b/crates/shell/src/utilities.rs @@ -266,6 +266,7 @@ fn fade(c: Rgba, op: f32) -> Rgba { /// Quick toggles in the order shown: (id, icon, is a switch). pub fn quick_toggles(shared: &Shared) -> Vec<(String, &'static str, bool)> { + // Toggles.qml `iconFor`, and whether it switches something on or just does it. let known = |id: &str| -> Option<(&'static str, bool)> { Some(match id { "wifi" => ("wifi", true), @@ -277,19 +278,32 @@ pub fn quick_toggles(shared: &Shared) -> Vec<(String, &'static str, bool)> { "gameMode" => ("gamepad", true), "wallpaper" => ("wallpaper", false), "launcher" => ("apps", false), + "overview" => ("view_array", false), "dashboard" => ("dashboard", false), + "restartShell" => ("restart_alt", false), + "visualiser" => ("equalizer", true), + "keepAwake" => ("coffee", true), _ => return None, }) }; + let cfg = &shared.cfg.utilities; + let disabled = |id: &str| cfg.quick_toggles.iter().any(|t| t.id == id && t.enabled == Some(false)); + // Toggles.qml's `builtIn` go after the configured ones. Hotspot, Pause Wallpaper, Night + // Light and EasyEffects have no backend on niri. + let ids = cfg.quick_toggles.iter().map(|t| t.id.as_str()).chain(["restartShell", "visualiser", "keepAwake"]); let mut out: Vec<(String, &'static str, bool)> = Vec::new(); - for t in &shared.cfg.utilities.quick_toggles { - if t.enabled == Some(false) || out.iter().any(|o| o.0 == t.id) { + for id in ids { + if disabled(id) || out.iter().any(|o| o.0 == id) { continue; } - if let Some((icon, sw)) = known(&t.id) { - out.push((t.id.clone(), icon, sw)); + if let Some((icon, sw)) = known(id) { + out.push((id.to_string(), icon, sw)); } } + if cfg.quick_toggles_custom_order { + let pos = |id: &str| cfg.quick_toggles.iter().position(|t| t.id == id).unwrap_or(9999); + out.sort_by_key(|t| pos(&t.0)); + } if !shared.util.order.is_empty() { let pos = |id: &str| shared.util.order.iter().position(|o| o == id).unwrap_or(usize::MAX); out.sort_by_key(|t| pos(&t.0)); @@ -322,6 +336,8 @@ fn toggle_on(shared: &Shared, id: &str) -> bool { "mic" => !u.mic_muted, "dnd" => shared.dnd, "gameMode" => u.game_mode, + "visualiser" => shared.cfg.background.visualiser.enabled, + "keepAwake" => u.keep_awake.is_some(), _ => false, } } @@ -658,7 +674,8 @@ impl Utilities { if row.is_empty() { continue; } - let n = row.len().max(split); + // ButtonRow: each row shares its own width, so a shorter row stretches. + let n = row.len(); let cw = (iw - SPACING_SMALL * (n - 1) as f32) / n as f32; for (k, (id, icon, sw)) in row.iter().enumerate() { let bx = ix + k as f32 * (cw + SPACING_SMALL); diff --git a/crates/shell/src/wl.rs b/crates/shell/src/wl.rs index 652f7f3..3e1d274 100644 --- a/crates/shell/src/wl.rs +++ b/crates/shell/src/wl.rs @@ -1351,6 +1351,28 @@ impl App { self.close_all(); self.open_nexus(None); } + // Starts over in place, as the original's `caelestia shell -k` and start. + "restartShell" => { + use std::os::unix::process::CommandExt; + if let Ok(exe) = std::env::current_exe() { + let _ = Command::new(exe).args(std::env::args().skip(1)).exec(); + } + } + "keepAwake" => return self.util_act(i, crate::utilities::UAct::KeepAwake), + "overview" => { + self.close_all(); + let _ = niri::action(json!({ "ToggleOverview": {} })); + } + "visualiser" => { + let on = !self.shared.cfg.background.visualiser.enabled; + let path = paths::shell_config(); + let mut doc = caelestia_core::config::read_json(&path).unwrap_or_else(|| json!({})); + doc["background"]["visualiser"]["enabled"] = json!(on); + let _ = caelestia_core::config::write_json(&path, &doc); + self.shared.cfg.background.visualiser.enabled = on; + self.update_audio(); + self.mark_bg_dirty(); + } "colorpicker" => self.after_close("niri msg pick-color | sed -n 's/^Hex: //p' | wl-copy"), "wallpaper" => { self.close_all(); diff --git a/docs/AUDIT.md b/docs/AUDIT.md index 441bd9d..6e1f225 100644 --- a/docs/AUDIT.md +++ b/docs/AUDIT.md @@ -202,3 +202,18 @@ A main-thread panic now goes to `~/.local/state/caelestia/crash.log` and the she Tested with recording stand-ins only: real swaylock, swayidle and polkit-gnome are not installed yet. `appearance.islands` is gone from Appearance: nothing here read it, and the user does not want it. + +## Panels pages against the originals (2026-11-04) + +Every key on Dashboard, Taskbar, Launcher, Sidebar, Quick toggle and the taskbar's sub-pages was checked for a reader in the shell: a name match, not a behaviour test of each row. + +| Area | Original | Ours | Closeness | Notes | +|---|---|---|---|---| +| Toggle rows | `cards/Toggles.qml` `QuickToggleRow` (ButtonRow) | `utilities.rs` | exact logic | Each row shares its own width, so a short row stretches. | +| Toggle list | `quickToggles`, `builtIn` | `quick_toggles` | close | Adds Overview, Restart Shell, Audio Visualiser, Keep Awake. Left out with no backend here: Hotspot, VPN, Quick Share, Pause Wallpaper, Night Light, EasyEffects. Restart re-executes the shell. | +| ListEditor | `nexus/common/ListEditor.qml` | `nexus/listedit.rs` | close | Drag, switch, remove; used by Quick toggles and Status icons. The original's overshoot damping and displacement animation are not ported: rows jump on drop. | +| Page layout | Quick toggle under Panels, Utilities panel and Quick toggles under Utilities | all under Panels → Quick toggle | changed | The user's request. Quick Share's card row removed. | +| Enable component | `BarWidgets.setEnabled` | `live:entry:` keys | exact logic | Greeter and Dock. | +| Custom logo | `SysInfo` Qt settings | `general.logoTint`, `general.logoSize` | close | Kept in shell.json. | + +Not ported: per-monitor bar position (the Repeater on Taskbar, whose header stays hidden until then; `cfg.bar.position` is read as one value throughout). GitHub. Sidebar tab rows, removed until the AI and News tabs exist. diff --git a/docs/HANDOFF.md b/docs/HANDOFF.md index 8606364..afb9eca 100644 --- a/docs/HANDOFF.md +++ b/docs/HANDOFF.md @@ -87,7 +87,8 @@ Not confirmed or known wrong: Github (removed or left out on purpose). In Notes: audio recording and playback, file pickers. Dead keys left, with nothing to attach to: `sidebar.defaultTab` and `ai.showNews` wait for the AI and News tabs. `ai.showCaelestiaMode` and BarScreenCapture `show*` are read nowhere in the original outside Nexus, so they stay dead there too. -2. Settings pages, what is left: Network's Add network, Hotspot, Add VPN and provider rows, IPv4 editing; Bluetooth pairing and device info; +2. Desktop icons: the user has noticed they do not work (`DesktopIcons.qml`, `desktopicons/*`; the two Desktop rows do nothing). Then per-monitor bar position on Taskbar. + Settings pages, what is left: Network's Add network, Hotspot, Add VPN and provider rows, IPv4 editing; Bluetooth pairing and device info; audio Device Profiles; Quick Share; Apps' default apps and All apps; Language & region's two widgets; Calendar sources (the clock popout's agenda needs `scripts/calendar_events.py` ported); Export configuration. Notifications, Utilities, Session and most of Services and AI are keyed rows that already work.