Skip to content
Open
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
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,14 @@ You can specify alternative configuration locations through:
1. Use the following config keys to configure centerpiece. These are all config keys including their respective defaults.

```yml
scale: 1.0
color:
text: "#ffffff"
background: "#000000"
font:
# To list the available fonts on your system, use `fc-list : family | sed 's/,.*$//' | sort | uniq`
family: monospace # 'monospace' | 'serif' | 'sans_serif' | 'cursive' | 'fantasy' | 'your-font-name'
size: 14
plugin:
applications:
enable: true
Expand Down Expand Up @@ -302,10 +307,16 @@ You can specify alternative configuration locations through:
programs.centerpiece = {
enable = true;
config = {
scale = 1.0;
color = {
text = "#ffffff";
background = "#000000";
};
font = {
# To list the available fonts on your system, use `fc-list : family | sed 's/,.*$//' | sort | uniq`
family = "monospace"; # 'monospace' | 'serif' | 'sans_serif' | 'cursive' | 'fantasy' | 'your-font-name'
size = 14;
};
plugin = {
applications = {
enable = true;
Expand Down
Binary file removed client/assets/FiraCode/FiraCodeNerdFont-Bold.ttf
Binary file not shown.
Binary file removed client/assets/FiraCode/FiraCodeNerdFont-Light.ttf
Binary file not shown.
Binary file removed client/assets/FiraCode/FiraCodeNerdFont-Medium.ttf
Binary file not shown.
Binary file removed client/assets/FiraCode/FiraCodeNerdFont-Regular.ttf
Binary file not shown.
93 changes: 0 additions & 93 deletions client/assets/FiraCode/LICENSE

This file was deleted.

Binary file added client/assets/SymbolsNerdFont.ttf
Binary file not shown.
6 changes: 3 additions & 3 deletions client/src/component/divider.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
pub fn view() -> iced::Element<'static, crate::Message> {
iced::widget::column![iced::widget::horizontal_rule(1)]
.padding(iced::Padding {
top: 1. * crate::REM,
top: 1. * crate::rem(),
right: 0.,
bottom: 0.5 * crate::REM,
bottom: 0.5 * crate::rem(),
left: 0.,
})
// We're fixing the height here to unify it
// with the height of entries for a smooth
// scrolling experience
.height(crate::ENTRY_HEIGHT)
.height(crate::entry_height())
.into()
}
12 changes: 6 additions & 6 deletions client/src/component/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ pub fn view(entry: &crate::model::Entry, active: bool) -> iced::Element<'static,
iced::widget::container(
iced::widget::row![
iced::widget::text(clipped_title(entry.title.clone()))
.size(1. * crate::REM)
.size(1. * crate::rem())
.width(iced::Length::Fill)
.shaping(iced::widget::text::Shaping::Advanced),
iced::widget::text(if active {
entry.action.clone()
} else {
"".to_string()
})
.size(1. * crate::REM)
.size(1. * crate::rem())
]
.padding(0.5 * crate::REM),
.padding(0.5 * crate::rem()),
)
.style(move |theme: &iced::Theme| {
if !active {
Expand All @@ -25,7 +25,7 @@ pub fn view(entry: &crate::model::Entry, active: bool) -> iced::Element<'static,
border: iced::Border {
color: palette.background.base.text,
width: 1.,
radius: iced::border::Radius::from(0.1 * crate::REM),
radius: iced::border::Radius::from(0.1 * crate::rem()),
},
..Default::default()
}
Expand All @@ -34,8 +34,8 @@ pub fn view(entry: &crate::model::Entry, active: bool) -> iced::Element<'static,
// We're fixing the height here to unify it
// with the height of plugin headers for a smooth
// scrolling experience
.height(crate::ENTRY_HEIGHT)
.padding([0., 0.75 * crate::REM])
.height(crate::entry_height())
.padding([0., 0.75 * crate::rem()])
.into()
}

Expand Down
23 changes: 12 additions & 11 deletions client/src/component/plugin_header.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
use crate::settings;

pub fn view(plugin: &crate::model::Plugin) -> iced::Element<'static, crate::Message> {
let mut font = settings().default_font.clone();
font.weight = iced::font::Weight::Light;

iced::widget::row![iced::widget::text(plugin.title.clone())
.font(iced::Font {
family: iced::font::Family::Name("FiraCode Nerd Font"),
weight: iced::font::Weight::Light,
..Default::default()
})
.size(0.75 * crate::REM)]
.font(font)
.size(0.75 * crate::rem())]
// We're fixing the height here to unify it
// with the height of entries for a smooth
// scrolling experience
.height(crate::ENTRY_HEIGHT)
.height(crate::entry_height())
.padding(iced::Padding {
top: 0.8 * crate::REM,
right: 1.25 * crate::REM,
bottom: 0.5 * crate::REM,
left: 1.25 * crate::REM,
top: 0.8 * crate::rem(),
right: 1.25 * crate::rem(),
bottom: 0.5 * crate::rem(),
left: 1.25 * crate::rem(),
})
.into()
}
8 changes: 4 additions & 4 deletions client/src/component/query_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ pub fn view(query: &str, add_horizontal_rule: bool) -> iced::Element<'static, cr
.icon(iced::widget::text_input::Icon {
font: crate::settings().default_font,
code_point: '󰍉',
size: Some(iced::Pixels(1.3 * crate::REM)),
spacing: crate::REM,
size: Some(iced::Pixels(1.3 * crate::rem())),
spacing: crate::rem(),
side: iced::widget::text_input::Side::Left,
})
.size(1. * crate::REM)
.padding([1.0 * crate::REM, 1.2 * crate::REM])
.size(1. * crate::rem())
.padding([1.0 * crate::rem(), 1.2 * crate::rem()])
.style(style),]
.padding(iced::Padding::default().bottom(1.));

Expand Down
36 changes: 21 additions & 15 deletions client/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,11 @@ fn view(centerpice: &Centerpiece) -> iced::Element<Message> {

iced::widget::container::Style {
background: Some(iced::Background::Color(palette.background.base.color)),
border: iced::Border::default().rounded(0.25 * crate::REM),
border: iced::Border::default().rounded(0.25 * crate::rem()),
..Default::default()
}
})
.padding(iced::padding::bottom(0.75 * crate::REM))
.padding(iced::padding::bottom(0.75 * crate::rem()))
.into()
}

Expand Down Expand Up @@ -317,17 +317,22 @@ fn style(_centerpiece: &Centerpiece, _theme: &iced::Theme) -> iced_layershell::A
}

fn settings() -> iced_layershell::build_pattern::MainSettings {
let settings = settings::Settings::get_or_init();

let width = (650.0 * settings.scale).round() as u32;
let height = (380.0 * settings.scale).round() as u32;

iced_layershell::build_pattern::MainSettings {
id: Some(APP_ID.into()),
default_font: iced::Font {
family: iced::font::Family::Name("FiraCode Nerd Font"),
family: settings.font.family,
weight: iced::font::Weight::Normal,
stretch: iced::font::Stretch::Normal,
style: iced::font::Style::default(),
},
default_text_size: iced::Pixels(crate::REM),
default_text_size: iced::Pixels(settings.font.size),
layer_settings: iced_layershell::settings::LayerShellSettings {
size: Some((650, 380)),
size: Some((width, height)),
layer: iced_layershell::reexport::Layer::Top,
anchor: iced_layershell::reexport::Anchor::Top,
keyboard_interactivity: iced_layershell::reexport::KeyboardInteractivity::Exclusive,
Expand All @@ -353,14 +358,9 @@ impl Centerpiece {
plugins: vec![],
},
iced::Task::batch(vec![
iced::font::load(
include_bytes!("../assets/FiraCode/FiraCodeNerdFont-Regular.ttf").as_slice(),
)
.map(Message::FontLoaded),
iced::font::load(
include_bytes!("../assets/FiraCode/FiraCodeNerdFont-Light.ttf").as_slice(),
)
.map(Message::FontLoaded),
// Load the symbols only nerd font to ensure they're always available
iced::font::load(include_bytes!("../assets/SymbolsNerdFont.ttf").as_slice())
.map(Message::FontLoaded),
iced::Task::perform(async {}, move |()| Message::Loaded),
]),
)
Expand Down Expand Up @@ -518,5 +518,11 @@ impl Centerpiece {
}
}

pub const REM: f32 = 14.0;
pub const ENTRY_HEIGHT: f32 = 2.3 * crate::REM;
pub fn rem() -> f32 {
let settings = settings::Settings::get_or_init();
(settings.scale as f32) * settings.font.size
}

pub fn entry_height() -> f32 {
2.3 * rem()
}
19 changes: 19 additions & 0 deletions home-manager-module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ in
enable = lib.mkEnableOption (lib.mdDoc "Centerpiece");

config = {
scale = lib.mkOption {
default = 1.;
type = lib.types.float;
description = lib.mdDoc "Scale factor";
};

color = {
text = lib.mkOption {
default = "#ffffff";
Expand All @@ -28,6 +34,19 @@ in
};
};

font = {
family = lib.mkOption {
default = "monospace";
type = lib.types.str;
description = lib.mdDoc "To list the available fonts on your system, use `fc-list : family | sed 's/,.*$//' | sort | uniq`. May be the name of a font or one of: 'monospace' | 'serif' | 'sans_serif' | 'cursive' | 'fantasy'";
};
size = lib.mkOption {
default = 14;
type = lib.types.int;
description = lib.mdDoc "Font size";
};
};

plugin = {
applications = {
enable = lib.mkOption {
Expand Down
Loading