Skip to content

Commit

Permalink
feat(bar): use phosphor icons for uniformity
Browse files Browse the repository at this point in the history
  • Loading branch information
LGUG2Z committed Sep 8, 2024
1 parent 9f78739 commit a4ef858
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 29 deletions.
10 changes: 10 additions & 0 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion komorebi-bar/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ serde_json = "1"
starship-battery = "0.10"
sysinfo = "0.31"
windows = { workspace = true }
windows-icons = "0.1"
windows-icons = "0.1"
egui-phosphor = "0.6.0"
4 changes: 2 additions & 2 deletions komorebi-bar/src/battery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ impl BarWidget for Battery {
if !output.is_empty() {
for battery in output {
let emoji = match self.state {
BatteryState::Charging => "⚡️",
BatteryState::Discharging => "🔋",
BatteryState::Charging => egui_phosphor::regular::BATTERY_CHARGING,
BatteryState::Discharging => egui_phosphor::regular::BATTERY_FULL,
};

ui.add(
Expand Down
10 changes: 7 additions & 3 deletions komorebi-bar/src/date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,13 @@ impl BarWidget for Date {
for output in self.output() {
if ui
.add(
Label::new(format!("📅 {}", output))
.selectable(false)
.sense(Sense::click()),
Label::new(format!(
"{} {}",
egui_phosphor::regular::CALENDAR_DOTS,
output
))
.selectable(false)
.sense(Sense::click()),
)
.clicked()
{
Expand Down
18 changes: 7 additions & 11 deletions komorebi-bar/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ fn main() -> eframe::Result<()> {
enable: true,
hide_empty_workspaces: true,
},
layout: KomorebiLayoutConfig { enable: false },
layout: KomorebiLayoutConfig { enable: true },
focused_window: KomorebiFocusedWindowConfig {
enable: true,
show_icon: true,
Expand Down Expand Up @@ -325,8 +325,9 @@ impl KomorebiNotificationState {
}
}

fn add_custom_font(ctx: &egui::Context, name: &str) {
fn add_custom_font(ctx: &Context, name: &str) {
let mut fonts = egui::FontDefinitions::default();
egui_phosphor::add_to_fonts(&mut fonts, egui_phosphor::Variant::Regular);

let property = FontPropertyBuilder::new().family(name).build();

Expand Down Expand Up @@ -430,14 +431,10 @@ impl eframe::App for Komobar {
.handle_notification(self.rx_gui.clone());

egui::CentralPanel::default()
.frame(
egui::Frame::none()
// TODO: make this configurable
.outer_margin(egui::Margin::symmetric(
self.config.outer_margin.x,
self.config.outer_margin.y,
)),
)
.frame(egui::Frame::none().outer_margin(egui::Margin::symmetric(
self.config.outer_margin.x,
self.config.outer_margin.y,
)))
.show(ctx, |ui| {
ui.horizontal_centered(|ui| {
ui.with_layout(Layout::left_to_right(Align::Center), |ui| {
Expand All @@ -446,7 +443,6 @@ impl eframe::App for Komobar {
}
});

// TODO: make the order configurable
ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
for w in &mut self.right_widgets {
w.render(ctx, ui);
Expand Down
2 changes: 1 addition & 1 deletion komorebi-bar/src/media.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ impl BarWidget for Media {
for output in self.output() {
if ui
.add(
Label::new(format!("🎧 {output}"))
Label::new(format!("{} {output}", egui_phosphor::regular::HEADPHONES))
.selectable(false)
.sense(Sense::click()),
)
Expand Down
2 changes: 1 addition & 1 deletion komorebi-bar/src/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl BarWidget for Memory {
for output in self.output() {
if ui
.add(
Label::new(format!("🐏 {}", output))
Label::new(format!("{} {}", egui_phosphor::regular::MEMORY, output))
.selectable(false)
.sense(Sense::click()),
)
Expand Down
21 changes: 15 additions & 6 deletions komorebi-bar/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,13 @@ impl BarWidget for Network {
1 => {
if ui
.add(
Label::new(format!("📶 {}", output[0]))
.selectable(false)
.sense(Sense::click()),
Label::new(format!(
"{} {}",
egui_phosphor::regular::WIFI_HIGH,
output[0]
))
.selectable(false)
.sense(Sense::click()),
)
.clicked()
{
Expand All @@ -116,9 +120,14 @@ impl BarWidget for Network {
2 => {
if ui
.add(
Label::new(format!("📶 {} - {}", output[0], output[1]))
.selectable(false)
.sense(Sense::click()),
Label::new(format!(
"{} {} - {}",
egui_phosphor::regular::WIFI_HIGH,
output[0],
output[1]
))
.selectable(false)
.sense(Sense::click()),
)
.clicked()
{
Expand Down
10 changes: 7 additions & 3 deletions komorebi-bar/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,13 @@ impl BarWidget for Storage {
for output in self.output() {
if ui
.add(
Label::new(format!("🖴 {}", output))
.selectable(false)
.sense(Sense::click()),
Label::new(format!(
"{} {}",
egui_phosphor::regular::HARD_DRIVES,
output
))
.selectable(false)
.sense(Sense::click()),
)
.clicked()
{
Expand Down
2 changes: 1 addition & 1 deletion komorebi-bar/src/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl BarWidget for Time {
for output in self.output() {
if ui
.add(
Label::new(format!("🕐 {}", output))
Label::new(format!("{} {}", egui_phosphor::regular::CLOCK, output))
.selectable(false)
.sense(Sense::click()),
)
Expand Down

0 comments on commit a4ef858

Please sign in to comment.