Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 33 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,30 @@ ICONDIR ?= $(PREFIX)/share/icons/hicolor/scalable/apps

MANIFEST = Cargo.toml
CARGO ?= cargo
CARGO_BUILD_FLAGS ?=
TARGET = target/release/disktree
BUNDLE ?= target/release/Disktree.app
MAC_APPDIR ?= $(HOME)/Applications
ifeq ($(shell uname -s),Darwin)
export MACOSX_DEPLOYMENT_TARGET = 12.0
# macOS 27 rejects host proc-macros misaligned by LLVM's debug stripper.
# Scope the workaround to Mac builds; keep the workspace profiles unchanged.
# https://github.com/rust-lang/rust/issues/157750
CARGO_BUILD_FLAGS += --config 'profile.release.build-override.strip="none"'
CARGO_BUILD_FLAGS += --config 'profile.release.package.gpui-pre-macros.strip="none"'
endif
ICON = assets/disktree.svg
DESKTOP = packaging/disktree.desktop.in

.PHONY: help build run install uninstall lint test ci fmt clean
.PHONY: help build run bundle install uninstall lint test ci fmt clean

help:
@echo "disktree"
@echo
@echo " make build release build"
@echo " make bundle macOS .app bundle"
@echo " make run build and run, scanning $$HOME"
@echo " make install install to $(PREFIX): binary, desktop entry, icon"
@echo " make install macOS: ~/Applications; Linux: $(PREFIX)"
@echo " make uninstall remove what install put there"
@echo " make lint rustfmt --check and clippy -D warnings"
@echo " make test core and window-harness tests"
Expand All @@ -37,7 +49,7 @@ help:
# make file-target would only compare the binary against the manifest and
# happily install a stale build.
build:
$(CARGO) build --release
$(CARGO) build --release $(CARGO_BUILD_FLAGS)

run: build
$(TARGET)
Expand All @@ -53,6 +65,22 @@ ci: lint test
fmt:
$(CARGO) xtask fmt-fix

ifeq ($(shell uname -s),Darwin)
bundle: build
packaging/macos/bundle.sh "$(TARGET)" "$(BUNDLE)"

install: bundle
mkdir -p "$(MAC_APPDIR)"
ditto "$(BUNDLE)" "$(MAC_APPDIR)/Disktree.app"
@echo "Installed $(MAC_APPDIR)/Disktree.app"

uninstall:
rm -rf "$(MAC_APPDIR)/Disktree.app"
else
bundle:
@echo "App bundles require macOS" >&2
@exit 1

install: build
install -d $(BINDIR) $(APPDIR) $(ICONDIR)
install -m755 $(TARGET) $(BINDIR)/disktree
Expand Down Expand Up @@ -82,5 +110,7 @@ uninstall:
fi
@echo "removed"

endif

clean:
$(CARGO) clean
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ removes exactly what was installed.
You need Rust 1.97 or newer and a Wayland or X11 session with a GPU that GPUI
can drive (Vulkan).

### macOS

Requires macOS 12 or newer, Rust 1.97 or newer, and Xcode with the Metal
toolchain. Run `make bundle` to build `target/release/Disktree.app`;
`make install` copies it into `~/Applications`.

Use **File → Open Folder…** (`⌘O`) to choose a folder, and `⌘` instead of
`ctrl` for marking and interface zoom. For protected folders, grant the app
Full Disk Access through **File → Full Disk Access Settings…** and reopen it.

## Use

