Skip to content
This repository has been archived by the owner on Jan 21, 2024. It is now read-only.

Commit

Permalink
cargo deb packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
mjaric committed Oct 14, 2020
1 parent fc59208 commit 0ce416c
Show file tree
Hide file tree
Showing 11 changed files with 83 additions and 61 deletions.
12 changes: 6 additions & 6 deletions Cargo.lock

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

4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ Project is in early phase, and currently code cover just some peaces.
Below is current UI state with fake live data.

<img src="https://github.com/coolio-rs/coolio/blob/master/doc/sample.gif?raw=true" width="500">


# Todo Cross Compile
https://gtk-rs.org/docs-src/tutorial/cross
6 changes: 2 additions & 4 deletions coolio-drivers/src/device_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,14 @@ pub struct DeviceManager {

impl DeviceManager {
pub fn new() -> Result<Self, DriverError> {
let api = hidapi::HidApi::new()?;

if let Some(driver) = resolve_driver(&api) {
if let Some(driver) = resolve_driver(&HAPI) {
Ok(Self { driver })
} else {
Err(DriverError::NoDeviceFound)
}
}

fn write(&self, channel: &str, cfg: DeviceConf) -> Result<(), DriverError> {
pub fn write(&self, channel: &str, cfg: DeviceConf) -> Result<(), DriverError> {
let device = self.driver.device_info().open_device(&HAPI)?;
let writes = self.driver.encode(channel, cfg)?;
let mut write_result: Result<(), DriverError> = Ok(());
Expand Down
5 changes: 3 additions & 2 deletions coolio-drivers/src/drivers/kraken_gen3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl KrakenGen3 {
let stdtemps = (20u8..50u8)
.chain((50u8..=60u8).step_by(2))
.collect::<Vec<_>>();
let normalized = normalize_profile(profile, CRITICAL_TEMPERATURE, MIN_DUTY);
let normalized = normalize_profile(profile, CRITICAL_TEMPERATURE, duty_min);
let interpolated_profile = stdtemps
.iter()
.enumerate()
Expand Down Expand Up @@ -122,7 +122,8 @@ impl Driver for KrakenGen3 {
}

fn supports_cooling_profile(&self) -> bool {
self.supports_cooling && self.firmware_version >= Some((3, 0, 0))
debug!("supports cooling {:?} VERSION {:?}", self.supports_cooling, self.firmware_version);
self.supports_cooling // && self.firmware_version >= Some((3, 0, 0))
}

fn device_info(&self) -> &DeviceInfo {
Expand Down
6 changes: 3 additions & 3 deletions coolio-drivers/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const UNIT_TEMPERATURE: &'static str = "°C";
const UNIT_DUTY: &'static str = "%";


#[derive(Clone, Debug)]
#[derive(Clone, Debug, PartialEq)]
pub struct Metric(String, f64, String, f64);

impl Metric {
Expand Down Expand Up @@ -109,7 +109,7 @@ impl MetricCollector {
.with_components_list();
let system = &mut System::new_with_specifics(refresh_kind);
let device_manager = &mut DeviceManager::new().unwrap();
let pause = 3000;
let pause = Duration::from_millis(2000);
loop {
match stop_rx.try_recv() {
Ok(_) | Err(TryRecvError::Disconnected) => break,
Expand All @@ -130,7 +130,7 @@ impl MetricCollector {
}
}
}
thread::sleep(Duration::from_millis(pause));
thread::sleep(pause);
}
});
Self {
Expand Down
19 changes: 19 additions & 0 deletions coolio-ui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ version = "0.1.0"
authors = ["Milan Jarić <milan.jaric@gmail.com>"]
edition = "2018"
build = "build.rs"
license = "GPL"
repository = "https://github.com/coolio-rs/coolio"
publish = false

[[bin]]
name = "coolio"
Expand Down Expand Up @@ -43,3 +46,19 @@ features = ["v3_22"]
[dependencies.gdk-pixbuf]
version = "0.9"
features = ["v2_32"]


[package.metadata.deb]
name = "coolio-rs"
maintainer = "Milan Jaric"
depends = "$auto"
copyright = "2020, Milan Jaric."
extended-description = "NZXT KrakenX series configurator and monitoring app."
license-file = ["../LICENSE", "2"]
section = "utils"
priority = "optional"
assets = [
["../target/release/coolio", "usr/bin/", "755"],
["res/app-icon.png", "usr/share/icons/coolio-rs/", "644"],
["res/Coolio.desktop", "usr/share/applications/", "644"]
]
4 changes: 2 additions & 2 deletions coolio-ui/res/Coolio.desktop
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[Desktop Entry]
Name=Coolio
Exec={{PATH}}
Icon=
Exec=/usr/bin/coolio
Icon=/usr/share/icons/coolio-rs/app-icon.png
Type=Application
Categories=GTK;GNOME;Utility;
Binary file added coolio-ui/res/app-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 14 additions & 18 deletions coolio-ui/src/coolio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,21 @@ pub struct AppState {}
#[widget]
impl Widget for MainWindow {
fn init_view(&mut self) {
if let Ok(path) = &mut std::env::current_exe() {
path.pop();
path.push("gtk-light.css");
debug!("Trying to load theme from path {:?}", path);
let screen = gdk::Screen::get_default().expect("Error init gtk css provider");

let css = gtk::CssProvider::new();
if let Some(theme_path) = path.to_str() {
if let Err(error) = css.load_from_path(theme_path) {
debug!("Failed to load theme due error {:?}", error);
}
gtk::StyleContext::add_provider_for_screen(
&screen,
&css,
gtk::STYLE_PROVIDER_PRIORITY_USER,
);
gtk::StyleContext::reset_widgets(&screen);
}
let css_str = include_bytes!("../res/gtk-light.css");
let screen = gdk::Screen::get_default().expect("Error init gtk css provider");

let css = gtk::CssProvider::new();

if let Err(error) = css.load_from_data(css_str) {
debug!("Failed to load theme due error {:?}", error);
}
gtk::StyleContext::add_provider_for_screen(
&screen,
&css,
gtk::STYLE_PROVIDER_PRIORITY_USER,
);
gtk::StyleContext::reset_widgets(&screen);


self.main_window.set_default_size(850, 300);
self.main_window.set_resizable(false);
Expand Down
13 changes: 5 additions & 8 deletions coolio-ui/src/widgets/cooling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,9 @@ impl Widget for CoolingPage {
for p in self.model.config.profiles.as_slice() {
self.master_profile_combobox.append(Some(&p.name), &p.name);
}
self.master_profile_combobox.set_active_id(
self
.model
.config
.selected_profile
.as_ref()
.map(String::as_str),
);
if let Some(profile) = &self.model.config.selected_profile {
self.master_profile_combobox.set_active_id(Some(profile));
}
self.cooling_box.get_style_context().add_class("p-10");
self
.main_profile_label
Expand Down Expand Up @@ -107,6 +102,8 @@ impl Widget for CoolingPage {
None
};
let new_current = self.model.config.current();
self.model.device_manager.write("fan", new_current.fan.clone()).unwrap();
self.model.device_manager.write("pump", new_current.pump.clone()).unwrap();
self
.fan_profile
.emit(ProfileConfigMsg::SetProfile(new_current.fan));
Expand Down
43 changes: 25 additions & 18 deletions coolio-ui/src/widgets/profile_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,18 @@ impl relm::Widget for ProfileConfig {

fn update(&mut self, event: ProfileConfigMsg) {
match event {
SetProfile(profile) => match profile {
DeviceConf::VariableSpeed(sensor, p) => {
self.model.selected_sensor = Some(sensor.to_string());
self.model.profile = p;
}
DeviceConf::FixedSpeed(p) => {
self.model.selected_sensor = Some(MonitorHeat::Liquid.to_string());
self.model.profile = (0..16).map(|s| (s * 5 + 20, p)).collect::<Vec<_>>();
}
SetProfile(profile) => {
match profile {
DeviceConf::VariableSpeed(sensor, p) => {
self.model.selected_sensor = Some(sensor.to_string());
self.model.profile = p;
}
DeviceConf::FixedSpeed(p) => {
self.model.selected_sensor = Some(MonitorHeat::Liquid.to_string());
self.model.profile = (0..16).map(|s| (s * 5 + 20, p)).collect::<Vec<_>>();
}
};
self.draw_chart();
},
OnPanelButtonDown(button) => {
let pos = button.get_position();
Expand All @@ -123,7 +126,8 @@ impl relm::Widget for ProfileConfig {
match button.get_button() {
1 => {
// felt mouse button
self.model.selected_index = None
self.model.selected_index = None;
self.draw_chart();
}
3 => {
// right mouse button
Expand All @@ -146,16 +150,20 @@ impl relm::Widget for ProfileConfig {
p.1 = duty.max(p.1)
}
}
self.draw_chart();
}
}
DrawLineChart(_img, _cr) => {
self.draw_chart();
//self.draw_chart();
}
UpdateMetric(metric) => match metric.path().as_slice() {
["dev", "cpu", "heat"] => self.model.cpu_temp = metric.value(),
["dev", "krakenX", "liquid"] => self.model.liquid_temp = metric.value(),
["dev", "krakenM", "liquid"] => self.model.liquid_temp = metric.value(),
_ => (),
UpdateMetric(metric) => {
match metric.path().as_slice() {
["dev", "cpu", "heat"] => self.model.cpu_temp = metric.value(),
["dev", "krakenX", "liquid"] => self.model.liquid_temp = metric.value(),
["dev", "krakenM", "liquid"] => self.model.liquid_temp = metric.value(),
_ => (),
};
self.draw_chart();
},
SelectSensor(val) => self.model.selected_sensor = val,
Ignore => (),
Expand Down Expand Up @@ -343,8 +351,7 @@ impl relm::Widget for ProfileConfig {
#[name="chart"]
gtk::Image {
valign: gtk::Align::Center,
halign: gtk::Align::Center,
draw(w, cr) => (DrawLineChart(w.clone(), cr.clone()), Inhibit(false)),
halign: gtk::Align::Center
},
}
},
Expand Down

0 comments on commit 0ce416c

Please sign in to comment.