Skip to content
Merged
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
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "capybar"
description = "Wayland native toolbar"
version = "0.2.0"
version = "0.3.0"
edition = "2021"
license = "MIT"
repository = "https://github.com/CapyCore/capybar"
Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Simple customizable bar applications that aims to have as little external depend
- Custom widgets creation via rust
- Pre-built widgets:
- Text
- IconText
- Clock
- Battery
- CPU usage
Expand Down Expand Up @@ -43,7 +44,14 @@ programs.capybar = {
```

### Others
Currently bar needs to be build manually. To do so clone the repo and write main file. Bulding the bar is done with cargo. The example is located in examples folder.
Capybar can be installed via cargo using
```cmd
cargo install capybar
```
This will install and setup `capybar` executable.

### Building from source
Bulding the bar is done with cargo. The example is located in examples folder.
```
cargo build --release
```
Expand Down
46 changes: 30 additions & 16 deletions examples/basic/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use capybar::{
containers::bar::{Bar, BarSettings},
cpu::{CPUSettings, CPU},
text::TextSettings,
Style, WidgetData, WidgetNew,
Margin, Style, WidgetData, WidgetNew,
},
};
use wayland_client::{globals::registry_queue_init, Connection};
Expand All @@ -28,14 +28,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let conn = Connection::connect_to_env()?;
let (globals, mut event_queue) = registry_queue_init(&conn)?;

let mut capybar = Root::new(&globals, &mut event_queue)?;

// Fonts can be replaces by your liking. The first font added will be used for normal text, the
// second for emoji
//capybar.add_font_by_name("mono")?;
capybar.add_font_by_name("jetbrainsmononerdfont")?;
capybar.add_font_by_name("jetbrainsmononerdfont")?;

let mut bar = Bar::new(
None,
BarSettings {
Expand All @@ -57,7 +49,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
)?;

// Left widgets
bar.create_child_left(
bar.create_widget_left(
CPU::new,
CPUSettings {
update_rate: 1000,
Expand All @@ -68,15 +60,23 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
..TextSettings::default()
},
default_data: WidgetData {
margin: (10, 0, 0, 0),
..WidgetData::default()
},
style: Style {
margin: Margin {
left: 10,
right: 0,
up: 0,
down: 0,
},
..Default::default()
},
..CPUSettings::default()
},
)?;

//Center widgets
bar.create_child_center(
bar.create_widget_center(
Clock::new,
ClockSettings {
font_color: catpuccin_mocha.font,
Expand All @@ -87,7 +87,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
)?;

// Right widgets
bar.create_child_right(
bar.create_widget_right(
Battery::new,
BatterySettings {
text_settings: TextSettings {
Expand All @@ -97,16 +97,30 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
..TextSettings::default()
},
default_data: WidgetData {
margin: (0, 10, 0, 0),
..WidgetData::default()
},
style: Style {
margin: Margin {
left: 0,
right: 10,
up: 0,
down: 0,
},
..Default::default()
},
..BatterySettings::default()
},
)?;

capybar.add_widget(bar)?;
let mut capybar = Root::new(&globals, &mut event_queue, Some(bar))?;

// Fonts can be replaces by your liking. The first font added will be used for normal text, the
// second for emoji
//capybar.add_font_by_name("mono")?;
capybar.add_font_by_name("jetbrainsmononerdfont")?;
capybar.add_font_by_name("jetbrainsmononerdfont")?;

capybar.init(&mut event_queue)?.run(&mut event_queue)?;
capybar.run(&mut event_queue)?;

Ok(())
}
Binary file modified examples/toml_config/bar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 19 additions & 15 deletions examples/toml_config/config.toml
Original file line number Diff line number Diff line change
@@ -1,47 +1,51 @@
#TOML does not support variables interpolation, so this is just a place to copy values from
[palete]
font = 0xf5e0dcff
background = 0x1e1e2eff
border = 0x74c7ecff
font = 0xf5e0dcff
background = 0x1e1e2eff
border = 0x74c7ecff

[preloaded_fonts]
list = ["mono", "jetbrainsmononerdfont"]
list = ["mono", "jetbrainsmononerdfont"]

[bar.settings]
width = 1920
background = 0x1e1e2eff
border = [1, 0x74c7ecff]
width = 1920
background = 0x1e1e2eff
border = [1, 0x74c7ecff]
padding = [5,5,5]
[bar.settings.left_settings]
margin = [3,0,3,3]
[bar.settings.right_settings]
margin = [0,6,3,3]

[[bar.left]]
widget = "keyboard"
[[bar.left.settings]]
size = 24
font_color = 0xf5e0dcff
margin = [10,0,0,0]
layout_mappings = {"Russian" = "RU", "English (US)" = "EN"}
border = [1, 0x74c7ecff]
[[bar.left.settings]]
update_rate = 0
update_rate = 100

[[bar.left]]
widget = "cpu"
[bar.left.settings]
size = 24
font_color = 0xf5e0dcff
margin = [10,0,0,0]
border = [1, 0x74c7ecff]

[[bar.center]]
widget = "clock"
[bar.center.settings]
size = 24
font_color = 0xf5e0dcff
margin = [0,3,3,0]
border = [1, 0x74c7ecff]

[[bar.right]]
widget = "battery"
[bar.right.settings]
size = 24
font_color = 0xf5e0dcff
margin = [0,10,0,0]




margin = [0,3,3,0]
border = [1, 0x74c7ecff]
4 changes: 2 additions & 2 deletions examples/toml_config/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ fn main() -> Result<()> {
let conn = Connection::connect_to_env()?;
let (globals, mut event_queue) = registry_queue_init(&conn)?;

let mut capybar = Root::new(&globals, &mut event_queue)?;
let mut capybar = Root::new(&globals, &mut event_queue, None)?;
capybar.apply_config(config)?;

capybar.init(&mut event_queue)?.run(&mut event_queue)?;
capybar.run(&mut event_queue)?;

Ok(())
}
8 changes: 4 additions & 4 deletions flake.lock

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

8 changes: 4 additions & 4 deletions src/config/widgets/bar.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
use serde::Deserialize;

use crate::widgets::{containers::bar::BarSettings, WidgetsList};
use crate::widgets::{containers::bar::BarSettings, WidgetsSettingsList};

#[derive(Default, Deserialize, Debug)]
pub struct Bar {
#[serde(default)]
pub settings: BarSettings,
#[serde(default)]
pub left: Vec<WidgetsList>,
pub left: Vec<WidgetsSettingsList>,
#[serde(default)]
pub center: Vec<WidgetsList>,
pub center: Vec<WidgetsSettingsList>,
#[serde(default)]
pub right: Vec<WidgetsList>,
pub right: Vec<WidgetsSettingsList>,
}

impl Bar {
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pub mod config;
pub mod processes;
pub mod root;
pub mod services;
pub mod util;
pub mod widgets;
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ fn main() -> Result<()> {
let conn = Connection::connect_to_env()?;
let (globals, mut event_queue) = registry_queue_init(&conn)?;

let mut capybar = Root::new(&globals, &mut event_queue)?;
let mut capybar = Root::new(&globals, &mut event_queue, None)?;
capybar.apply_config(config)?;

capybar.init(&mut event_queue)?.run(&mut event_queue)?;
capybar.run(&mut event_queue)?;

Ok(())
}
57 changes: 0 additions & 57 deletions src/processes/mod.rs

This file was deleted.

Loading
Loading