```sh
Expand Down
Binary file added assets/disktree.icns
Binary file not shown.
4 changes: 3 additions & 1 deletion crates/disktree-app/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
mod git;
mod marks;
mod palette;
mod platform;
mod state;
#[cfg(test)]
mod tests;
Expand Down Expand Up @@ -64,7 +65,7 @@ fn main() -> Result<()> {
gpui_kit::application()
.with_assets(gpui_kit::assets::Assets)
.run(move |cx| {
gpui_omarchy::init(cx);
platform::init(cx);
let options = args.options.clone();
let root_for_app = root.clone();
let window = cx
Expand Down Expand Up @@ -114,6 +115,7 @@ fn main() -> Result<()> {
let _ = window.update(cx, |this, window, cx| {
let focus = this.focus.clone();
window.focus(&focus, cx);
platform::init_window(window, cx);
});
cx.activate(true);
});
Expand Down
156 changes: 156 additions & 0 deletions crates/disktree-app/src/platform.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
//! Desktop integration around the same GPUI/Omarchy components.
#![allow(
clippy::derive_partial_eq_without_eq,
reason = "GPUI's actions! macro derives PartialEq for its generated types"
)]
use gpui_kit::{App, Window};

gpui_kit::actions!(
disktree,
[
Quit,
Hide,
HideOthers,
ShowAll,
OpenFolder,
Reveal,
Rescan,
ScanDisk,
CloseWindow,
FullDiskAccess
]
);

pub fn init(cx: &mut App) {
gpui_omarchy::init(cx);
cx.on_window_closed(|cx, _| {
if cx.windows().is_empty() {
cx.quit();
}
})
.detach();
#[cfg(target_os = "macos")]
{
use gpui_kit::{KeyBinding, Menu, MenuItem};
apply_appearance(cx.window_appearance(), cx);
cx.on_action(|_: &Quit, cx| cx.quit());
cx.on_action(|_: &Hide, cx| cx.hide());
cx.on_action(|_: &HideOthers, cx| cx.hide_other_apps());
cx.on_action(|_: &ShowAll, cx| cx.unhide_other_apps());
cx.on_action(|_: &FullDiskAccess, cx| {
cx.open_url("x-apple.systempreferences:com.apple.preference.security?Privacy_AllFiles");
});
cx.bind_keys([
KeyBinding::new("cmd-q", Quit, None),
KeyBinding::new("cmd-h", Hide, None),
KeyBinding::new("cmd-alt-h", HideOthers, None),
KeyBinding::new("cmd-o", OpenFolder, Some("Disktree")),
KeyBinding::new("cmd-r", Rescan, Some("Disktree")),
KeyBinding::new("cmd-shift-r", Reveal, Some("Disktree")),
KeyBinding::new("cmd-w", CloseWindow, Some("Disktree")),
]);
cx.set_menus([
Menu::new("Disktree").items([
MenuItem::action("Hide Disktree", Hide),
MenuItem::action("Hide Others", HideOthers),
MenuItem::action("Show All", ShowAll),
MenuItem::separator(),
MenuItem::action("Quit Disktree", Quit),
]),
Menu::new("File").items([
MenuItem::action("Open Folder…", OpenFolder),
MenuItem::action("Reveal in Finder", Reveal),
MenuItem::separator(),
MenuItem::action("Scan Again", Rescan),
MenuItem::action("Scan the Whole Volume", ScanDisk),
MenuItem::separator(),
MenuItem::action("Full Disk Access Settings…", FullDiskAccess),
MenuItem::separator(),
MenuItem::action("Close Window", CloseWindow),
]),
]);
}
}

#[cfg_attr(
not(target_os = "macos"),
allow(
clippy::missing_const_for_fn,
reason = "the macOS variant installs a non-const native appearance observer"
)
)]
pub fn init_window(window: &Window, _cx: &mut App) {
#[cfg(target_os = "macos")]
window
.observe_window_appearance(|window, cx| {
apply_appearance(window.appearance(), cx);
})
.detach();
#[cfg(not(target_os = "macos"))]
let _ = window;
}

#[cfg(target_os = "macos")]
fn apply_appearance(appearance: gpui_kit::WindowAppearance, cx: &mut App) {
use gpui_kit::base::ThemeAppearance;
use gpui_kit::{WindowAppearance, rgb};
use gpui_omarchy::Theme;
let dark = matches!(
appearance,
WindowAppearance::Dark | WindowAppearance::VibrantDark
);
let mut theme = if dark {
Theme::tokyo_night()
} else {
Theme::flexoki_light()
};
theme.name = "macOS".into();
theme.font = ".SystemUIFont".into();
theme.appearance = if dark {
ThemeAppearance::Dark
} else {
ThemeAppearance::Light
};
let colors = if dark {
[
0x1c_1c_1e, 0x24_24_26, 0x15_15_17, 0xd7_d7_dc, 0x98_98_9f,
0xf5_f5_f7, 0x0a_84_ff, 0xff_ff_ff, 0x34_34_38, 0x48_48_4d,
0xff_69_61, 0xe9_b4_5a, 0x55_bd_70,
]
} else {
[
0xf5_f5_f7, 0xff_ff_ff, 0xea_ea_ed, 0x30_30_36, 0x64_64_6c,
0x18_18_1b, 0x00_6c_db, 0xff_ff_ff, 0xdb_e9_fa, 0xc6_c6_ce,
0xc6_2e_26, 0x8e_5e_0d, 0x24_7d_3b,
]
};
let [
background,
surface,
inset,
foreground,
secondary,
bright,
accent,
on_accent,
selection,
border,
danger,
warning,
success,
] = colors.map(|c| rgb(c).into());
theme.background = background;
theme.surface = surface;
theme.inset = inset;
theme.foreground = foreground;
theme.secondary = secondary;
theme.bright = bright;
theme.accent = accent;
theme.on_accent = on_accent;
theme.selection = selection;
theme.border = border;
theme.danger = danger;
theme.warning = warning;
theme.success = success;
theme.apply(cx);
}
Loading