├── .gitignore ├── src ├── modules │ ├── mod.rs │ ├── module.rs │ ├── date.rs │ ├── battery.rs │ └── workspace.rs ├── config.rs ├── layout.rs └── main.rs ├── .gitmodules ├── README.md ├── Cargo.toml └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | **/*.rs.bk 3 | run/* 4 | Cargo.lock 5 | -------------------------------------------------------------------------------- /src/modules/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod module; 2 | pub mod date; 3 | pub mod workspace; 4 | pub mod battery; -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "gtk-layer-shell-rs"] 2 | path = gtk-layer-shell-rs 3 | url = https://github.com/subgraph/gtk-layer-shell-rs.git 4 | -------------------------------------------------------------------------------- /src/modules/module.rs: -------------------------------------------------------------------------------- 1 | use glib::IsA; 2 | use gtk::Widget; 3 | use serde::de::DeserializeOwned; 4 | use serde_json::Value; 5 | 6 | pub trait Module 7 | where W: IsA { 8 | fn into_widget(self) -> W; 9 | 10 | fn from_value(v: &Value) -> Box 11 | where Self: DeserializeOwned { 12 | serde_json::from_value(v.clone()).unwrap() 13 | } 14 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # rustbar 2 | 3 | Abandoned, try this instead: 4 | 5 | https://github.com/JakeStanger/ironbar 6 | 7 | ## Compile & run 8 | 9 | Assuming you have `git`, `cargo` and [gtk-layer-shell](https://github.com/wmww/gtk-layer-shell) installed: 10 | ``` 11 | git clone https://github.com/zeroeightysix/rustbar 12 | cargo build --release 13 | target/build/rustbar 14 | ``` 15 | (`cargo run` in development) 16 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rustbar" 3 | version = "0.1.0" 4 | authors = ["zeroeightsix"] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | gtk-layer-shell-rs = { path = "gtk-layer-shell-rs/" } 11 | tokio = { version = "0.2.21", features = ["macros", "rt-threaded", "time", "sync", "blocking"] } 12 | futures = "0.3.5" 13 | chrono = "0.4.11" 14 | serde = { version = "1.0.111", features = ["derive"] } 15 | serde_json = "1.0.55" 16 | json5 = "0.2.7" 17 | ksway = "0.1.0" 18 | battery = "0.7.5" 19 | 20 | [dependencies.gtk] 21 | git = "https://github.com/gtk-rs/gtk" 22 | 23 | [dependencies.gio] 24 | git = "https://github.com/gtk-rs/gio" 25 | 26 | [dependencies.glib] 27 | git = "https://github.com/gtk-rs/glib" 28 | 29 | [dependencies.gdk] 30 | git = "https://github.com/gtk-rs/gdk" 31 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Ridan Vandenbergh 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/modules/date.rs: -------------------------------------------------------------------------------- 1 | use chrono::Local; 2 | use glib::Continue; 3 | use gtk::{Label, LabelExt}; 4 | use serde::Deserialize; 5 | use tokio::{ 6 | spawn, 7 | time::delay_for, 8 | }; 9 | 10 | use crate::modules::module::Module; 11 | 12 | #[derive(Deserialize)] 13 | pub struct DateModule { 14 | #[serde(default = "default_format")] 15 | format: String 16 | } 17 | 18 | fn default_format() -> String { 19 | String::from("%I:%M:%S %P %A %d-%m-%Y") 20 | } 21 | 22 | impl Module