Compare commits
No commits in common. "main" and "v0.1.0" have entirely different histories.
11 changed files with 53 additions and 238 deletions
|
|
@ -1,21 +0,0 @@
|
||||||
name: Mirror to GitHub
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: ['**']
|
|
||||||
tags: ['**']
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
mirror:
|
|
||||||
runs-on: [self-hosted, hestia]
|
|
||||||
steps:
|
|
||||||
- name: Mirror to GitHub
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
git clone --mirror "https://git.breadway.dev/${GITHUB_REPOSITORY}.git" repo.git
|
|
||||||
cd repo.git
|
|
||||||
# Mirror only branches and tags (not refs/pull/*, which GitHub rejects);
|
|
||||||
# --prune deletes GitHub refs that no longer exist on Forgejo.
|
|
||||||
git push --prune \
|
|
||||||
"https://x-access-token:${{ secrets.MIRROR_TOKEN }}@github.com/Breadway/breadbox.git" \
|
|
||||||
'+refs/heads/*:refs/heads/*' '+refs/tags/*:refs/tags/*'
|
|
||||||
|
|
@ -1,40 +0,0 @@
|
||||||
name: Build and publish package
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
tags: ['v*']
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
package:
|
|
||||||
runs-on: [self-hosted, hestia]
|
|
||||||
container:
|
|
||||||
image: archlinux:latest
|
|
||||||
steps:
|
|
||||||
# Note: no actions/checkout — the archlinux image has no Node, which JS
|
|
||||||
# actions require. Everything runs as shell steps and clones manually.
|
|
||||||
- name: Build and publish
|
|
||||||
env:
|
|
||||||
PUBLISH_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
VERSION="${GITHUB_REF_NAME#v}"
|
|
||||||
pacman -Syu --noconfirm base-devel git rust cargo gtk4 gtk4-layer-shell librsvg
|
|
||||||
useradd -m builder
|
|
||||||
git config --global --add safe.directory '*'
|
|
||||||
git clone --branch "${GITHUB_REF_NAME}" --depth 1 \
|
|
||||||
"https://git.breadway.dev/${GITHUB_REPOSITORY}.git" /home/builder/src
|
|
||||||
cd /home/builder/src
|
|
||||||
git archive --format=tar.gz --prefix="breadbox-${VERSION}/" HEAD \
|
|
||||||
> packaging/arch/breadbox-${VERSION}.tar.gz
|
|
||||||
SHA=$(sha256sum packaging/arch/breadbox-${VERSION}.tar.gz | awk '{print $1}')
|
|
||||||
sed -i "s/^pkgver=.*/pkgver=${VERSION}/" packaging/arch/PKGBUILD
|
|
||||||
sed -i "s/^sha256sums=.*/sha256sums=('${SHA}')/" packaging/arch/PKGBUILD
|
|
||||||
chown -R builder:builder /home/builder/src
|
|
||||||
# --nocheck: packaging builds the artifact; tests belong in a CI job.
|
|
||||||
su builder -c "cd /home/builder/src/packaging/arch && makepkg -f --noconfirm --nocheck"
|
|
||||||
PKG=$(find /home/builder/src/packaging/arch -name '*.pkg.tar.zst' | head -1)
|
|
||||||
curl -fsS -X PUT \
|
|
||||||
-H "Authorization: token ${PUBLISH_TOKEN}" \
|
|
||||||
-H "Content-Type: application/octet-stream" \
|
|
||||||
--data-binary "@${PKG}" \
|
|
||||||
"https://git.breadway.dev/api/packages/Breadway/arch/os"
|
|
||||||
12
.github/workflows/release.yml
vendored
12
.github/workflows/release.yml
vendored
|
|
@ -9,7 +9,7 @@ permissions:
|
||||||
|
|
||||||
env:
|
env:
|
||||||
DL_DIR: /srv/breadway-dl
|
DL_DIR: /srv/breadway-dl
|
||||||
ECOSYSTEM_DIR: /tmp/bread-ecosystem-ci
|
ECOSYSTEM_DIR: /home/breadway/Projects/bread-ecosystem
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
|
@ -37,12 +37,16 @@ jobs:
|
||||||
cp packaging/breadbox-sync.service "${PKG_DIR}/"
|
cp packaging/breadbox-sync.service "${PKG_DIR}/"
|
||||||
cp config.example.toml "${PKG_DIR}/"
|
cp config.example.toml "${PKG_DIR}/"
|
||||||
cp bakery.toml "${PKG_DIR}/bakery.toml"
|
cp bakery.toml "${PKG_DIR}/bakery.toml"
|
||||||
ln -sfn "${VERSION}" "${DL_DIR}/breadbox/latest"
|
ln -sfn "${PKG_DIR}" "${DL_DIR}/breadbox/latest"
|
||||||
|
|
||||||
- name: ensure bread-ecosystem
|
- name: ensure bread-ecosystem
|
||||||
run: |
|
run: |
|
||||||
rm -rf "${ECOSYSTEM_DIR}"
|
if [[ -d "${ECOSYSTEM_DIR}/.git" ]]; then
|
||||||
git clone https://github.com/Breadway/bread-ecosystem.git "${ECOSYSTEM_DIR}"
|
git -C "${ECOSYSTEM_DIR}" pull --ff-only
|
||||||
|
else
|
||||||
|
mkdir -p "$(dirname "${ECOSYSTEM_DIR}")"
|
||||||
|
git clone https://github.com/Breadway/bread-ecosystem.git "${ECOSYSTEM_DIR}"
|
||||||
|
fi
|
||||||
|
|
||||||
- name: regenerate index.json
|
- name: regenerate index.json
|
||||||
run: bash "${ECOSYSTEM_DIR}/scripts/gen-index.sh"
|
run: bash "${ECOSYSTEM_DIR}/scripts/gen-index.sh"
|
||||||
|
|
|
||||||
11
Cargo.lock
generated
11
Cargo.lock
generated
|
|
@ -28,8 +28,8 @@ checksum = "b4388bee8683e3d04af747c73422af53102d2bd24d9eadb6cbc100baef4b43f8"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bread-theme"
|
name = "bread-theme"
|
||||||
version = "0.2.3"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/Breadway/bread-ecosystem?tag=v0.2.8#77417d552130281ff787e07d52541eb25e9d533b"
|
source = "git+https://github.com/Breadway/bread-ecosystem?tag=v0.1.0#6b5f4f475f66a645b08cb865e6dda8228d23679b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dirs",
|
"dirs",
|
||||||
"gtk4",
|
"gtk4",
|
||||||
|
|
@ -39,7 +39,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "breadbox"
|
name = "breadbox"
|
||||||
version = "0.2.4"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bread-theme",
|
"bread-theme",
|
||||||
"breadbox-shared",
|
"breadbox-shared",
|
||||||
|
|
@ -50,16 +50,15 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "breadbox-shared"
|
name = "breadbox-shared"
|
||||||
version = "0.2.4"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
|
||||||
"toml 0.8.23",
|
"toml 0.8.23",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "breadbox-sync"
|
name = "breadbox-sync"
|
||||||
version = "0.2.4"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"breadbox-shared",
|
"breadbox-shared",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ name = "breadbox"
|
||||||
description = "App launcher for Hyprland / Wayland"
|
description = "App launcher for Hyprland / Wayland"
|
||||||
binaries = ["breadbox", "breadbox-sync"]
|
binaries = ["breadbox", "breadbox-sync"]
|
||||||
system_deps = ["gtk4", "gtk4-layer-shell", "librsvg"]
|
system_deps = ["gtk4", "gtk4-layer-shell", "librsvg"]
|
||||||
optional_system_deps = ["hyprland"]
|
|
||||||
bread_deps = []
|
bread_deps = []
|
||||||
|
|
||||||
[[service]]
|
[[service]]
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,9 @@
|
||||||
[package]
|
[package]
|
||||||
name = "breadbox-shared"
|
name = "breadbox-shared"
|
||||||
version = "0.2.4"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
serde_json = "1"
|
|
||||||
toml = "0.8"
|
toml = "0.8"
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
|
||||||
env,
|
env,
|
||||||
fs::{self, File},
|
fs::{self, File},
|
||||||
io::{BufRead, BufReader},
|
io::{BufRead, BufReader},
|
||||||
|
|
@ -216,38 +215,6 @@ impl Default for IconCache {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---- Launch history ---------------------------------------------------------
|
|
||||||
|
|
||||||
pub struct LaunchHistory {
|
|
||||||
counts: HashMap<String, u32>,
|
|
||||||
path: PathBuf,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl LaunchHistory {
|
|
||||||
pub fn load() -> Self {
|
|
||||||
let path = cache_dir().join("history.json");
|
|
||||||
let counts = fs::read_to_string(&path)
|
|
||||||
.ok()
|
|
||||||
.and_then(|s| serde_json::from_str(&s).ok())
|
|
||||||
.unwrap_or_default();
|
|
||||||
LaunchHistory { counts, path }
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn count(&self, name: &str) -> u32 {
|
|
||||||
self.counts.get(name).copied().unwrap_or(0)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn increment(&mut self, name: &str) {
|
|
||||||
*self.counts.entry(name.to_string()).or_insert(0) += 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn save(&self) {
|
|
||||||
if let Ok(json) = serde_json::to_string(&self.counts) {
|
|
||||||
let _ = fs::write(&self.path, json);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---- Config -----------------------------------------------------------------
|
// ---- Config -----------------------------------------------------------------
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
|
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "breadbox-sync"
|
name = "breadbox-sync"
|
||||||
version = "0.2.4"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "breadbox"
|
name = "breadbox"
|
||||||
version = "0.2.4"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
|
||||||
|
|
@ -9,7 +9,7 @@ name = "breadbox"
|
||||||
path = "src/main.rs"
|
path = "src/main.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bread-theme = { git = "https://github.com/Breadway/bread-ecosystem", tag = "v0.2.8", features = ["gtk"] }
|
bread-theme = { git = "https://github.com/Breadway/bread-ecosystem", tag = "v0.1.0", features = ["gtk"] }
|
||||||
breadbox-shared = { path = "../breadbox-shared" }
|
breadbox-shared = { path = "../breadbox-shared" }
|
||||||
gtk4 = { version = "0.11", features = ["v4_12"] }
|
gtk4 = { version = "0.11", features = ["v4_12"] }
|
||||||
gtk4-layer-shell = "0.8"
|
gtk4-layer-shell = "0.8"
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
use bread_theme::{hex_to_rgba, ink_on, load_palette, Palette};
|
use bread_theme::{hex_to_rgba, load_palette, Palette};
|
||||||
use std::{
|
use std::{
|
||||||
cell::RefCell,
|
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
env,
|
env,
|
||||||
fs,
|
fs,
|
||||||
|
|
@ -12,9 +11,10 @@ use std::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use breadbox_shared::{
|
use breadbox_shared::{
|
||||||
config_dir, load_all_desktop_entries, Config, DesktopEntry, IconCache, LaunchHistory,
|
config_dir, load_all_desktop_entries, Config, DesktopEntry, IconCache,
|
||||||
};
|
};
|
||||||
use gtk4::{
|
use gtk4::{
|
||||||
|
gdk::Display,
|
||||||
glib,
|
glib,
|
||||||
pango::EllipsizeMode,
|
pango::EllipsizeMode,
|
||||||
prelude::*,
|
prelude::*,
|
||||||
|
|
@ -58,7 +58,6 @@ fn load_manifest() -> HashMap<String, PathBuf> {
|
||||||
fn load_sorted_entries(
|
fn load_sorted_entries(
|
||||||
manifest: &HashMap<String, PathBuf>,
|
manifest: &HashMap<String, PathBuf>,
|
||||||
priority: &[String],
|
priority: &[String],
|
||||||
history: &LaunchHistory,
|
|
||||||
) -> Vec<DesktopEntry> {
|
) -> Vec<DesktopEntry> {
|
||||||
let mut entries = load_all_desktop_entries();
|
let mut entries = load_all_desktop_entries();
|
||||||
|
|
||||||
|
|
@ -80,11 +79,7 @@ fn load_sorted_entries(
|
||||||
(Some(i), Some(j)) => i.cmp(&j),
|
(Some(i), Some(j)) => i.cmp(&j),
|
||||||
(Some(_), None) => std::cmp::Ordering::Less,
|
(Some(_), None) => std::cmp::Ordering::Less,
|
||||||
(None, Some(_)) => std::cmp::Ordering::Greater,
|
(None, Some(_)) => std::cmp::Ordering::Greater,
|
||||||
(None, None) => {
|
(None, None) => a.name.to_lowercase().cmp(&b.name.to_lowercase()),
|
||||||
// Most-launched first, then alphabetical
|
|
||||||
history.count(&b.name).cmp(&history.count(&a.name))
|
|
||||||
.then(a.name.to_lowercase().cmp(&b.name.to_lowercase()))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -132,32 +127,26 @@ fn matches_term(field: &str, term: &str) -> bool {
|
||||||
|
|
||||||
fn build_css(p: &Palette) -> String {
|
fn build_css(p: &Palette) -> String {
|
||||||
let bg_panel = hex_to_rgba(&p.background, 0.60);
|
let bg_panel = hex_to_rgba(&p.background, 0.60);
|
||||||
// breadbox-specific rules only — fonts, palette, and generic widgets come
|
|
||||||
// from the shared ecosystem stylesheet (applied first in connect_activate).
|
|
||||||
// Colour is set on each surface (panel, search box, hovered/selected row) so
|
|
||||||
// child labels inherit the legible ink for that background. `on_*` are
|
|
||||||
// luminance-picked black/white — the pywal hues are untouched. Without this a
|
|
||||||
// light `surface` slot makes the selected row's text vanish.
|
|
||||||
format!(
|
format!(
|
||||||
"window {{ background-color: transparent; }}\
|
"* {{ font-family: 'Varela Round', sans-serif; font-size: 14px; }}\
|
||||||
.launcher-bg {{ background-color: {bg_panel}; color: {on_bg}; border-radius: 8px;\
|
window {{ background-color: transparent; }}\
|
||||||
|
.launcher-bg {{ background-color: {bg_panel}; border-radius: 8px;\
|
||||||
box-shadow: 0 8px 32px rgba(0,0,0,0.6); }}\
|
box-shadow: 0 8px 32px rgba(0,0,0,0.6); }}\
|
||||||
searchentry {{ background-color: {surface}; color: {on_surface}; caret-color: {accent};\
|
searchentry {{ background-color: {surface}; color: {fg}; caret-color: {accent};\
|
||||||
border: none; outline: none; box-shadow: none;\
|
border: none; outline: none; box-shadow: none;\
|
||||||
padding: 12px 16px; border-radius: 6px 6px 0 0; }}\
|
padding: 12px 16px; border-radius: 6px 6px 0 0; }}\
|
||||||
listbox {{ background-color: transparent; padding: 4px; }}\
|
listbox {{ background-color: transparent; padding: 4px; }}\
|
||||||
row {{ padding: 8px 12px; color: {on_bg}; background-color: transparent;\
|
row {{ padding: 8px 12px; color: {fg}; background-color: transparent;\
|
||||||
border-radius: 6px; }}\
|
border-radius: 6px; }}\
|
||||||
row:hover {{ background-color: {surface}; color: {on_surface}; }}\
|
row:hover {{ background-color: {surface}; }}\
|
||||||
row:selected {{ background-color: {surface}; color: {on_surface}; }}\
|
row:selected {{ background-color: {surface}; }}\
|
||||||
.app-name {{ font-size: 14px; }}\
|
.app-name {{ font-size: 14px; }}\
|
||||||
.app-muted {{ opacity: 0.6; font-size: 12px; }}\
|
.app-muted {{ color: {fg}; opacity: 0.6; font-size: 12px; }}\
|
||||||
image {{ margin-right: 8px; }}",
|
image {{ margin-right: 8px; }}",
|
||||||
bg_panel = bg_panel,
|
bg_panel = bg_panel,
|
||||||
surface = p.color0,
|
surface = p.color0,
|
||||||
accent = p.color4,
|
fg = p.foreground,
|
||||||
on_bg = ink_on(&p.background),
|
accent = p.color4,
|
||||||
on_surface = ink_on(&p.color0),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -241,17 +230,6 @@ fn fuzzy_matches(pattern: &str, text: &str) -> bool {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fuzzy_score(query: &str, entry: &DesktopEntry) -> u32 {
|
|
||||||
let q = query.to_lowercase();
|
|
||||||
let name = entry.name.to_lowercase();
|
|
||||||
let wm = entry.wm_class.as_deref().unwrap_or("").to_lowercase();
|
|
||||||
if name == q || wm == q { return 0; }
|
|
||||||
if name.starts_with(&q) { return 1; }
|
|
||||||
if name.contains(&q) { return 2; }
|
|
||||||
if wm.starts_with(&q) || wm.contains(&q) { return 3; }
|
|
||||||
4 // subsequence match
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---- PID file toggle --------------------------------------------------------
|
// ---- PID file toggle --------------------------------------------------------
|
||||||
|
|
||||||
fn pid_file() -> PathBuf {
|
fn pid_file() -> PathBuf {
|
||||||
|
|
@ -295,23 +273,24 @@ fn get_row_entry(row: >k4::ListBoxRow) -> Option<DesktopEntry> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_ui(entries: Vec<DesktopEntry>, history: LaunchHistory) {
|
fn run_ui(entries: Vec<DesktopEntry>, css: String) {
|
||||||
let app = Application::builder()
|
let app = Application::builder()
|
||||||
.application_id("com.breadway.breadbox")
|
.application_id("com.breadway.breadbox")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let history_rc = Rc::new(RefCell::new(history));
|
|
||||||
let query_rc: Rc<RefCell<String>> = Rc::new(RefCell::new(String::new()));
|
|
||||||
|
|
||||||
app.connect_activate(move |app| {
|
app.connect_activate(move |app| {
|
||||||
// Shared ecosystem base (fonts, palette, generic widgets) first, then
|
// Base CSS
|
||||||
// breadbox-specific CSS layered on top — both hot-reload on
|
let provider = CssProvider::new();
|
||||||
// `bread-theme reload` (the closure re-reads the pywal palette).
|
provider.load_from_string(&css);
|
||||||
bread_theme::gtk::apply_shared();
|
gtk4::style_context_add_provider_for_display(
|
||||||
bread_theme::gtk::apply_app_css(|| build_css(&load_palette()));
|
&Display::default().expect("no display"),
|
||||||
|
&provider,
|
||||||
|
gtk4::STYLE_PROVIDER_PRIORITY_APPLICATION,
|
||||||
|
);
|
||||||
|
|
||||||
// User CSS override
|
// User CSS override
|
||||||
{
|
{
|
||||||
|
use std::cell::RefCell;
|
||||||
let user_css_path = config_dir().join("style.css");
|
let user_css_path = config_dir().join("style.css");
|
||||||
let user_cell: RefCell<Option<CssProvider>> = RefCell::new(None);
|
let user_cell: RefCell<Option<CssProvider>> = RefCell::new(None);
|
||||||
bread_theme::gtk::apply_user_css(&user_css_path, &user_cell);
|
bread_theme::gtk::apply_user_css(&user_css_path, &user_cell);
|
||||||
|
|
@ -355,7 +334,7 @@ fn run_ui(entries: Vec<DesktopEntry>, history: LaunchHistory) {
|
||||||
let list = ListBox::new();
|
let list = ListBox::new();
|
||||||
list.set_selection_mode(SelectionMode::Browse);
|
list.set_selection_mode(SelectionMode::Browse);
|
||||||
|
|
||||||
for (idx, entry) in entries.iter().enumerate() {
|
for entry in &entries {
|
||||||
let row = gtk4::ListBoxRow::new();
|
let row = gtk4::ListBoxRow::new();
|
||||||
let hbox = GBox::new(Orientation::Horizontal, 0);
|
let hbox = GBox::new(Orientation::Horizontal, 0);
|
||||||
hbox.set_margin_start(6);
|
hbox.set_margin_start(6);
|
||||||
|
|
@ -381,35 +360,9 @@ fn run_ui(entries: Vec<DesktopEntry>, history: LaunchHistory) {
|
||||||
|
|
||||||
row.set_child(Some(&hbox));
|
row.set_child(Some(&hbox));
|
||||||
unsafe { row.set_data("entry", entry.clone()) };
|
unsafe { row.set_data("entry", entry.clone()) };
|
||||||
unsafe { row.set_data("initial_order", idx as u32) };
|
|
||||||
list.append(&row);
|
list.append(&row);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort by match quality + launch count when a query is active;
|
|
||||||
// fall back to insertion order (priority + launch frequency) when empty.
|
|
||||||
let sort_query = Rc::clone(&query_rc);
|
|
||||||
let sort_history = Rc::clone(&history_rc);
|
|
||||||
list.set_sort_func(move |row_a, row_b| {
|
|
||||||
let query = sort_query.borrow();
|
|
||||||
if query.is_empty() {
|
|
||||||
let oa = unsafe { row_a.data::<u32>("initial_order").map_or(u32::MAX, |p| *p.as_ref()) };
|
|
||||||
let ob = unsafe { row_b.data::<u32>("initial_order").map_or(u32::MAX, |p| *p.as_ref()) };
|
|
||||||
return oa.cmp(&ob).into();
|
|
||||||
}
|
|
||||||
let (Some(ea), Some(eb)) = (get_row_entry(row_a), get_row_entry(row_b)) else {
|
|
||||||
return std::cmp::Ordering::Equal.into();
|
|
||||||
};
|
|
||||||
let sa = fuzzy_score(&query, &ea);
|
|
||||||
let sb = fuzzy_score(&query, &eb);
|
|
||||||
let history = sort_history.borrow();
|
|
||||||
let ca = history.count(&ea.name);
|
|
||||||
let cb = history.count(&eb.name);
|
|
||||||
sa.cmp(&sb)
|
|
||||||
.then(cb.cmp(&ca))
|
|
||||||
.then(ea.name.to_lowercase().cmp(&eb.name.to_lowercase()))
|
|
||||||
.into()
|
|
||||||
});
|
|
||||||
|
|
||||||
if let Some(first) = list.row_at_index(0) {
|
if let Some(first) = list.row_at_index(0) {
|
||||||
list.select_row(Some(&first));
|
list.select_row(Some(&first));
|
||||||
}
|
}
|
||||||
|
|
@ -420,11 +373,10 @@ fn run_ui(entries: Vec<DesktopEntry>, history: LaunchHistory) {
|
||||||
|
|
||||||
// Filter on keystroke
|
// Filter on keystroke
|
||||||
let list_f = list.clone();
|
let list_f = list.clone();
|
||||||
let filter_query = Rc::clone(&query_rc);
|
|
||||||
search.connect_changed(move |entry| {
|
search.connect_changed(move |entry| {
|
||||||
let text = entry.text();
|
let text = entry.text();
|
||||||
let query = text.as_str();
|
let query = text.as_str();
|
||||||
*filter_query.borrow_mut() = query.to_string();
|
let mut first_vis: Option<gtk4::ListBoxRow> = None;
|
||||||
let mut i = 0i32;
|
let mut i = 0i32;
|
||||||
while let Some(row) = list_f.row_at_index(i) {
|
while let Some(row) = list_f.row_at_index(i) {
|
||||||
let vis = get_row_entry(&row)
|
let vis = get_row_entry(&row)
|
||||||
|
|
@ -437,12 +389,11 @@ fn run_ui(entries: Vec<DesktopEntry>, history: LaunchHistory) {
|
||||||
})
|
})
|
||||||
.unwrap_or(false);
|
.unwrap_or(false);
|
||||||
row.set_visible(vis);
|
row.set_visible(vis);
|
||||||
|
if vis && first_vis.is_none() {
|
||||||
|
first_vis = Some(row);
|
||||||
|
}
|
||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
list_f.invalidate_sort();
|
|
||||||
let first_vis = (0i32..).find_map(|j| {
|
|
||||||
list_f.row_at_index(j).filter(|r| r.is_visible())
|
|
||||||
});
|
|
||||||
list_f.select_row(first_vis.as_ref());
|
list_f.select_row(first_vis.as_ref());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -451,7 +402,6 @@ fn run_ui(entries: Vec<DesktopEntry>, history: LaunchHistory) {
|
||||||
key_ctrl.set_propagation_phase(gtk4::PropagationPhase::Capture);
|
key_ctrl.set_propagation_phase(gtk4::PropagationPhase::Capture);
|
||||||
let close_k = Rc::clone(&close_all);
|
let close_k = Rc::clone(&close_all);
|
||||||
let list_k = list.clone();
|
let list_k = list.clone();
|
||||||
let history_k = Rc::clone(&history_rc);
|
|
||||||
key_ctrl.connect_key_pressed(move |_, key, _, _| {
|
key_ctrl.connect_key_pressed(move |_, key, _, _| {
|
||||||
use gtk4::gdk::Key;
|
use gtk4::gdk::Key;
|
||||||
match key {
|
match key {
|
||||||
|
|
@ -462,8 +412,6 @@ fn run_ui(entries: Vec<DesktopEntry>, history: LaunchHistory) {
|
||||||
Key::Return | Key::KP_Enter => {
|
Key::Return | Key::KP_Enter => {
|
||||||
if let Some(row) = list_k.selected_row() {
|
if let Some(row) = list_k.selected_row() {
|
||||||
if let Some(entry) = get_row_entry(&row) {
|
if let Some(entry) = get_row_entry(&row) {
|
||||||
history_k.borrow_mut().increment(&entry.name);
|
|
||||||
history_k.borrow().save();
|
|
||||||
do_launch(&entry);
|
do_launch(&entry);
|
||||||
close_k();
|
close_k();
|
||||||
}
|
}
|
||||||
|
|
@ -510,11 +458,8 @@ fn run_ui(entries: Vec<DesktopEntry>, history: LaunchHistory) {
|
||||||
|
|
||||||
// Row click launches
|
// Row click launches
|
||||||
let close_a = Rc::clone(&close_all);
|
let close_a = Rc::clone(&close_all);
|
||||||
let history_a = Rc::clone(&history_rc);
|
|
||||||
list.connect_row_activated(move |_, row| {
|
list.connect_row_activated(move |_, row| {
|
||||||
if let Some(entry) = get_row_entry(row) {
|
if let Some(entry) = get_row_entry(row) {
|
||||||
history_a.borrow_mut().increment(&entry.name);
|
|
||||||
history_a.borrow().save();
|
|
||||||
do_launch(&entry);
|
do_launch(&entry);
|
||||||
close_a();
|
close_a();
|
||||||
}
|
}
|
||||||
|
|
@ -560,9 +505,11 @@ fn main() {
|
||||||
.map(|c| c.priority.clone())
|
.map(|c| c.priority.clone())
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
|
|
||||||
let history = LaunchHistory::load();
|
|
||||||
let manifest = load_manifest();
|
let manifest = load_manifest();
|
||||||
let entries = load_sorted_entries(&manifest, &priority, &history);
|
let entries = load_sorted_entries(&manifest, &priority);
|
||||||
|
|
||||||
run_ui(entries, history);
|
let palette = load_palette();
|
||||||
|
let css = build_css(&palette);
|
||||||
|
|
||||||
|
run_ui(entries, css);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,39 +0,0 @@
|
||||||
# Maintainer: Breadway <rileyhorsham@gmail.com>
|
|
||||||
|
|
||||||
pkgname=breadbox
|
|
||||||
pkgver=0.1.0
|
|
||||||
pkgrel=1
|
|
||||||
pkgdesc="App launcher for Hyprland / Wayland"
|
|
||||||
arch=('x86_64')
|
|
||||||
url="https://github.com/Breadway/breadbox"
|
|
||||||
license=('MIT')
|
|
||||||
# Some Rust deps (ring/mlua) build vendored C/asm into static archives; makepkg's
|
|
||||||
# default -flto=auto emits GCC LTO bitcode the Rust (lld) link cannot read,
|
|
||||||
# causing undefined-symbol errors. Disable LTO.
|
|
||||||
options=(!lto !debug)
|
|
||||||
depends=('gtk4' 'gtk4-layer-shell' 'librsvg')
|
|
||||||
optdepends=(
|
|
||||||
'hyprland: window and workspace integration'
|
|
||||||
)
|
|
||||||
makedepends=('rust' 'cargo')
|
|
||||||
source=("${pkgname}-${pkgver}.tar.gz")
|
|
||||||
sha256sums=('SKIP')
|
|
||||||
|
|
||||||
build() {
|
|
||||||
cd "${srcdir}/${pkgname}-${pkgver}"
|
|
||||||
cargo build --release --locked
|
|
||||||
}
|
|
||||||
|
|
||||||
check() {
|
|
||||||
cd "${srcdir}/${pkgname}-${pkgver}"
|
|
||||||
cargo test --release --locked --workspace
|
|
||||||
}
|
|
||||||
|
|
||||||
package() {
|
|
||||||
cd "${srcdir}/${pkgname}-${pkgver}"
|
|
||||||
install -Dm755 target/release/breadbox "${pkgdir}/usr/bin/breadbox"
|
|
||||||
install -Dm755 target/release/breadbox-sync "${pkgdir}/usr/bin/breadbox-sync"
|
|
||||||
install -Dm644 packaging/breadbox-sync.service \
|
|
||||||
"${pkgdir}/usr/lib/systemd/user/breadbox-sync.service"
|
|
||||||
install -Dm644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue