batery and time working (POC more than anything)
This commit is contained in:
parent
70ad7e9b65
commit
958b7714da
7 changed files with 107 additions and 25 deletions
|
|
@ -1,19 +1,19 @@
|
|||
#!/usr/bin/env bash
|
||||
set -e
|
||||
if [[ ! -d "/mnt/removable/Projects/Rust/wayland_panel" ]]; then
|
||||
if [[ ! -d "/home/maxag/Projects/Rust/wayland_panel" ]]; then
|
||||
echo "Cannot find source directory; Did you move it?"
|
||||
echo "(Looking for "/mnt/removable/Projects/Rust/wayland_panel")"
|
||||
echo "(Looking for "/home/maxag/Projects/Rust/wayland_panel")"
|
||||
echo 'Cannot force reload with this script - use "direnv reload" manually and then try again'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# rebuild the cache forcefully
|
||||
_nix_direnv_force_reload=1 direnv exec "/mnt/removable/Projects/Rust/wayland_panel" true
|
||||
_nix_direnv_force_reload=1 direnv exec "/home/maxag/Projects/Rust/wayland_panel" true
|
||||
|
||||
# Update the mtime for .envrc.
|
||||
# This will cause direnv to reload again - but without re-building.
|
||||
touch "/mnt/removable/Projects/Rust/wayland_panel/.envrc"
|
||||
touch "/home/maxag/Projects/Rust/wayland_panel/.envrc"
|
||||
|
||||
# Also update the timestamp of whatever profile_rc we have.
|
||||
# This makes sure that we know we are up to date.
|
||||
touch -r "/mnt/removable/Projects/Rust/wayland_panel/.envrc" "/mnt/removable/Projects/Rust/wayland_panel/.direnv"/*.rc
|
||||
touch -r "/home/maxag/Projects/Rust/wayland_panel/.envrc" "/home/maxag/Projects/Rust/wayland_panel/.direnv"/*.rc
|
||||
|
|
|
|||
1
.direnv/flake-inputs/hiqaajlf19pcrhc05q5nnwv4dxznhnsq-source
Symbolic link
1
.direnv/flake-inputs/hiqaajlf19pcrhc05q5nnwv4dxznhnsq-source
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
/nix/store/hiqaajlf19pcrhc05q5nnwv4dxznhnsq-source
|
||||
|
|
@ -1 +0,0 @@
|
|||
/nix/store/sgbaklhjmn4dm32y5fvmg70hccrr47qa-source
|
||||
|
|
@ -47,7 +47,7 @@ NIX_BINTOOLS_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu='1'
|
|||
export NIX_BINTOOLS_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu
|
||||
NIX_BINTOOLS_WRAPPER_TARGET_TARGET_x86_64_unknown_linux_gnu='1'
|
||||
export NIX_BINTOOLS_WRAPPER_TARGET_TARGET_x86_64_unknown_linux_gnu
|
||||
NIX_BUILD_CORES='16'
|
||||
NIX_BUILD_CORES='12'
|
||||
export NIX_BUILD_CORES
|
||||
NIX_CC='/nix/store/kbw2j1vag664b3sj3rjwz9v53cqx87sb-gcc-wrapper-15.2.0'
|
||||
export NIX_CC
|
||||
|
|
@ -65,7 +65,7 @@ NIX_ENFORCE_NO_NATIVE='1'
|
|||
export NIX_ENFORCE_NO_NATIVE
|
||||
NIX_HARDENING_ENABLE='bindnow format fortify fortify3 libcxxhardeningextensive libcxxhardeningfast pic relro stackclashprotection stackprotector strictoverflow zerocallusedregs'
|
||||
export NIX_HARDENING_ENABLE
|
||||
NIX_LDFLAGS='-rpath /mnt/removable/Projects/Rust/wayland_panel/outputs/out/lib -L/nix/store/fv438zxk1mvcfi2sj20mgn4s91qpjdcd-rust-default-1.94.0/lib -L/nix/store/fv438zxk1mvcfi2sj20mgn4s91qpjdcd-rust-default-1.94.0/lib -L/nix/store/jcc9imfj4samq59gwsskxalcd9rjicip-wayland-1.24.0/lib -L/nix/store/jcc9imfj4samq59gwsskxalcd9rjicip-wayland-1.24.0/lib -L/nix/store/k1gvr4prs9736r1lhqyy1plxrrvv9b4m-libxkbcommon-1.11.0/lib -L/nix/store/k1gvr4prs9736r1lhqyy1plxrrvv9b4m-libxkbcommon-1.11.0/lib -L/nix/store/vl8jkqpr0l3fac3cxiy4nwc5paiww1lv-zlib-1.3.1/lib -L/nix/store/vl8jkqpr0l3fac3cxiy4nwc5paiww1lv-zlib-1.3.1/lib -L/nix/store/5mnq195cx3cagnpbbvf5ncbp4fjgy0sz-libffi-3.5.2/lib -L/nix/store/5mnq195cx3cagnpbbvf5ncbp4fjgy0sz-libffi-3.5.2/lib -L/nix/store/md592gfars4m9madyrpj9yrq5jhckgjf-gettext-0.26/lib -L/nix/store/md592gfars4m9madyrpj9yrq5jhckgjf-gettext-0.26/lib -L/nix/store/1qm74vf93ik1xjrr9kl6qvjrklljlcqh-glib-2.86.3/lib -L/nix/store/1qm74vf93ik1xjrr9kl6qvjrklljlcqh-glib-2.86.3/lib -L/nix/store/1il4q8s87v0p8xp1g2q8mmbswbwkj23l-vulkan-loader-1.4.341.0/lib -L/nix/store/1il4q8s87v0p8xp1g2q8mmbswbwkj23l-vulkan-loader-1.4.341.0/lib -L/nix/store/g7wjwz546f510jv95318n23330c3ni7k-mesa-26.0.2/lib -L/nix/store/g7wjwz546f510jv95318n23330c3ni7k-mesa-26.0.2/lib -L/nix/store/wwckb31fcbwj479g7qwcb3b7cv6416pf-libglvnd-1.7.0/lib -L/nix/store/wwckb31fcbwj479g7qwcb3b7cv6416pf-libglvnd-1.7.0/lib -L/nix/store/fv438zxk1mvcfi2sj20mgn4s91qpjdcd-rust-default-1.94.0/lib -L/nix/store/fv438zxk1mvcfi2sj20mgn4s91qpjdcd-rust-default-1.94.0/lib -L/nix/store/jcc9imfj4samq59gwsskxalcd9rjicip-wayland-1.24.0/lib -L/nix/store/jcc9imfj4samq59gwsskxalcd9rjicip-wayland-1.24.0/lib -L/nix/store/k1gvr4prs9736r1lhqyy1plxrrvv9b4m-libxkbcommon-1.11.0/lib -L/nix/store/k1gvr4prs9736r1lhqyy1plxrrvv9b4m-libxkbcommon-1.11.0/lib -L/nix/store/vl8jkqpr0l3fac3cxiy4nwc5paiww1lv-zlib-1.3.1/lib -L/nix/store/vl8jkqpr0l3fac3cxiy4nwc5paiww1lv-zlib-1.3.1/lib -L/nix/store/5mnq195cx3cagnpbbvf5ncbp4fjgy0sz-libffi-3.5.2/lib -L/nix/store/5mnq195cx3cagnpbbvf5ncbp4fjgy0sz-libffi-3.5.2/lib -L/nix/store/md592gfars4m9madyrpj9yrq5jhckgjf-gettext-0.26/lib -L/nix/store/md592gfars4m9madyrpj9yrq5jhckgjf-gettext-0.26/lib -L/nix/store/1qm74vf93ik1xjrr9kl6qvjrklljlcqh-glib-2.86.3/lib -L/nix/store/1qm74vf93ik1xjrr9kl6qvjrklljlcqh-glib-2.86.3/lib -L/nix/store/1il4q8s87v0p8xp1g2q8mmbswbwkj23l-vulkan-loader-1.4.341.0/lib -L/nix/store/1il4q8s87v0p8xp1g2q8mmbswbwkj23l-vulkan-loader-1.4.341.0/lib -L/nix/store/g7wjwz546f510jv95318n23330c3ni7k-mesa-26.0.2/lib -L/nix/store/g7wjwz546f510jv95318n23330c3ni7k-mesa-26.0.2/lib -L/nix/store/wwckb31fcbwj479g7qwcb3b7cv6416pf-libglvnd-1.7.0/lib -L/nix/store/wwckb31fcbwj479g7qwcb3b7cv6416pf-libglvnd-1.7.0/lib'
|
||||
NIX_LDFLAGS='-rpath /home/maxag/Projects/Rust/wayland_panel/outputs/out/lib -L/nix/store/fv438zxk1mvcfi2sj20mgn4s91qpjdcd-rust-default-1.94.0/lib -L/nix/store/fv438zxk1mvcfi2sj20mgn4s91qpjdcd-rust-default-1.94.0/lib -L/nix/store/jcc9imfj4samq59gwsskxalcd9rjicip-wayland-1.24.0/lib -L/nix/store/jcc9imfj4samq59gwsskxalcd9rjicip-wayland-1.24.0/lib -L/nix/store/k1gvr4prs9736r1lhqyy1plxrrvv9b4m-libxkbcommon-1.11.0/lib -L/nix/store/k1gvr4prs9736r1lhqyy1plxrrvv9b4m-libxkbcommon-1.11.0/lib -L/nix/store/vl8jkqpr0l3fac3cxiy4nwc5paiww1lv-zlib-1.3.1/lib -L/nix/store/vl8jkqpr0l3fac3cxiy4nwc5paiww1lv-zlib-1.3.1/lib -L/nix/store/5mnq195cx3cagnpbbvf5ncbp4fjgy0sz-libffi-3.5.2/lib -L/nix/store/5mnq195cx3cagnpbbvf5ncbp4fjgy0sz-libffi-3.5.2/lib -L/nix/store/md592gfars4m9madyrpj9yrq5jhckgjf-gettext-0.26/lib -L/nix/store/md592gfars4m9madyrpj9yrq5jhckgjf-gettext-0.26/lib -L/nix/store/1qm74vf93ik1xjrr9kl6qvjrklljlcqh-glib-2.86.3/lib -L/nix/store/1qm74vf93ik1xjrr9kl6qvjrklljlcqh-glib-2.86.3/lib -L/nix/store/1il4q8s87v0p8xp1g2q8mmbswbwkj23l-vulkan-loader-1.4.341.0/lib -L/nix/store/1il4q8s87v0p8xp1g2q8mmbswbwkj23l-vulkan-loader-1.4.341.0/lib -L/nix/store/g7wjwz546f510jv95318n23330c3ni7k-mesa-26.0.2/lib -L/nix/store/g7wjwz546f510jv95318n23330c3ni7k-mesa-26.0.2/lib -L/nix/store/wwckb31fcbwj479g7qwcb3b7cv6416pf-libglvnd-1.7.0/lib -L/nix/store/wwckb31fcbwj479g7qwcb3b7cv6416pf-libglvnd-1.7.0/lib -L/nix/store/fv438zxk1mvcfi2sj20mgn4s91qpjdcd-rust-default-1.94.0/lib -L/nix/store/fv438zxk1mvcfi2sj20mgn4s91qpjdcd-rust-default-1.94.0/lib -L/nix/store/jcc9imfj4samq59gwsskxalcd9rjicip-wayland-1.24.0/lib -L/nix/store/jcc9imfj4samq59gwsskxalcd9rjicip-wayland-1.24.0/lib -L/nix/store/k1gvr4prs9736r1lhqyy1plxrrvv9b4m-libxkbcommon-1.11.0/lib -L/nix/store/k1gvr4prs9736r1lhqyy1plxrrvv9b4m-libxkbcommon-1.11.0/lib -L/nix/store/vl8jkqpr0l3fac3cxiy4nwc5paiww1lv-zlib-1.3.1/lib -L/nix/store/vl8jkqpr0l3fac3cxiy4nwc5paiww1lv-zlib-1.3.1/lib -L/nix/store/5mnq195cx3cagnpbbvf5ncbp4fjgy0sz-libffi-3.5.2/lib -L/nix/store/5mnq195cx3cagnpbbvf5ncbp4fjgy0sz-libffi-3.5.2/lib -L/nix/store/md592gfars4m9madyrpj9yrq5jhckgjf-gettext-0.26/lib -L/nix/store/md592gfars4m9madyrpj9yrq5jhckgjf-gettext-0.26/lib -L/nix/store/1qm74vf93ik1xjrr9kl6qvjrklljlcqh-glib-2.86.3/lib -L/nix/store/1qm74vf93ik1xjrr9kl6qvjrklljlcqh-glib-2.86.3/lib -L/nix/store/1il4q8s87v0p8xp1g2q8mmbswbwkj23l-vulkan-loader-1.4.341.0/lib -L/nix/store/1il4q8s87v0p8xp1g2q8mmbswbwkj23l-vulkan-loader-1.4.341.0/lib -L/nix/store/g7wjwz546f510jv95318n23330c3ni7k-mesa-26.0.2/lib -L/nix/store/g7wjwz546f510jv95318n23330c3ni7k-mesa-26.0.2/lib -L/nix/store/wwckb31fcbwj479g7qwcb3b7cv6416pf-libglvnd-1.7.0/lib -L/nix/store/wwckb31fcbwj479g7qwcb3b7cv6416pf-libglvnd-1.7.0/lib'
|
||||
export NIX_LDFLAGS
|
||||
NIX_LDFLAGS_FOR_TARGET=' -L/nix/store/fv438zxk1mvcfi2sj20mgn4s91qpjdcd-rust-default-1.94.0/lib -L/nix/store/jcc9imfj4samq59gwsskxalcd9rjicip-wayland-1.24.0/lib -L/nix/store/k1gvr4prs9736r1lhqyy1plxrrvv9b4m-libxkbcommon-1.11.0/lib -L/nix/store/vl8jkqpr0l3fac3cxiy4nwc5paiww1lv-zlib-1.3.1/lib -L/nix/store/5mnq195cx3cagnpbbvf5ncbp4fjgy0sz-libffi-3.5.2/lib -L/nix/store/md592gfars4m9madyrpj9yrq5jhckgjf-gettext-0.26/lib -L/nix/store/1qm74vf93ik1xjrr9kl6qvjrklljlcqh-glib-2.86.3/lib -L/nix/store/1il4q8s87v0p8xp1g2q8mmbswbwkj23l-vulkan-loader-1.4.341.0/lib -L/nix/store/g7wjwz546f510jv95318n23330c3ni7k-mesa-26.0.2/lib -L/nix/store/wwckb31fcbwj479g7qwcb3b7cv6416pf-libglvnd-1.7.0/lib'
|
||||
export NIX_LDFLAGS_FOR_TARGET
|
||||
|
|
@ -178,7 +178,7 @@ name='nix-shell-env'
|
|||
export name
|
||||
nativeBuildInputs=''
|
||||
export nativeBuildInputs
|
||||
out='/mnt/removable/Projects/Rust/wayland_panel/outputs/out'
|
||||
out='/home/maxag/Projects/Rust/wayland_panel/outputs/out'
|
||||
export out
|
||||
outputBin='out'
|
||||
outputDev='out'
|
||||
|
|
@ -211,7 +211,7 @@ declare -a preFixupHooks=('_moveToShare' '_multioutDocs' '_multioutDevs' )
|
|||
preInstallPhases=' glibPreInstallPhase'
|
||||
preferLocalBuild='1'
|
||||
export preferLocalBuild
|
||||
prefix='/mnt/removable/Projects/Rust/wayland_panel/outputs/out'
|
||||
prefix='/home/maxag/Projects/Rust/wayland_panel/outputs/out'
|
||||
declare -a propagatedBuildDepFiles=('propagated-build-build-deps' 'propagated-native-build-inputs' 'propagated-build-target-deps' )
|
||||
propagatedBuildInputs=''
|
||||
export propagatedBuildInputs
|
||||
|
|
|
|||
38
Cargo.lock
generated
38
Cargo.lock
generated
|
|
@ -261,6 +261,19 @@ version = "0.2.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"
|
||||
|
||||
[[package]]
|
||||
name = "chrono"
|
||||
version = "0.4.44"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c673075a2e0e5f4a1dde27ce9dee1ea4558c7ffe648f576438a20ca1d2acc4b0"
|
||||
dependencies = [
|
||||
"iana-time-zone",
|
||||
"js-sys",
|
||||
"num-traits",
|
||||
"wasm-bindgen",
|
||||
"windows-link",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clipboard-win"
|
||||
version = "5.4.1"
|
||||
|
|
@ -969,6 +982,30 @@ version = "0.2.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dfa686283ad6dd069f105e5ab091b04c62850d3e4cf5d67debad1933f55023df"
|
||||
|
||||
[[package]]
|
||||
name = "iana-time-zone"
|
||||
version = "0.1.65"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e31bc9ad994ba00e440a8aa5c9ef0ec67d5cb5e5cb0cc7f8b744a35b389cc470"
|
||||
dependencies = [
|
||||
"android_system_properties",
|
||||
"core-foundation-sys",
|
||||
"iana-time-zone-haiku",
|
||||
"js-sys",
|
||||
"log",
|
||||
"wasm-bindgen",
|
||||
"windows-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "iana-time-zone-haiku"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f"
|
||||
dependencies = [
|
||||
"cc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "iced"
|
||||
version = "0.14.0"
|
||||
|
|
@ -3000,6 +3037,7 @@ dependencies = [
|
|||
name = "wayland_panel"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"iced",
|
||||
"iced_layershell",
|
||||
"winit",
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ version = "0.1.0"
|
|||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
chrono = "0.4.44"
|
||||
iced = { version = "0.14.0", default-features = false, features = ["wgpu", "wayland", "tokio"] }
|
||||
iced_layershell = { version = "0.15.0", default-features = false }
|
||||
winit = { version = "0.30.12", default-features = false, features = ["wayland"] }
|
||||
|
|
|
|||
73
src/main.rs
73
src/main.rs
|
|
@ -1,16 +1,21 @@
|
|||
use chrono::Local;
|
||||
use iced::Color;
|
||||
use iced::Element;
|
||||
use iced::Subscription;
|
||||
use iced::Task;
|
||||
use iced::widget::Row;
|
||||
use iced::widget::container;
|
||||
use iced::widget::row;
|
||||
use iced::widget::text;
|
||||
use iced_layershell::daemon;
|
||||
use iced_layershell::reexport::Anchor;
|
||||
use iced_layershell::settings::LayerShellSettings;
|
||||
use iced_layershell::settings::Settings;
|
||||
use iced_layershell::to_layer_message;
|
||||
use std::time::Duration;
|
||||
|
||||
pub fn main() -> Result<(), iced_layershell::Error> {
|
||||
daemon(App::default, || "rbaw".into(), App::update, App::view)
|
||||
.style(App::style)
|
||||
.theme(App::theme)
|
||||
.subscription(App::subscription)
|
||||
.settings(Settings {
|
||||
layer_settings: LayerShellSettings {
|
||||
|
|
@ -25,29 +30,66 @@ pub fn main() -> Result<(), iced_layershell::Error> {
|
|||
.run()
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
struct App {}
|
||||
struct App {
|
||||
time: chrono::DateTime<chrono::Local>,
|
||||
battery: String,
|
||||
}
|
||||
|
||||
impl Default for App {
|
||||
fn default() -> Self {
|
||||
let mut output = Self {
|
||||
time: Default::default(),
|
||||
battery: Default::default(),
|
||||
};
|
||||
let _ = output.update(Message::Clock);
|
||||
|
||||
output
|
||||
}
|
||||
}
|
||||
|
||||
impl App {
|
||||
fn view(&self, _id: iced::window::Id) -> Element<'_, Message> {
|
||||
let content = Row::new();
|
||||
let display_time = self.time.format("%H:%M");
|
||||
|
||||
container(content)
|
||||
.width(iced::Length::Fill)
|
||||
.height(iced::Length::Fill)
|
||||
.into()
|
||||
let content = row![
|
||||
text!("{}", display_time),
|
||||
iced::widget::space().width(iced::Length::Fill),
|
||||
text!("{}", self.battery),
|
||||
]
|
||||
.padding(iced::Padding::from([0, 5]))
|
||||
.height(iced::Length::Fill)
|
||||
.width(iced::Length::Fill)
|
||||
.align_y(iced::Alignment::Center);
|
||||
|
||||
container(content).into()
|
||||
}
|
||||
fn update(&mut self, _message: Message) -> Task<Message> {
|
||||
|
||||
fn update(&mut self, message: Message) -> Task<Message> {
|
||||
if let Message::Clock = message {
|
||||
self.time = Local::now();
|
||||
self.battery = format!(
|
||||
"{} ",
|
||||
std::fs::read_to_string(std::path::Path::new(
|
||||
"/sys/class/power_supply/BAT0/capacity",
|
||||
))
|
||||
.unwrap()
|
||||
.trim_ascii_end()
|
||||
);
|
||||
}
|
||||
|
||||
Task::none()
|
||||
}
|
||||
fn style(&self, _theme: &iced::Theme) -> iced::theme::Style {
|
||||
todo!()
|
||||
fn style(&self, theme: &iced::Theme) -> iced::theme::Style {
|
||||
iced::theme::Style {
|
||||
background_color: Color::TRANSPARENT,
|
||||
text_color: theme.palette().text,
|
||||
}
|
||||
}
|
||||
fn theme(&self) -> iced::Theme {
|
||||
todo!()
|
||||
fn theme(&self, _id: iced::window::Id) -> iced::Theme {
|
||||
iced::Theme::GruvboxDark
|
||||
}
|
||||
fn subscription(&self) -> iced::Subscription<Message> {
|
||||
Subscription::none()
|
||||
iced::time::every(Duration::from_secs(1)).map(|_| Message::Clock)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -55,4 +97,5 @@ impl App {
|
|||
#[derive(Debug)]
|
||||
enum Message {
|
||||
IcedEvent(iced::Event),
|
||||
Clock,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue