Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob-pro committed Dec 29, 2023
1 parent df7e1fc commit f6c9227
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 209 deletions.
4 changes: 2 additions & 2 deletions app/src/apply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ pub fn apply_brightness(
if let Some(err) = error.as_ref() {
log::error!("Failed to set brightness for '{}': {:?}", name, err);
} else {
log::debug!(
"Successfully set brightness for '{}' to {}",
log::info!(
"Successfully set brightness for '{}' to {}%",
name,
brightness.brightness
);
Expand Down
32 changes: 0 additions & 32 deletions app/src/console/bearlib.rs

This file was deleted.

32 changes: 0 additions & 32 deletions app/src/console/mod.rs

This file was deleted.

142 changes: 0 additions & 142 deletions app/src/console/windows.rs

This file was deleted.

18 changes: 17 additions & 1 deletion app/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,27 @@ mod config;
mod gui;
mod tray;
mod unique;
mod controller2;

use std::sync::{Arc, RwLock};
use crate::common::{install_logger, APP_NAME};
use crate::gui::{NextPaint, WgpuWinitApp};
use crate::unique::SsbUniqueInstance;
use egui_winit::winit;
use log::LevelFilter;
use std::time::Instant;
use anyhow::Context;
use winit::event::Event;
use winit::event_loop::EventLoopBuilder;
use winit::platform::run_return::EventLoopExtRunReturn;
use crate::config::SsbConfig;
use crate::controller2::BrightnessController;

#[derive(Debug)]
pub enum UserEvent {
// When the tray button is clicked - we should open or bring forward the window
OpenWindow,
// When the tray exit button is clicked - the application should exit
Exit,
RequestRepaint {
when: Instant,
Expand All @@ -35,6 +42,15 @@ fn run() -> anyhow::Result<()> {
env!("CARGO_PKG_VERSION")
);

let config = Arc::new(RwLock::new(match SsbConfig::load() {
Ok(c) => c,
Err(e) => {
log::warn!("Unable to load config: {:#}", e);
SsbConfig::default()
}
}));
let controller = BrightnessController::start(config);

let mut event_loop = EventLoopBuilder::<UserEvent>::with_user_event().build();

let _tray = tray::create(&event_loop)?;
Expand Down Expand Up @@ -82,7 +98,7 @@ fn run() -> anyhow::Result<()> {
match event_result {
Err(err) => {
log::error!("Exiting because of error: {err:?} on event {event:?}");
returned_result = Err(anyhow::Error::msg("TODO"));
returned_result = Err(err);
control_flow.set_exit();
return;
}
Expand Down

0 comments on commit f6c9227

Please sign in to comment.