aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/config.rs19
-rw-r--r--src/main.rs94
2 files changed, 67 insertions, 46 deletions
diff --git a/src/config.rs b/src/config.rs
index 65720e3..c1b00ae 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -29,7 +29,10 @@ pub struct Config {
pub startup: Option<String>,
}
pub fn directory() -> PathBuf {
- dirs::config_dir()
+ std::env::var_os("XDG_CONFIG_HOME")
+ .filter(|value| !value.is_empty())
+ .map(PathBuf::from)
+ .or_else(dirs::config_dir)
.unwrap_or_else(|| PathBuf::from("."))
.join("ducky")
}
@@ -57,6 +60,14 @@ impl Config {
}
pub(crate) fn parse(source: &str, dir: &std::path::Path) -> Result<Self> {
let lua = Lua::new();
+ let api = lua
+ .create_table()
+ .map_err(|e| anyhow::anyhow!(e.to_string()))?;
+ api.set("config_dir", dir.to_string_lossy().as_ref())
+ .map_err(|e| anyhow::anyhow!(e.to_string()))?;
+ lua.globals()
+ .set("ducky", api)
+ .map_err(|e| anyhow::anyhow!(e.to_string()))?;
let package: Table = lua
.globals()
.get("package")
@@ -173,6 +184,12 @@ mod tests {
assert_eq!(c.palette.len(), 16);
}
#[test]
+ fn prompt_path_uses_platform_config_directory() {
+ let dir = std::path::Path::new("/Users/example/Library/Application Support/ducky");
+ let c = Config::parse(DEFAULT, dir).unwrap();
+ assert_eq!(c.args[1], dir.join("shell.bash").to_string_lossy());
+ }
+ #[test]
fn rejects_bad_config() {
assert!(Config::parse("return {font_size=0}", std::path::Path::new("/tmp")).is_err());
assert!(color("#ff").is_err());
diff --git a/src/main.rs b/src/main.rs
index 34117c3..f6a6dfb 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -539,6 +539,7 @@ impl Render for Ducky {
.flex()
.items_center()
.gap_2()
+ .when(cfg!(target_os = "macos"), |s| s.pl(px(84.)))
.children(tabs)
.child(
div()
@@ -566,51 +567,54 @@ impl Render for Ducky {
}
},
))
- .child(
- div()
- .id("minimize")
- .size(px(28.))
- .rounded_md()
- .flex()
- .items_center()
- .justify_center()
- .text_size(px(14.))
- .text_color(rgb(c.muted))
- .hover(|s| s.bg(rgb(c.surface)).text_color(rgb(c.foreground)))
- .cursor_pointer()
- .child("−")
- .on_click(|_, window, _| window.minimize_window()),
- )
- .child(
- div()
- .id("maximize")
- .size(px(28.))
- .rounded_md()
- .flex()
- .items_center()
- .justify_center()
- .text_size(px(13.))
- .text_color(rgb(c.muted))
- .hover(|s| s.bg(rgb(c.surface)).text_color(rgb(c.foreground)))
- .cursor_pointer()
- .child("□")
- .on_click(|_, window, _| window.zoom_window()),
- )
- .child(
- div()
- .id("close-window")
- .size(px(28.))
- .rounded_md()
- .flex()
- .items_center()
- .justify_center()
- .text_size(px(17.))
- .text_color(rgb(c.muted))
- .hover(|s| s.bg(rgb(0x58333f)).text_color(rgb(0xf5a5b6)))
- .cursor_pointer()
- .child("×")
- .on_click(|_, window, _| window.remove_window()),
- ),
+ .when(!cfg!(target_os = "macos"), |header| {
+ header
+ .child(
+ div()
+ .id("minimize")
+ .size(px(28.))
+ .rounded_md()
+ .flex()
+ .items_center()
+ .justify_center()
+ .text_size(px(14.))
+ .text_color(rgb(c.muted))
+ .hover(|s| s.bg(rgb(c.surface)).text_color(rgb(c.foreground)))
+ .cursor_pointer()
+ .child("−")
+ .on_click(|_, window, _| window.minimize_window()),
+ )
+ .child(
+ div()
+ .id("maximize")
+ .size(px(28.))
+ .rounded_md()
+ .flex()
+ .items_center()
+ .justify_center()
+ .text_size(px(13.))
+ .text_color(rgb(c.muted))
+ .hover(|s| s.bg(rgb(c.surface)).text_color(rgb(c.foreground)))
+ .cursor_pointer()
+ .child("□")
+ .on_click(|_, window, _| window.zoom_window()),
+ )
+ .child(
+ div()
+ .id("close-window")
+ .size(px(28.))
+ .rounded_md()
+ .flex()
+ .items_center()
+ .justify_center()
+ .text_size(px(17.))
+ .text_color(rgb(c.muted))
+ .hover(|s| s.bg(rgb(0x58333f)).text_color(rgb(0xf5a5b6)))
+ .cursor_pointer()
+ .child("×")
+ .on_click(|_, window, _| window.remove_window()),
+ )
+ }),
)
.child(
div()