Improve GUI
This commit is contained in:
parent
8d8f4932c1
commit
a795200245
67
Cargo.lock
generated
67
Cargo.lock
generated
@ -160,14 +160,14 @@ dependencies = [
|
|||||||
"glutin 0.29.1",
|
"glutin 0.29.1",
|
||||||
"gumdrop",
|
"gumdrop",
|
||||||
"image",
|
"image",
|
||||||
"log",
|
|
||||||
"nix 0.25.0",
|
"nix 0.25.0",
|
||||||
"parking_lot 0.12.1",
|
"parking_lot 0.12.1",
|
||||||
"pretty_env_logger",
|
|
||||||
"serde",
|
"serde",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"tokio",
|
"tokio",
|
||||||
"toml",
|
"toml",
|
||||||
|
"tracing",
|
||||||
|
"tracing-subscriber",
|
||||||
"vulkano",
|
"vulkano",
|
||||||
"vulkano-shaders",
|
"vulkano-shaders",
|
||||||
"vulkano-win",
|
"vulkano-win",
|
||||||
@ -213,11 +213,11 @@ version = "0.1.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"amdgpu",
|
"amdgpu",
|
||||||
"futures",
|
"futures",
|
||||||
"log",
|
|
||||||
"pretty_env_logger",
|
|
||||||
"ron 0.7.1",
|
"ron 0.7.1",
|
||||||
"serde",
|
"serde",
|
||||||
"tokio",
|
"tokio",
|
||||||
|
"tracing",
|
||||||
|
"tracing-subscriber",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -249,6 +249,15 @@ dependencies = [
|
|||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ansi_term"
|
||||||
|
version = "0.12.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
|
||||||
|
dependencies = [
|
||||||
|
"winapi",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "arboard"
|
name = "arboard"
|
||||||
version = "2.1.1"
|
version = "2.1.1"
|
||||||
@ -2509,6 +2518,15 @@ dependencies = [
|
|||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "sharded-slab"
|
||||||
|
version = "0.1.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31"
|
||||||
|
dependencies = [
|
||||||
|
"lazy_static",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "shared_library"
|
name = "shared_library"
|
||||||
version = "0.1.9"
|
version = "0.1.9"
|
||||||
@ -2698,6 +2716,15 @@ dependencies = [
|
|||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "thread_local"
|
||||||
|
version = "1.1.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180"
|
||||||
|
dependencies = [
|
||||||
|
"once_cell",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "threadpool"
|
name = "threadpool"
|
||||||
version = "1.8.1"
|
version = "1.8.1"
|
||||||
@ -2840,6 +2867,32 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "5aeea4303076558a00714b823f9ad67d58a3bbda1df83d8827d21193156e22f7"
|
checksum = "5aeea4303076558a00714b823f9ad67d58a3bbda1df83d8827d21193156e22f7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"once_cell",
|
"once_cell",
|
||||||
|
"valuable",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tracing-log"
|
||||||
|
version = "0.1.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922"
|
||||||
|
dependencies = [
|
||||||
|
"lazy_static",
|
||||||
|
"log",
|
||||||
|
"tracing-core",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tracing-subscriber"
|
||||||
|
version = "0.3.15"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "60db860322da191b40952ad9affe65ea23e7dd6a5c442c2c42865810c6ab8e6b"
|
||||||
|
dependencies = [
|
||||||
|
"ansi_term",
|
||||||
|
"sharded-slab",
|
||||||
|
"smallvec",
|
||||||
|
"thread_local",
|
||||||
|
"tracing-core",
|
||||||
|
"tracing-log",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -2906,6 +2959,12 @@ dependencies = [
|
|||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "valuable"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "vec_map"
|
name = "vec_map"
|
||||||
version = "0.8.2"
|
version = "0.8.2"
|
||||||
|
@ -127,6 +127,7 @@ impl OutputType {
|
|||||||
Some(match s {
|
Some(match s {
|
||||||
"DP" => Self::DisplayPort,
|
"DP" => Self::DisplayPort,
|
||||||
"eDP" => Self::MiniDisplayPort,
|
"eDP" => Self::MiniDisplayPort,
|
||||||
|
"DVI" => Self::Dvi,
|
||||||
"HDMI" => Self::Hdmi,
|
"HDMI" => Self::Hdmi,
|
||||||
_ => return None,
|
_ => return None,
|
||||||
})
|
})
|
||||||
@ -174,6 +175,7 @@ pub struct Output {
|
|||||||
pub status: Status,
|
pub status: Status,
|
||||||
#[serde(rename = "M")]
|
#[serde(rename = "M")]
|
||||||
pub modes: Vec<OutputMode>,
|
pub modes: Vec<OutputMode>,
|
||||||
|
pub display_power_managment: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
|
||||||
|
@ -37,8 +37,8 @@ toml = { version = "0.5" }
|
|||||||
thiserror = { version = "1.0" }
|
thiserror = { version = "1.0" }
|
||||||
gumdrop = { version = "0.8" }
|
gumdrop = { version = "0.8" }
|
||||||
|
|
||||||
log = { version = "0.4" }
|
tracing = { version = "0.1.36" }
|
||||||
pretty_env_logger = { version = "0.4" }
|
tracing-subscriber = { version = "0.3.15" }
|
||||||
|
|
||||||
egui = { version = "0.18", optional = true, features = [] }
|
egui = { version = "0.18", optional = true, features = [] }
|
||||||
epaint = { version = "0.18", features = [], optional = true }
|
epaint = { version = "0.18", features = [], optional = true }
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 39 KiB |
BIN
amdguid/assets/icons/ports2.png
Normal file
BIN
amdguid/assets/icons/ports2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 51 KiB |
@ -41,6 +41,14 @@ impl FanService {
|
|||||||
|
|
||||||
pub struct FanServices(pub Vec<FanService>);
|
pub struct FanServices(pub Vec<FanService>);
|
||||||
|
|
||||||
|
impl std::ops::Deref for FanServices {
|
||||||
|
type Target = Vec<FanService>;
|
||||||
|
|
||||||
|
fn deref(&self) -> &Self::Target {
|
||||||
|
&self.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl FanServices {
|
impl FanServices {
|
||||||
pub fn list_changed(&self, other: &[Pid]) -> bool {
|
pub fn list_changed(&self, other: &[Pid]) -> bool {
|
||||||
if self.0.len() != other.len() {
|
if self.0.len() != other.len() {
|
||||||
@ -108,8 +116,8 @@ impl StatefulConfig {
|
|||||||
|
|
||||||
// 80x80
|
// 80x80
|
||||||
let image = {
|
let image = {
|
||||||
let bytes = include_bytes!("../assets/icons/ports2.jpg");
|
let bytes = include_bytes!("../assets/icons/ports2.png");
|
||||||
image::load_from_memory_with_format(bytes, ImageFormat::Jpeg).unwrap()
|
image::load_from_memory_with_format(bytes, ImageFormat::Png).unwrap()
|
||||||
};
|
};
|
||||||
|
|
||||||
let ctx = ui.ctx();
|
let ctx = ui.ctx();
|
||||||
@ -139,8 +147,8 @@ impl StatefulConfig {
|
|||||||
|
|
||||||
pub struct AmdGui {
|
pub struct AmdGui {
|
||||||
pub page: Page,
|
pub page: Page,
|
||||||
pid_files: FanServices,
|
pid_files: SocketState<FanServices>,
|
||||||
outputs: BTreeMap<String, Vec<Output>>,
|
outputs: SocketState<BTreeMap<String, Vec<Output>>>,
|
||||||
cooling_performance: CoolingPerformance,
|
cooling_performance: CoolingPerformance,
|
||||||
change_fan_settings: ChangeFanSettings,
|
change_fan_settings: ChangeFanSettings,
|
||||||
outputs_settings: OutputsSettings,
|
outputs_settings: OutputsSettings,
|
||||||
@ -160,13 +168,13 @@ impl AmdGui {
|
|||||||
pub fn new_with_config(config: FanConfig) -> Self {
|
pub fn new_with_config(config: FanConfig) -> Self {
|
||||||
Self {
|
Self {
|
||||||
page: Default::default(),
|
page: Default::default(),
|
||||||
pid_files: FanServices::from(vec![]),
|
pid_files: SocketState::NotAvailable,
|
||||||
outputs: Default::default(),
|
outputs: SocketState::NotAvailable,
|
||||||
cooling_performance: CoolingPerformance::new(100, config.clone()),
|
cooling_performance: CoolingPerformance::new(100, config.clone()),
|
||||||
change_fan_settings: ChangeFanSettings::new(config.clone()),
|
change_fan_settings: ChangeFanSettings::new(config.clone()),
|
||||||
outputs_settings: OutputsSettings::default(),
|
outputs_settings: OutputsSettings::default(),
|
||||||
config: StatefulConfig::new(config),
|
config: StatefulConfig::new(config),
|
||||||
reload_pid_list_delay: RELOAD_PID_LIST_DELAY,
|
reload_pid_list_delay: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,40 +183,64 @@ impl AmdGui {
|
|||||||
|
|
||||||
match self.page {
|
match self.page {
|
||||||
Page::Config => {
|
Page::Config => {
|
||||||
|
if let SocketState::Connected(pid_files) = &mut self.pid_files {
|
||||||
self.change_fan_settings
|
self.change_fan_settings
|
||||||
.draw(ui, &mut self.pid_files, &mut self.config);
|
.draw(ui, pid_files, &mut self.config);
|
||||||
|
} else {
|
||||||
|
ui.label("Not available");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Page::Monitoring => {
|
Page::Monitoring => {
|
||||||
self.cooling_performance.draw(ui, &self.pid_files);
|
if let SocketState::Connected(pid_files) = &mut self.pid_files {
|
||||||
|
self.cooling_performance.draw(ui, pid_files);
|
||||||
|
} else {
|
||||||
|
ui.label("Not available");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Page::Settings => {}
|
Page::Settings => {}
|
||||||
Page::Outputs => {
|
Page::Outputs => {
|
||||||
self.outputs_settings
|
if let SocketState::Connected(outputs) = &self.outputs {
|
||||||
.draw(ui, &mut self.config, &self.outputs);
|
self.outputs_settings.draw(ui, &mut self.config, outputs);
|
||||||
|
} else {
|
||||||
|
ui.label("Not available");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn tick(&mut self) {
|
pub fn tick(&mut self) {
|
||||||
self.cooling_performance.tick();
|
self.cooling_performance.tick();
|
||||||
if self.pid_files.0.is_empty() || self.reload_pid_list_delay.checked_sub(1).is_none() {
|
let can_decrease = self.reload_pid_list_delay > 0;
|
||||||
|
|
||||||
|
if can_decrease {
|
||||||
|
self.reload_pid_list_delay -= 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
self.reload_pid_list_delay = RELOAD_PID_LIST_DELAY;
|
self.reload_pid_list_delay = RELOAD_PID_LIST_DELAY;
|
||||||
|
|
||||||
{
|
{
|
||||||
use amdgpu::pidfile::helper_cmd::{send_command, Command, Response};
|
use amdgpu::pidfile::helper_cmd::{send_command, Command, Response};
|
||||||
|
|
||||||
match send_command(Command::FanServices) {
|
match send_command(Command::FanServices) {
|
||||||
Ok(Response::Services(services)) if self.pid_files.list_changed(&services) => {
|
Ok(Response::Services(services))
|
||||||
self.pid_files = FanServices::from(services);
|
if self
|
||||||
|
.pid_files
|
||||||
|
.connected()
|
||||||
|
.map(|c| c.list_changed(&services))
|
||||||
|
.unwrap_or(true) =>
|
||||||
|
{
|
||||||
|
self.pid_files = SocketState::Connected(FanServices::from(services));
|
||||||
}
|
}
|
||||||
Ok(Response::Services(_services)) => {
|
Ok(Response::Services(_services)) => {
|
||||||
// SKIP
|
// SKIP
|
||||||
}
|
}
|
||||||
Ok(res) => {
|
Ok(res) => {
|
||||||
log::warn!("Unexpected response {:?} while loading fan services", res);
|
tracing::warn!("Unexpected response {:?} while loading fan services", res);
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
log::warn!("Failed to load amd fan services pid list. {:?}", e);
|
self.pid_files = SocketState::NotAvailable;
|
||||||
|
tracing::warn!("Failed to load amd fan services pid list. {:?}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -233,7 +265,9 @@ impl AmdGui {
|
|||||||
tree.insert(name, Vec::with_capacity(6));
|
tree.insert(name, Vec::with_capacity(6));
|
||||||
});
|
});
|
||||||
|
|
||||||
self.outputs = outputs.into_iter().fold(tree, |mut agg, output| {
|
self.outputs = SocketState::Connected(outputs.into_iter().fold(
|
||||||
|
tree,
|
||||||
|
|mut agg, output| {
|
||||||
let v = agg
|
let v = agg
|
||||||
.entry(output.card.clone())
|
.entry(output.card.clone())
|
||||||
.or_insert_with(|| Vec::with_capacity(6));
|
.or_insert_with(|| Vec::with_capacity(6));
|
||||||
@ -253,15 +287,31 @@ impl AmdGui {
|
|||||||
))
|
))
|
||||||
});
|
});
|
||||||
agg
|
agg
|
||||||
});
|
},
|
||||||
|
));
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
log::warn!("Failed to load amd fan services pid list. {:?}", e);
|
if matches!(self.page, Page::Outputs) {
|
||||||
|
self.page = Page::Config;
|
||||||
|
}
|
||||||
|
self.outputs = SocketState::NotAvailable;
|
||||||
|
tracing::warn!("Failed to load amd fan services pid list. {:?}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
self.reload_pid_list_delay -= 1;
|
}
|
||||||
}
|
|
||||||
|
pub enum SocketState<Content> {
|
||||||
|
NotAvailable,
|
||||||
|
Connected(Content),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<C> SocketState<C> {
|
||||||
|
pub fn connected(&self) -> Option<&C> {
|
||||||
|
match self {
|
||||||
|
Self::Connected(c) => Some(c),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ pub fn run_app(amd_gui: Arc<Mutex<AmdGui>>, mut receiver: UnboundedReceiver<bool
|
|||||||
loop {
|
loop {
|
||||||
if receiver.recv().await.is_some() {
|
if receiver.recv().await.is_some() {
|
||||||
if let Err(e) = proxy.send_event(()) {
|
if let Err(e) = proxy.send_event(()) {
|
||||||
log::error!("{:?}", e);
|
tracing::error!("{:?}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ pub fn run_app(amd_gui: Arc<Mutex<AmdGui>>, mut receiver: UnboundedReceiver<bool
|
|||||||
loop {
|
loop {
|
||||||
if receiver.recv().await.is_some() {
|
if receiver.recv().await.is_some() {
|
||||||
if let Err(e) = proxy.send_event(()) {
|
if let Err(e) = proxy.send_event(()) {
|
||||||
log::error!("{:?}", e);
|
tracing::error!("{:?}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,14 +23,7 @@ use crate::AmdGui;
|
|||||||
pub fn create_ui(amd_gui: Arc<Mutex<AmdGui>>, ctx: &egui::Context) {
|
pub fn create_ui(amd_gui: Arc<Mutex<AmdGui>>, ctx: &egui::Context) {
|
||||||
egui::containers::TopBottomPanel::new(TopBottomSide::Top, "menu").show(ctx, |ui| {
|
egui::containers::TopBottomPanel::new(TopBottomSide::Top, "menu").show(ctx, |ui| {
|
||||||
let mut child = ui.child_ui(ui.available_rect_before_wrap(), Layout::left_to_right());
|
let mut child = ui.child_ui(ui.available_rect_before_wrap(), Layout::left_to_right());
|
||||||
if child
|
|
||||||
.add(
|
|
||||||
egui::Button::new("Outputs"), /* .text_style(TextStyle::Heading) */
|
|
||||||
)
|
|
||||||
.clicked_by(PointerButton::Primary)
|
|
||||||
{
|
|
||||||
amd_gui.lock().page = Page::Outputs;
|
|
||||||
}
|
|
||||||
if child
|
if child
|
||||||
.add(
|
.add(
|
||||||
egui::Button::new("Config"), /* .text_style(TextStyle::Heading) */
|
egui::Button::new("Config"), /* .text_style(TextStyle::Heading) */
|
||||||
@ -47,6 +40,14 @@ pub fn create_ui(amd_gui: Arc<Mutex<AmdGui>>, ctx: &egui::Context) {
|
|||||||
{
|
{
|
||||||
amd_gui.lock().page = Page::Monitoring;
|
amd_gui.lock().page = Page::Monitoring;
|
||||||
}
|
}
|
||||||
|
if child
|
||||||
|
.add(
|
||||||
|
egui::Button::new("Outputs"), /* .text_style(TextStyle::Heading) */
|
||||||
|
)
|
||||||
|
.clicked_by(PointerButton::Primary)
|
||||||
|
{
|
||||||
|
amd_gui.lock().page = Page::Outputs;
|
||||||
|
}
|
||||||
if child
|
if child
|
||||||
.add(
|
.add(
|
||||||
egui::Button::new("Settings"), /* .text_style(TextStyle::Heading) */
|
egui::Button::new("Settings"), /* .text_style(TextStyle::Heading) */
|
||||||
|
@ -24,7 +24,7 @@ use vulkano::{swapchain, sync};
|
|||||||
use vulkano_win::VkSurfaceBuild;
|
use vulkano_win::VkSurfaceBuild;
|
||||||
use winit::event::{Event, WindowEvent};
|
use winit::event::{Event, WindowEvent};
|
||||||
use winit::event_loop::{ControlFlow, EventLoop};
|
use winit::event_loop::{ControlFlow, EventLoop};
|
||||||
use winit::window::{Fullscreen, Window, WindowBuilder};
|
use winit::window::{Window, WindowBuilder};
|
||||||
|
|
||||||
use crate::app::AmdGui;
|
use crate::app::AmdGui;
|
||||||
use crate::backend::create_ui;
|
use crate::backend::create_ui;
|
||||||
@ -66,14 +66,19 @@ impl<F: GpuFuture> AsMut<dyn GpuFuture> for FrameEndFuture<F> {
|
|||||||
pub fn run_app(amd_gui: Arc<Mutex<AmdGui>>, _receiver: UnboundedReceiver<bool>) {
|
pub fn run_app(amd_gui: Arc<Mutex<AmdGui>>, _receiver: UnboundedReceiver<bool>) {
|
||||||
let required_extensions = vulkano_win::required_extensions();
|
let required_extensions = vulkano_win::required_extensions();
|
||||||
let instance = Instance::new(InstanceCreateInfo {
|
let instance = Instance::new(InstanceCreateInfo {
|
||||||
|
application_name: Some("amdguid".into()),
|
||||||
enabled_extensions: required_extensions,
|
enabled_extensions: required_extensions,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
})
|
})
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let physical = PhysicalDevice::enumerate(&instance).next().unwrap();
|
let physical = {
|
||||||
|
let mut v = PhysicalDevice::enumerate(&instance).collect::<Vec<_>>();
|
||||||
|
v.sort_by(|a, b| a.api_version().cmp(&b.api_version()));
|
||||||
|
v.remove(0)
|
||||||
|
};
|
||||||
|
|
||||||
println!(
|
tracing::info!(
|
||||||
"Using device: {} (type: {:?})",
|
"Using device: {} (type: {:?})",
|
||||||
physical.properties().device_name,
|
physical.properties().device_name,
|
||||||
physical.properties().device_type,
|
physical.properties().device_type,
|
||||||
@ -82,7 +87,7 @@ pub fn run_app(amd_gui: Arc<Mutex<AmdGui>>, _receiver: UnboundedReceiver<bool>)
|
|||||||
let event_loop = EventLoop::new();
|
let event_loop = EventLoop::new();
|
||||||
let surface = WindowBuilder::new()
|
let surface = WindowBuilder::new()
|
||||||
.with_title("AMD GUID")
|
.with_title("AMD GUID")
|
||||||
.with_fullscreen(Some(Fullscreen::Borderless(None)))
|
// .with_fullscreen(Some(Fullscreen::Borderless(None)))
|
||||||
.build_vk_surface(&event_loop, instance.clone())
|
.build_vk_surface(&event_loop, instance.clone())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ async fn main() {
|
|||||||
if std::env::var("RUST_LOG").is_err() {
|
if std::env::var("RUST_LOG").is_err() {
|
||||||
std::env::set_var("RUST_LOG", "DEBUG");
|
std::env::set_var("RUST_LOG", "DEBUG");
|
||||||
}
|
}
|
||||||
pretty_env_logger::init();
|
tracing_subscriber::fmt::init();
|
||||||
let config = Arc::new(Mutex::new(
|
let config = Arc::new(Mutex::new(
|
||||||
amdgpu_config::fan::load_config(amdgpu_config::fan::DEFAULT_FAN_CONFIG_PATH)
|
amdgpu_config::fan::load_config(amdgpu_config::fan::DEFAULT_FAN_CONFIG_PATH)
|
||||||
.expect("No FAN config"),
|
.expect("No FAN config"),
|
||||||
@ -35,7 +35,7 @@ fn schedule_tick(amd_gui: std::sync::Arc<parking_lot::Mutex<AmdGui>>) -> Unbound
|
|||||||
loop {
|
loop {
|
||||||
amd_gui.lock().tick();
|
amd_gui.lock().tick();
|
||||||
if let Err(e) = sender.send(true) {
|
if let Err(e) = sender.send(true) {
|
||||||
log::error!("Failed to propagate tick update. {:?}", e);
|
tracing::error!("Failed to propagate tick update. {:?}", e);
|
||||||
}
|
}
|
||||||
tokio::time::sleep(tokio::time::Duration::from_millis(166)).await;
|
tokio::time::sleep(tokio::time::Duration::from_millis(166)).await;
|
||||||
}
|
}
|
||||||
|
@ -158,7 +158,7 @@ impl ChangeFanSettings {
|
|||||||
let c: &amdgpu_config::fan::Config = &*config;
|
let c: &amdgpu_config::fan::Config = &*config;
|
||||||
let content = match toml::to_string(c) {
|
let content = match toml::to_string(c) {
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
log::error!("Config file serialization failed. {:?}", e);
|
tracing::error!("Config file serialization failed. {:?}", e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Ok(content) => content,
|
Ok(content) => content,
|
||||||
|
@ -23,35 +23,10 @@ impl OutputsSettings {
|
|||||||
ui.horizontal_top(|ui| {
|
ui.horizontal_top(|ui| {
|
||||||
outputs.iter().for_each(|(name, outputs)| {
|
outputs.iter().for_each(|(name, outputs)| {
|
||||||
ui.vertical(|ui| {
|
ui.vertical(|ui| {
|
||||||
ui.label(format!("name {name}"));
|
ui.label(format!("Card {name}"));
|
||||||
ui.horizontal_top(|ui| {
|
ui.horizontal_top(|ui| {
|
||||||
outputs.iter().for_each(|output| {
|
outputs.iter().for_each(|output| {
|
||||||
ui.vertical(|ui| {
|
Self::render_single(ui, state, output);
|
||||||
ui.add(OutputWidget::new(output, state));
|
|
||||||
|
|
||||||
ui.label(format!("port_number {}", output.port_number));
|
|
||||||
ui.label(format!("port_type {:?}", output.port_type));
|
|
||||||
ui.label(format!("card {}", output.card));
|
|
||||||
ui.label(format!(
|
|
||||||
"port_name {}",
|
|
||||||
output.port_name.as_deref().unwrap_or_default()
|
|
||||||
));
|
|
||||||
|
|
||||||
let state = WidgetText::RichText(
|
|
||||||
RichText::new(match output.status {
|
|
||||||
Status::Connected => "Connected",
|
|
||||||
Status::Disconnected => "Disconnected",
|
|
||||||
})
|
|
||||||
.color(
|
|
||||||
match output.status {
|
|
||||||
Status::Connected => Color32::DARK_GREEN,
|
|
||||||
Status::Disconnected => Color32::GRAY,
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
ui.label(state);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -59,4 +34,49 @@ impl OutputsSettings {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn render_single(ui: &mut Ui, state: &mut StatefulConfig, output: &Output) {
|
||||||
|
ui.vertical(|ui| {
|
||||||
|
ui.add(OutputWidget::new(output, state));
|
||||||
|
|
||||||
|
ui.label(format!("Port type {:?}", output.port_type));
|
||||||
|
ui.label(format!("Port number {}", output.port_number));
|
||||||
|
if let Some(name) = output.port_name.as_deref() {
|
||||||
|
ui.label(format!("Port name {}", name));
|
||||||
|
}
|
||||||
|
|
||||||
|
ui.label(WidgetText::RichText(
|
||||||
|
RichText::new(match output.status {
|
||||||
|
Status::Connected => "Connected",
|
||||||
|
Status::Disconnected => "Disconnected",
|
||||||
|
})
|
||||||
|
.color(match output.status {
|
||||||
|
Status::Connected => Color32::GREEN,
|
||||||
|
Status::Disconnected => Color32::GRAY,
|
||||||
|
})
|
||||||
|
.code()
|
||||||
|
.strong()
|
||||||
|
.monospace(),
|
||||||
|
));
|
||||||
|
ui.label("Display Power Management");
|
||||||
|
if ui
|
||||||
|
.button(WidgetText::RichText(
|
||||||
|
RichText::new(match output.display_power_managment {
|
||||||
|
true => "On",
|
||||||
|
false => "Off",
|
||||||
|
})
|
||||||
|
.color(match output.display_power_managment {
|
||||||
|
true => Color32::GREEN,
|
||||||
|
false => Color32::GRAY,
|
||||||
|
})
|
||||||
|
.monospace()
|
||||||
|
.code()
|
||||||
|
.strong(),
|
||||||
|
))
|
||||||
|
.clicked()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,11 +23,11 @@ impl<'l> egui::Widget for ReloadSection<'l> {
|
|||||||
}) {
|
}) {
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
service.reload = ChangeState::Success;
|
service.reload = ChangeState::Success;
|
||||||
log::info!("{:?}", response)
|
tracing::info!("{:?}", response)
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
service.reload = ChangeState::Failure(format!("{:?}", e));
|
service.reload = ChangeState::Failure(format!("{:?}", e));
|
||||||
log::error!("Failed to reload config. {:?}", e)
|
tracing::error!("Failed to reload config. {:?}", e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,5 +11,5 @@ futures = { version = "0.3", features = [] }
|
|||||||
ron = { version = "0.7.1" }
|
ron = { version = "0.7.1" }
|
||||||
serde = { version = "1.0.137", features = ["derive"] }
|
serde = { version = "1.0.137", features = ["derive"] }
|
||||||
|
|
||||||
log = { version = "0.4" }
|
tracing = { version = "0.1.36" }
|
||||||
pretty_env_logger = { version = "0.4" }
|
tracing-subscriber = { version = "0.3.15" }
|
||||||
|
@ -12,6 +12,7 @@ fn parse_output(entry: DirEntry) -> Option<Output> {
|
|||||||
if ty.is_dir() {
|
if ty.is_dir() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
tracing::error!("{:?}", entry.path());
|
||||||
let file_name = entry.file_name();
|
let file_name = entry.file_name();
|
||||||
let path = file_name.to_str()?;
|
let path = file_name.to_str()?;
|
||||||
let mut it = path
|
let mut it = path
|
||||||
@ -33,11 +34,20 @@ fn parse_output(entry: DirEntry) -> Option<Output> {
|
|||||||
|
|
||||||
let card = it.next()?.strip_prefix("card")?.to_string();
|
let card = it.next()?.strip_prefix("card")?.to_string();
|
||||||
let port_type = it.next()?;
|
let port_type = it.next()?;
|
||||||
|
let dpms = std::fs::read_to_string(entry.path().join("dpms"))
|
||||||
|
.unwrap_or_else(|e| {
|
||||||
|
tracing::error!("{}", e);
|
||||||
|
"Off".into()
|
||||||
|
})
|
||||||
|
.to_lowercase();
|
||||||
|
tracing::info!("Display Power Management System is {:?}", dpms);
|
||||||
|
|
||||||
let mut output = Output {
|
let mut output = Output {
|
||||||
card,
|
card,
|
||||||
ty: OutputType::parse_str(&port_type),
|
ty: OutputType::parse_str(&port_type),
|
||||||
port_type,
|
port_type,
|
||||||
modes,
|
modes,
|
||||||
|
display_power_managment: dpms.trim() == "on",
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
let mut it = it.rev();
|
let mut it = it.rev();
|
||||||
@ -90,7 +100,7 @@ async fn service(state: Arc<Mutex<Vec<Output>>>) {
|
|||||||
.expect("Creating pid file for ports failed")
|
.expect("Creating pid file for ports failed")
|
||||||
};
|
};
|
||||||
if let Err(e) = std::fs::set_permissions(&sock_path, Permissions::from_mode(0o777)) {
|
if let Err(e) = std::fs::set_permissions(&sock_path, Permissions::from_mode(0o777)) {
|
||||||
log::error!("Failed to change gui helper socket file mode. {:?}", e);
|
tracing::error!("Failed to change gui helper socket file mode. {:?}", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
while let Ok((stream, _addr)) = listener.accept() {
|
while let Ok((stream, _addr)) = listener.accept() {
|
||||||
@ -106,11 +116,11 @@ fn handle_connection(stream: UnixStream, state: Arc<Mutex<Vec<Output>>>) {
|
|||||||
_ => return service.kill(),
|
_ => return service.kill(),
|
||||||
};
|
};
|
||||||
|
|
||||||
log::info!("Incoming {:?}", command);
|
tracing::info!("Incoming {:?}", command);
|
||||||
let cmd = match ron::from_str::<Command>(command.trim()) {
|
let cmd = match ron::from_str::<Command>(command.trim()) {
|
||||||
Ok(cmd) => cmd,
|
Ok(cmd) => cmd,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
log::warn!("Invalid message {:?}. {:?}", command, e);
|
tracing::warn!("Invalid message {:?}. {:?}", command, e);
|
||||||
return service.kill();
|
return service.kill();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -128,6 +138,8 @@ fn handle_command(mut service: Service, cmd: Command, state: Arc<Mutex<Vec<Outpu
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
tracing_subscriber::fmt::init();
|
||||||
|
|
||||||
let executor = tokio::runtime::Builder::new_current_thread()
|
let executor = tokio::runtime::Builder::new_current_thread()
|
||||||
.enable_all()
|
.enable_all()
|
||||||
.build()
|
.build()
|
||||||
|
Loading…
Reference in New Issue
Block a user