Working on CLI
This commit is contained in:
parent
9242681bb2
commit
327bfcab0c
79
Cargo.lock
generated
79
Cargo.lock
generated
@ -59,6 +59,22 @@ dependencies = [
|
|||||||
"memchr",
|
"memchr",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "amd-edit"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"amdgpu",
|
||||||
|
"amdgpu-config",
|
||||||
|
"amdmond-lib",
|
||||||
|
"crossterm 0.25.0",
|
||||||
|
"gumdrop",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
"tracing",
|
||||||
|
"tracing-subscriber",
|
||||||
|
"tui 0.19.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "amdfan"
|
name = "amdfan"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
@ -66,7 +82,7 @@ dependencies = [
|
|||||||
"amdgpu",
|
"amdgpu",
|
||||||
"amdgpu-config",
|
"amdgpu-config",
|
||||||
"crossbeam",
|
"crossbeam",
|
||||||
"crossterm",
|
"crossterm 0.23.2",
|
||||||
"gumdrop",
|
"gumdrop",
|
||||||
"log",
|
"log",
|
||||||
"pretty_env_logger",
|
"pretty_env_logger",
|
||||||
@ -74,7 +90,7 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"toml",
|
"toml",
|
||||||
"tui",
|
"tui 0.18.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -779,6 +795,22 @@ dependencies = [
|
|||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "crossterm"
|
||||||
|
version = "0.25.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e64e6c0fbe2c17357405f7c758c1ef960fce08bdfb2c03d88d2a18d7e09c4b67"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags",
|
||||||
|
"crossterm_winapi",
|
||||||
|
"libc",
|
||||||
|
"mio",
|
||||||
|
"parking_lot 0.12.1",
|
||||||
|
"signal-hook",
|
||||||
|
"signal-hook-mio",
|
||||||
|
"winapi",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crossterm_winapi"
|
name = "crossterm_winapi"
|
||||||
version = "0.9.0"
|
version = "0.9.0"
|
||||||
@ -1713,6 +1745,15 @@ dependencies = [
|
|||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "matchers"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558"
|
||||||
|
dependencies = [
|
||||||
|
"regex-automata",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "matches"
|
name = "matches"
|
||||||
version = "0.1.9"
|
version = "0.1.9"
|
||||||
@ -2359,6 +2400,9 @@ name = "regex-automata"
|
|||||||
version = "0.1.10"
|
version = "0.1.10"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"
|
checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"
|
||||||
|
dependencies = [
|
||||||
|
"regex-syntax",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "regex-syntax"
|
name = "regex-syntax"
|
||||||
@ -2448,18 +2492,18 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.143"
|
version = "1.0.144"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "53e8e5d5b70924f74ff5c6d64d9a5acd91422117c60f48c4e07855238a254553"
|
checksum = "0f747710de3dcd43b88c9168773254e809d8ddbdf9653b84e2554ab219f17860"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_derive"
|
name = "serde_derive"
|
||||||
version = "1.0.143"
|
version = "1.0.144"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d3d8e8de557aee63c26b85b947f5e59b690d0454c753f3adeb5cd7835ab88391"
|
checksum = "94ed3a816fb1d101812f83e789f888322c34e291f894f19590dc310963e87a00"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@ -2468,9 +2512,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_json"
|
name = "serde_json"
|
||||||
version = "1.0.83"
|
version = "1.0.85"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "38dd04e3c8279e75b31ef29dbdceebfe5ad89f4d0937213c53f7d49d01b3d5a7"
|
checksum = "e55a28e3aaef9d5ce0506d0a14dbba8054ddc7e499ef522dd8b26859ec9d4a44"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"itoa 1.0.3",
|
"itoa 1.0.3",
|
||||||
"ryu",
|
"ryu",
|
||||||
@ -2888,9 +2932,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "60db860322da191b40952ad9affe65ea23e7dd6a5c442c2c42865810c6ab8e6b"
|
checksum = "60db860322da191b40952ad9affe65ea23e7dd6a5c442c2c42865810c6ab8e6b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ansi_term",
|
"ansi_term",
|
||||||
|
"matchers",
|
||||||
|
"once_cell",
|
||||||
|
"regex",
|
||||||
"sharded-slab",
|
"sharded-slab",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
"thread_local",
|
"thread_local",
|
||||||
|
"tracing",
|
||||||
"tracing-core",
|
"tracing-core",
|
||||||
"tracing-log",
|
"tracing-log",
|
||||||
]
|
]
|
||||||
@ -2909,7 +2957,20 @@ checksum = "96fe69244ec2af261bced1d9046a6fee6c8c2a6b0228e59e5ba39bc8ba4ed729"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"cassowary",
|
"cassowary",
|
||||||
"crossterm",
|
"crossterm 0.23.2",
|
||||||
|
"unicode-segmentation",
|
||||||
|
"unicode-width",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tui"
|
||||||
|
version = "0.19.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ccdd26cbd674007e649a272da4475fb666d3aa0ad0531da7136db6fab0e5bad1"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags",
|
||||||
|
"cassowary",
|
||||||
|
"crossterm 0.25.0",
|
||||||
"unicode-segmentation",
|
"unicode-segmentation",
|
||||||
"unicode-width",
|
"unicode-width",
|
||||||
]
|
]
|
||||||
|
@ -10,4 +10,5 @@ members = [
|
|||||||
"amdguid",
|
"amdguid",
|
||||||
"amdgui-helper",
|
"amdgui-helper",
|
||||||
"amdportsd",
|
"amdportsd",
|
||||||
|
"amd-edit",
|
||||||
]
|
]
|
||||||
|
17
README.md
17
README.md
@ -55,7 +55,7 @@ Or you can compile it from source
|
|||||||
#### Compile
|
#### Compile
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
./scripts/build.sh
|
./scripts/build.sh local
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Download missing shared libraries
|
#### Download missing shared libraries
|
||||||
@ -111,3 +111,18 @@ Where:
|
|||||||
cd /opt/amdguid
|
cd /opt/amdguid
|
||||||
./amdguid
|
./amdguid
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Architecture
|
||||||
|
|
||||||
|
![Architecture SVG](./assets/architecture.svg)
|
||||||
|
|
||||||
|
#### SystemD files
|
||||||
|
|
||||||
|
Depends
|
||||||
|
|
||||||
|
```
|
||||||
|
# cp ./services/amdmond.service /usr/lib/systemd/system/amdmond.service
|
||||||
|
# cp ./services/amdvold.service /usr/lib/systemd/system/amdvold.service
|
||||||
|
# cp ./services/amdgui-helper.service /usr/lib/systemd/system/amdgui-helper.service
|
||||||
|
# cp ./services/amdfand.service /usr/lib/systemd/system/amdfand.service
|
||||||
|
```
|
16
amd-edit/Cargo.toml
Normal file
16
amd-edit/Cargo.toml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
[package]
|
||||||
|
name = "amd-edit"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
amdmond-lib = { version = "1.0", path = "../amdmond-lib" }
|
||||||
|
amdgpu = { version = "1.0", path = "../amdgpu" }
|
||||||
|
amdgpu-config = { version = "1.0", path = "../amdgpu-config", features = ["fan"] }
|
||||||
|
crossterm = { version = "0.25.0" }
|
||||||
|
tui = { version = "0.19.0", features = ["crossterm"] }
|
||||||
|
serde = { version = "1.0.144" }
|
||||||
|
serde_json = { version = "1.0.85" }
|
||||||
|
gumdrop = { version = "0.8.1" }
|
||||||
|
tracing = { version = "0.1.36" }
|
||||||
|
tracing-subscriber = { version = "0.3.15", features = ['env-filter'] }
|
214
amd-edit/src/fan_speed.rs
Normal file
214
amd-edit/src/fan_speed.rs
Normal file
@ -0,0 +1,214 @@
|
|||||||
|
use amdgpu_config::fan::MatrixPoint;
|
||||||
|
use tui::buffer::Buffer;
|
||||||
|
use tui::layout::{Alignment, Constraint, Direction, Layout, Rect};
|
||||||
|
use tui::style::{Color, Style};
|
||||||
|
use tui::symbols::Marker;
|
||||||
|
use tui::text::{Span, Text};
|
||||||
|
use tui::widgets::{Axis, Block, Chart, Dataset, List, ListItem, Paragraph, Widget};
|
||||||
|
|
||||||
|
use crate::Dir;
|
||||||
|
|
||||||
|
#[derive(Default, Debug)]
|
||||||
|
pub struct FanSpeedState {
|
||||||
|
highlighted_point: Option<usize>,
|
||||||
|
selected_point: Option<usize>,
|
||||||
|
len: usize,
|
||||||
|
buffer: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl FanSpeedState {
|
||||||
|
pub fn move_dir(&mut self, dir: Dir) {
|
||||||
|
if self.selected_point.is_some() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
match dir {
|
||||||
|
Dir::Left => match self.highlighted_point {
|
||||||
|
None => self.highlighted_point = Some(0),
|
||||||
|
Some(0) => self.highlighted_point = Some(0),
|
||||||
|
Some(idx) => self.highlighted_point = Some(idx - 1),
|
||||||
|
},
|
||||||
|
Dir::Right => match self.highlighted_point {
|
||||||
|
None => self.highlighted_point = Some(0),
|
||||||
|
Some(idx) if idx + 1 < self.len => self.highlighted_point = Some(idx + 1),
|
||||||
|
Some(_) => {}
|
||||||
|
},
|
||||||
|
Dir::Up => {}
|
||||||
|
Dir::Down => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn toggle_select(&mut self) {
|
||||||
|
match (self.selected_point, self.highlighted_point) {
|
||||||
|
(_, None) => self.selected_point = None,
|
||||||
|
(Some(selected), Some(highlighted)) => {
|
||||||
|
if selected != highlighted {
|
||||||
|
self.selected_point = Some(highlighted);
|
||||||
|
} else {
|
||||||
|
self.selected_point = None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
(_, Some(highlighted)) => {
|
||||||
|
self.selected_point = Some(highlighted);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn text_input(&mut self, c: char) {
|
||||||
|
self.buffer.push(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn erase_last(&mut self) {
|
||||||
|
let len = self.buffer.len();
|
||||||
|
if len > 0 {
|
||||||
|
self.buffer.remove(len - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Default, Debug)]
|
||||||
|
pub struct FanSpeed {
|
||||||
|
y_axis: Vec<f64>,
|
||||||
|
x_axis: Vec<f64>,
|
||||||
|
dataset: Vec<(f64, f64)>,
|
||||||
|
highlighted_point: Option<usize>,
|
||||||
|
selected_point: Option<usize>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl FanSpeed {
|
||||||
|
pub fn with_values(mut self, matrix: &[MatrixPoint]) -> Self {
|
||||||
|
self.update_values(matrix);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn update_values(&mut self, matrix: &[MatrixPoint]) {
|
||||||
|
self.x_axis = matrix.iter().map(|point| point.temp).collect::<Vec<_>>();
|
||||||
|
|
||||||
|
self.y_axis = matrix.iter().map(|point| point.speed).collect::<Vec<_>>();
|
||||||
|
|
||||||
|
self.dataset = self
|
||||||
|
.x_axis
|
||||||
|
.iter()
|
||||||
|
.copied()
|
||||||
|
.zip(self.y_axis.iter().copied())
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn with_state(mut self, state: &mut FanSpeedState) -> Self {
|
||||||
|
self.highlighted_point = state.highlighted_point;
|
||||||
|
self.selected_point = state.selected_point;
|
||||||
|
|
||||||
|
state.len = self.x_axis.len();
|
||||||
|
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Widget for FanSpeed {
|
||||||
|
fn render(self, area: Rect, buf: &mut Buffer) {
|
||||||
|
let vertical = Layout::default()
|
||||||
|
.constraints([Constraint::Length(21), Constraint::Length(1)])
|
||||||
|
.direction(Direction::Vertical)
|
||||||
|
.split(area);
|
||||||
|
|
||||||
|
let top_horizontal = Layout::default()
|
||||||
|
.constraints([Constraint::Length(21), Constraint::Min(10)])
|
||||||
|
.direction(Direction::Horizontal)
|
||||||
|
.split(vertical[0]);
|
||||||
|
|
||||||
|
let bottom_horizontal = Layout::default()
|
||||||
|
.constraints([Constraint::Min(10), Constraint::Min(4), Constraint::Min(10)])
|
||||||
|
.direction(Direction::Horizontal)
|
||||||
|
.split(vertical[1]);
|
||||||
|
|
||||||
|
tracing::debug!("=======================================================");
|
||||||
|
tracing::debug!("vertical {:?}", vertical);
|
||||||
|
tracing::debug!("horizontal {:?}", top_horizontal);
|
||||||
|
|
||||||
|
let mut dataset_list = Vec::with_capacity(3);
|
||||||
|
|
||||||
|
match self.highlighted_point {
|
||||||
|
Some(idx) => {
|
||||||
|
if idx != 0 {
|
||||||
|
dataset_list.push(
|
||||||
|
Dataset::default()
|
||||||
|
.data(&self.dataset[0..idx])
|
||||||
|
.style(Style::default().fg(Color::White)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
dataset_list.push(
|
||||||
|
Dataset::default()
|
||||||
|
.data(&self.dataset[idx..=idx])
|
||||||
|
.style(Style::default().fg(Color::Red))
|
||||||
|
.marker(Marker::Dot),
|
||||||
|
);
|
||||||
|
|
||||||
|
if idx + 1 < self.x_axis.len() {
|
||||||
|
dataset_list.push(
|
||||||
|
Dataset::default()
|
||||||
|
.data(&self.dataset[(idx + 1)..])
|
||||||
|
.style(Style::default().fg(Color::White)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
dataset_list.push(
|
||||||
|
Dataset::default()
|
||||||
|
.data(self.dataset.as_slice())
|
||||||
|
.style(Style::default().fg(Color::White)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Chart::new(dataset_list)
|
||||||
|
.block(Block::default())
|
||||||
|
.x_axis(axis("Temperature"))
|
||||||
|
.y_axis(axis("Speed"))
|
||||||
|
.render(top_horizontal[0], buf);
|
||||||
|
|
||||||
|
List::new(self.dataset.iter().enumerate().fold(
|
||||||
|
vec![ListItem::new("Temperature | Speed".to_string())],
|
||||||
|
|mut v, (idx, (temperature, speed))| {
|
||||||
|
if self.selected_point == Some(idx) {
|
||||||
|
let text = Text::styled(
|
||||||
|
format!("{:>11} | {:>5} *", temperature, speed),
|
||||||
|
Style::default().fg(Color::Yellow),
|
||||||
|
);
|
||||||
|
v.push(ListItem::new(text));
|
||||||
|
} else if self.highlighted_point == Some(idx) {
|
||||||
|
v.push(
|
||||||
|
ListItem::new(format!("{:>11} | {:>5} <", temperature, speed))
|
||||||
|
.style(Style::default().fg(Color::Yellow)),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
v.push(ListItem::new(format!("{:>11} | {:>5}", temperature, speed)));
|
||||||
|
}
|
||||||
|
v
|
||||||
|
},
|
||||||
|
))
|
||||||
|
.render(top_horizontal[1], buf);
|
||||||
|
|
||||||
|
Paragraph::new("Selected:").render(bottom_horizontal[0], buf);
|
||||||
|
|
||||||
|
if let Some((x, _y)) = self.selected_point.and_then(|idx| self.dataset.get(idx)) {
|
||||||
|
Paragraph::new(format!("{:<3}", x))
|
||||||
|
} else {
|
||||||
|
Paragraph::new("none")
|
||||||
|
}
|
||||||
|
.render(bottom_horizontal[1], buf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn axis(label: &str) -> Axis {
|
||||||
|
Axis::default()
|
||||||
|
.labels_alignment(Alignment::Center)
|
||||||
|
.title(label)
|
||||||
|
.bounds([0f64, 101f64])
|
||||||
|
.labels(
|
||||||
|
(0..=100)
|
||||||
|
.into_iter()
|
||||||
|
.step_by(10)
|
||||||
|
.map(|f| Span::raw(format!("{:^3}", f)))
|
||||||
|
.collect::<Vec<_>>(),
|
||||||
|
)
|
||||||
|
}
|
150
amd-edit/src/main.rs
Normal file
150
amd-edit/src/main.rs
Normal file
@ -0,0 +1,150 @@
|
|||||||
|
mod fan_speed;
|
||||||
|
|
||||||
|
use std::io;
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use crossterm::event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode};
|
||||||
|
use crossterm::execute;
|
||||||
|
use crossterm::terminal::{
|
||||||
|
disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen,
|
||||||
|
};
|
||||||
|
use tracing_subscriber::layer::SubscriberExt;
|
||||||
|
use tracing_subscriber::util::SubscriberInitExt;
|
||||||
|
use tui::backend::CrosstermBackend;
|
||||||
|
use tui::layout::*;
|
||||||
|
use tui::widgets::*;
|
||||||
|
use tui::Terminal;
|
||||||
|
|
||||||
|
use crate::fan_speed::{FanSpeed, FanSpeedState};
|
||||||
|
|
||||||
|
#[derive(gumdrop::Options)]
|
||||||
|
struct Opts {
|
||||||
|
help: bool,
|
||||||
|
#[options(help = "Fan speed config file")]
|
||||||
|
fan_config: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
enum Page {
|
||||||
|
FanSpeed(FanSpeedState),
|
||||||
|
}
|
||||||
|
|
||||||
|
pub enum Dir {
|
||||||
|
Left,
|
||||||
|
Right,
|
||||||
|
Up,
|
||||||
|
Down,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Page {
|
||||||
|
pub fn index(&self) -> usize {
|
||||||
|
match self {
|
||||||
|
Page::FanSpeed(_) => 0,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() -> Result<(), io::Error> {
|
||||||
|
let config: Opts = gumdrop::parse_args_default_or_exit();
|
||||||
|
|
||||||
|
tracing_subscriber::registry()
|
||||||
|
.with(
|
||||||
|
tracing_subscriber::fmt::layer().with_writer(Arc::new(
|
||||||
|
std::fs::OpenOptions::new()
|
||||||
|
.write(true)
|
||||||
|
.create(true)
|
||||||
|
.append(true)
|
||||||
|
.open("/tmp/amd-edit.log")
|
||||||
|
.expect("Failed to open log file"),
|
||||||
|
)),
|
||||||
|
)
|
||||||
|
.init();
|
||||||
|
|
||||||
|
enable_raw_mode()?;
|
||||||
|
let mut stdout = io::stdout();
|
||||||
|
execute!(stdout, EnterAlternateScreen, EnableMouseCapture)?;
|
||||||
|
let backend = CrosstermBackend::new(stdout);
|
||||||
|
let mut terminal = Terminal::new(backend)?;
|
||||||
|
|
||||||
|
let config = amdgpu_config::fan::load_config(
|
||||||
|
&config
|
||||||
|
.fan_config
|
||||||
|
.unwrap_or_else(|| amdgpu_config::fan::DEFAULT_FAN_CONFIG_PATH.into()),
|
||||||
|
)
|
||||||
|
.expect("AMD GUI Fan speed config does not exists");
|
||||||
|
|
||||||
|
let mut page = Page::FanSpeed(FanSpeedState::default());
|
||||||
|
|
||||||
|
loop {
|
||||||
|
terminal.draw(|f| {
|
||||||
|
let size = f.size();
|
||||||
|
let chunks = Layout::default()
|
||||||
|
.constraints([Constraint::Percentage(10), Constraint::Percentage(90)])
|
||||||
|
.split(size);
|
||||||
|
|
||||||
|
let block = Block::default()
|
||||||
|
.title("AMD GPU")
|
||||||
|
.borders(Borders::empty())
|
||||||
|
.title_alignment(Alignment::Center);
|
||||||
|
|
||||||
|
let tabs = Tabs::new(vec!["Fan Speed".into(), "Monitoring".into()])
|
||||||
|
.select(page.index())
|
||||||
|
.block(block);
|
||||||
|
|
||||||
|
f.render_widget(tabs, chunks[0]);
|
||||||
|
|
||||||
|
match &mut page {
|
||||||
|
Page::FanSpeed(ref mut state) => f.render_widget(
|
||||||
|
FanSpeed::default()
|
||||||
|
.with_values(config.speed_matrix())
|
||||||
|
.with_state(state),
|
||||||
|
chunks[1],
|
||||||
|
),
|
||||||
|
}
|
||||||
|
})?;
|
||||||
|
|
||||||
|
if let Ok(ev) = event::read() {
|
||||||
|
match ev {
|
||||||
|
Event::FocusGained => {}
|
||||||
|
Event::FocusLost => {}
|
||||||
|
Event::Key(key) => match key.code {
|
||||||
|
KeyCode::Char('q') | KeyCode::Esc => break,
|
||||||
|
KeyCode::Char(' ') => match &mut page {
|
||||||
|
Page::FanSpeed(state) => state.toggle_select(),
|
||||||
|
},
|
||||||
|
dir @ (KeyCode::Right | KeyCode::Left | KeyCode::Up | KeyCode::Down) => {
|
||||||
|
match (dir, &mut page) {
|
||||||
|
(KeyCode::Left | KeyCode::Down, Page::FanSpeed(ref mut state)) => {
|
||||||
|
state.move_dir(Dir::Left);
|
||||||
|
}
|
||||||
|
(KeyCode::Right | KeyCode::Up, Page::FanSpeed(ref mut state)) => {
|
||||||
|
state.move_dir(Dir::Right);
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
KeyCode::Char(c) => match &mut page {
|
||||||
|
Page::FanSpeed(state) => state.text_input(c),
|
||||||
|
},
|
||||||
|
KeyCode::Backspace => match &mut page {
|
||||||
|
Page::FanSpeed(state) => state.erase_last(),
|
||||||
|
},
|
||||||
|
_ => {}
|
||||||
|
},
|
||||||
|
Event::Mouse(_mouse) => {}
|
||||||
|
Event::Paste(_) => {}
|
||||||
|
Event::Resize(_, _) => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// restore terminal
|
||||||
|
disable_raw_mode()?;
|
||||||
|
execute!(
|
||||||
|
terminal.backend_mut(),
|
||||||
|
LeaveAlternateScreen,
|
||||||
|
DisableMouseCapture
|
||||||
|
)?;
|
||||||
|
terminal.show_cursor()?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
47
assets/architecture.dot
Normal file
47
assets/architecture.dot
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
digraph {
|
||||||
|
compound = true;
|
||||||
|
|
||||||
|
amdvold [ shape=square ];
|
||||||
|
"amdgui-helper" [ shape=square ];
|
||||||
|
|
||||||
|
subgraph SystemD {
|
||||||
|
label = "SystemD";
|
||||||
|
|
||||||
|
systemd [ shape=square ];
|
||||||
|
|
||||||
|
subgraph {
|
||||||
|
rank = same;
|
||||||
|
|
||||||
|
amdfand [ shape=square ];
|
||||||
|
amdmond [ shape=square ];
|
||||||
|
amdportsd [ shape=square ];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
subgraph binaries {
|
||||||
|
label = "amdguid";
|
||||||
|
|
||||||
|
amdguid -> "amdgui-helper";
|
||||||
|
"amdfand config file" -> { amdguid, amdfand };
|
||||||
|
"amdgui-helper" -> { "amdfand config file", amdfand };
|
||||||
|
amdmond -> amdguid;
|
||||||
|
amdportsd -> amdguid;
|
||||||
|
}
|
||||||
|
|
||||||
|
subgraph services {
|
||||||
|
"/usr/lib/systemd/system/amdmond.service" [ shape = box ];
|
||||||
|
"/usr/lib/systemd/system/amdvold.service" [ shape = box ];
|
||||||
|
"/usr/lib/systemd/system/amdgui-helper.service" [ shape = box ];
|
||||||
|
"/usr/lib/systemd/system/amdfand.service" [ shape = box ];
|
||||||
|
|
||||||
|
subgraph {
|
||||||
|
|
||||||
|
systemd -> { "/usr/lib/systemd/system/amdmond.service", "/usr/lib/systemd/system/amdvold.service", "/usr/lib/systemd/system/amdgui-helper.service", "/usr/lib/systemd/system/amdfand.service" };
|
||||||
|
|
||||||
|
"/usr/lib/systemd/system/amdmond.service" -> amdmond;
|
||||||
|
"/usr/lib/systemd/system/amdvold.service" -> amdvold;
|
||||||
|
"/usr/lib/systemd/system/amdgui-helper.service" -> "amdgui-helper";
|
||||||
|
"/usr/lib/systemd/system/amdfand.service" -> amdfand;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
174
assets/architecture.svg
Normal file
174
assets/architecture.svg
Normal file
@ -0,0 +1,174 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||||
|
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||||
|
<!-- Generated by graphviz version 5.0.1 (0)
|
||||||
|
-->
|
||||||
|
<!-- Pages: 1 -->
|
||||||
|
<svg width="821pt" height="529pt"
|
||||||
|
viewBox="0.00 0.00 820.50 529.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 525)">
|
||||||
|
<polygon fill="white" stroke="none" points="-4,4 -4,-525 816.5,-525 816.5,4 -4,4"/>
|
||||||
|
<!-- amdvold -->
|
||||||
|
<g id="node1" class="node">
|
||||||
|
<title>amdvold</title>
|
||||||
|
<polygon fill="none" stroke="black" points="371.5,-346 306.5,-346 306.5,-281 371.5,-281 371.5,-346"/>
|
||||||
|
<text text-anchor="middle" x="339" y="-309.8" font-family="Times,serif" font-size="14.00">amdvold</text>
|
||||||
|
</g>
|
||||||
|
<!-- amdgui-helper -->
|
||||||
|
<g id="node2" class="node">
|
||||||
|
<title>amdgui-helper</title>
|
||||||
|
<polygon fill="none" stroke="black" points="580,-168 484,-168 484,-72 580,-72 580,-168"/>
|
||||||
|
<text text-anchor="middle" x="532" y="-116.3" font-family="Times,serif" font-size="14.00">amdgui-helper</text>
|
||||||
|
</g>
|
||||||
|
<!-- amdfand -->
|
||||||
|
<g id="node4" class="node">
|
||||||
|
<title>amdfand</title>
|
||||||
|
<polygon fill="none" stroke="black" points="728.5,-346 663.5,-346 663.5,-281 728.5,-281 728.5,-346"/>
|
||||||
|
<text text-anchor="middle" x="696" y="-309.8" font-family="Times,serif" font-size="14.00">amdfand</text>
|
||||||
|
</g>
|
||||||
|
<!-- amdgui-helper->amdfand -->
|
||||||
|
<g id="edge4" class="edge">
|
||||||
|
<title>amdgui-helper->amdfand</title>
|
||||||
|
<path fill="none" stroke="black" d="M580.31,-136.35C612.78,-149.21 653.75,-170.88 677,-204 690.5,-223.23 695.42,-249 696.88,-270.6"/>
|
||||||
|
<polygon fill="black" stroke="black" points="693.4,-270.99 697.35,-280.82 700.39,-270.68 693.4,-270.99"/>
|
||||||
|
</g>
|
||||||
|
<!-- amdfand config file -->
|
||||||
|
<g id="node8" class="node">
|
||||||
|
<title>amdfand config file</title>
|
||||||
|
<ellipse fill="none" stroke="black" cx="532" cy="-18" rx="79.89" ry="18"/>
|
||||||
|
<text text-anchor="middle" x="532" y="-14.3" font-family="Times,serif" font-size="14.00">amdfand config file</text>
|
||||||
|
</g>
|
||||||
|
<!-- amdgui-helper->amdfand config file -->
|
||||||
|
<g id="edge5" class="edge">
|
||||||
|
<title>amdgui-helper->amdfand config file</title>
|
||||||
|
<path fill="none" stroke="black" d="M532,-71.93C532,-63.15 532,-54.25 532,-46.32"/>
|
||||||
|
<polygon fill="black" stroke="black" points="535.5,-46.21 532,-36.21 528.5,-46.21 535.5,-46.21"/>
|
||||||
|
</g>
|
||||||
|
<!-- systemd -->
|
||||||
|
<g id="node3" class="node">
|
||||||
|
<title>systemd</title>
|
||||||
|
<polygon fill="none" stroke="black" points="492,-521 430,-521 430,-459 492,-459 492,-521"/>
|
||||||
|
<text text-anchor="middle" x="461" y="-486.3" font-family="Times,serif" font-size="14.00">systemd</text>
|
||||||
|
</g>
|
||||||
|
<!-- /usr/lib/systemd/system/amdmond.service -->
|
||||||
|
<g id="node9" class="node">
|
||||||
|
<title>/usr/lib/systemd/system/amdmond.service</title>
|
||||||
|
<polygon fill="none" stroke="black" points="248,-423 0,-423 0,-387 248,-387 248,-423"/>
|
||||||
|
<text text-anchor="middle" x="124" y="-401.3" font-family="Times,serif" font-size="14.00">/usr/lib/systemd/system/amdmond.service</text>
|
||||||
|
</g>
|
||||||
|
<!-- systemd->/usr/lib/systemd/system/amdmond.service -->
|
||||||
|
<g id="edge8" class="edge">
|
||||||
|
<title>systemd->/usr/lib/systemd/system/amdmond.service</title>
|
||||||
|
<path fill="none" stroke="black" d="M429.9,-481.34C378.78,-468.75 275.44,-443.3 203.08,-425.48"/>
|
||||||
|
<polygon fill="black" stroke="black" points="203.63,-422.01 193.09,-423.02 201.96,-428.81 203.63,-422.01"/>
|
||||||
|
</g>
|
||||||
|
<!-- /usr/lib/systemd/system/amdvold.service -->
|
||||||
|
<g id="node10" class="node">
|
||||||
|
<title>/usr/lib/systemd/system/amdvold.service</title>
|
||||||
|
<polygon fill="none" stroke="black" points="507.5,-423 266.5,-423 266.5,-387 507.5,-387 507.5,-423"/>
|
||||||
|
<text text-anchor="middle" x="387" y="-401.3" font-family="Times,serif" font-size="14.00">/usr/lib/systemd/system/amdvold.service</text>
|
||||||
|
</g>
|
||||||
|
<!-- systemd->/usr/lib/systemd/system/amdvold.service -->
|
||||||
|
<g id="edge9" class="edge">
|
||||||
|
<title>systemd->/usr/lib/systemd/system/amdvold.service</title>
|
||||||
|
<path fill="none" stroke="black" d="M433.87,-458.57C425.78,-449.5 417.02,-439.67 409.28,-430.99"/>
|
||||||
|
<polygon fill="black" stroke="black" points="411.78,-428.53 402.51,-423.4 406.56,-433.19 411.78,-428.53"/>
|
||||||
|
</g>
|
||||||
|
<!-- /usr/lib/systemd/system/amdgui-helper.service -->
|
||||||
|
<g id="node11" class="node">
|
||||||
|
<title>/usr/lib/systemd/system/amdgui-helper.service</title>
|
||||||
|
<polygon fill="none" stroke="black" points="668,-240 396,-240 396,-204 668,-204 668,-240"/>
|
||||||
|
<text text-anchor="middle" x="532" y="-218.3" font-family="Times,serif" font-size="14.00">/usr/lib/systemd/system/amdgui-helper.service</text>
|
||||||
|
</g>
|
||||||
|
<!-- systemd->/usr/lib/systemd/system/amdgui-helper.service -->
|
||||||
|
<g id="edge10" class="edge">
|
||||||
|
<title>systemd->/usr/lib/systemd/system/amdgui-helper.service</title>
|
||||||
|
<path fill="none" stroke="black" d="M492.26,-459.42C501.51,-448.85 510.59,-436.26 516,-423 539.63,-365.07 537.98,-289.98 534.89,-250.32"/>
|
||||||
|
<polygon fill="black" stroke="black" points="538.35,-249.78 534,-240.12 531.38,-250.39 538.35,-249.78"/>
|
||||||
|
</g>
|
||||||
|
<!-- /usr/lib/systemd/system/amdfand.service -->
|
||||||
|
<g id="node12" class="node">
|
||||||
|
<title>/usr/lib/systemd/system/amdfand.service</title>
|
||||||
|
<polygon fill="none" stroke="black" points="812.5,-423 571.5,-423 571.5,-387 812.5,-387 812.5,-423"/>
|
||||||
|
<text text-anchor="middle" x="692" y="-401.3" font-family="Times,serif" font-size="14.00">/usr/lib/systemd/system/amdfand.service</text>
|
||||||
|
</g>
|
||||||
|
<!-- systemd->/usr/lib/systemd/system/amdfand.service -->
|
||||||
|
<g id="edge11" class="edge">
|
||||||
|
<title>systemd->/usr/lib/systemd/system/amdfand.service</title>
|
||||||
|
<path fill="none" stroke="black" d="M492.15,-477.81C528.64,-464.7 589.81,-442.72 634.89,-426.52"/>
|
||||||
|
<polygon fill="black" stroke="black" points="636.31,-429.73 644.53,-423.05 633.94,-423.14 636.31,-429.73"/>
|
||||||
|
</g>
|
||||||
|
<!-- amdmond -->
|
||||||
|
<g id="node5" class="node">
|
||||||
|
<title>amdmond</title>
|
||||||
|
<polygon fill="none" stroke="black" points="245,-349.5 173,-349.5 173,-277.5 245,-277.5 245,-349.5"/>
|
||||||
|
<text text-anchor="middle" x="209" y="-309.8" font-family="Times,serif" font-size="14.00">amdmond</text>
|
||||||
|
</g>
|
||||||
|
<!-- amdguid -->
|
||||||
|
<g id="node7" class="node">
|
||||||
|
<title>amdguid</title>
|
||||||
|
<ellipse fill="none" stroke="black" cx="336" cy="-222" rx="42.49" ry="18"/>
|
||||||
|
<text text-anchor="middle" x="336" y="-218.3" font-family="Times,serif" font-size="14.00">amdguid</text>
|
||||||
|
</g>
|
||||||
|
<!-- amdmond->amdguid -->
|
||||||
|
<g id="edge6" class="edge">
|
||||||
|
<title>amdmond->amdguid</title>
|
||||||
|
<path fill="none" stroke="black" d="M245.05,-287.09C264.46,-273.41 288.11,-256.75 306.43,-243.84"/>
|
||||||
|
<polygon fill="black" stroke="black" points="308.79,-246.46 314.95,-237.84 304.76,-240.74 308.79,-246.46"/>
|
||||||
|
</g>
|
||||||
|
<!-- amdportsd -->
|
||||||
|
<g id="node6" class="node">
|
||||||
|
<title>amdportsd</title>
|
||||||
|
<polygon fill="none" stroke="black" points="464.5,-351 389.5,-351 389.5,-276 464.5,-276 464.5,-351"/>
|
||||||
|
<text text-anchor="middle" x="427" y="-309.8" font-family="Times,serif" font-size="14.00">amdportsd</text>
|
||||||
|
</g>
|
||||||
|
<!-- amdportsd->amdguid -->
|
||||||
|
<g id="edge7" class="edge">
|
||||||
|
<title>amdportsd->amdguid</title>
|
||||||
|
<path fill="none" stroke="black" d="M389.72,-275.84C379.45,-265.73 368.59,-255.05 359.35,-245.96"/>
|
||||||
|
<polygon fill="black" stroke="black" points="361.6,-243.26 352.01,-238.75 356.69,-248.26 361.6,-243.26"/>
|
||||||
|
</g>
|
||||||
|
<!-- amdguid->amdgui-helper -->
|
||||||
|
<g id="edge1" class="edge">
|
||||||
|
<title>amdguid->amdgui-helper</title>
|
||||||
|
<path fill="none" stroke="black" d="M362.03,-207.72C390.54,-193.17 437.16,-169.39 474.38,-150.4"/>
|
||||||
|
<polygon fill="black" stroke="black" points="476.3,-153.35 483.62,-145.69 473.12,-147.11 476.3,-153.35"/>
|
||||||
|
</g>
|
||||||
|
<!-- amdfand config file->amdfand -->
|
||||||
|
<g id="edge2" class="edge">
|
||||||
|
<title>amdfand config file->amdfand</title>
|
||||||
|
<path fill="none" stroke="black" d="M555.42,-35.29C594.3,-64.01 670.63,-127.86 698,-204 705.58,-225.08 705.69,-249.99 703.63,-270.62"/>
|
||||||
|
<polygon fill="black" stroke="black" points="700.14,-270.32 702.42,-280.67 707.09,-271.16 700.14,-270.32"/>
|
||||||
|
</g>
|
||||||
|
<!-- amdfand config file->amdguid -->
|
||||||
|
<g id="edge3" class="edge">
|
||||||
|
<title>amdfand config file->amdguid</title>
|
||||||
|
<path fill="none" stroke="black" d="M513.46,-35.62C502.16,-45.91 487.53,-59.49 475,-72 431.98,-114.95 384.08,-167.38 357.24,-197.21"/>
|
||||||
|
<polygon fill="black" stroke="black" points="354.33,-195.21 350.25,-204.99 359.53,-199.89 354.33,-195.21"/>
|
||||||
|
</g>
|
||||||
|
<!-- /usr/lib/systemd/system/amdmond.service->amdmond -->
|
||||||
|
<g id="edge12" class="edge">
|
||||||
|
<title>/usr/lib/systemd/system/amdmond.service->amdmond</title>
|
||||||
|
<path fill="none" stroke="black" d="M140.39,-386.74C148.39,-378.32 158.4,-367.78 168.28,-357.38"/>
|
||||||
|
<polygon fill="black" stroke="black" points="171.07,-359.52 175.42,-349.86 166,-354.7 171.07,-359.52"/>
|
||||||
|
</g>
|
||||||
|
<!-- /usr/lib/systemd/system/amdvold.service->amdvold -->
|
||||||
|
<g id="edge13" class="edge">
|
||||||
|
<title>/usr/lib/systemd/system/amdvold.service->amdvold</title>
|
||||||
|
<path fill="none" stroke="black" d="M377.75,-386.74C372.89,-377.69 366.71,-366.17 360.73,-355.01"/>
|
||||||
|
<polygon fill="black" stroke="black" points="363.81,-353.35 356,-346.2 357.64,-356.66 363.81,-353.35"/>
|
||||||
|
</g>
|
||||||
|
<!-- /usr/lib/systemd/system/amdgui-helper.service->amdgui-helper -->
|
||||||
|
<g id="edge14" class="edge">
|
||||||
|
<title>/usr/lib/systemd/system/amdgui-helper.service->amdgui-helper</title>
|
||||||
|
<path fill="none" stroke="black" d="M532,-203.58C532,-196.35 532,-187.51 532,-178.32"/>
|
||||||
|
<polygon fill="black" stroke="black" points="535.5,-178.29 532,-168.29 528.5,-178.29 535.5,-178.29"/>
|
||||||
|
</g>
|
||||||
|
<!-- /usr/lib/systemd/system/amdfand.service->amdfand -->
|
||||||
|
<g id="edge15" class="edge">
|
||||||
|
<title>/usr/lib/systemd/system/amdfand.service->amdfand</title>
|
||||||
|
<path fill="none" stroke="black" d="M692.77,-386.74C693.16,-378.04 693.65,-367.08 694.13,-356.34"/>
|
||||||
|
<polygon fill="black" stroke="black" points="697.63,-356.34 694.58,-346.2 690.64,-356.03 697.63,-356.34"/>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 9.6 KiB |
@ -1,5 +1,7 @@
|
|||||||
#!/usr/bin/env zsh
|
#!/usr/bin/env zsh
|
||||||
|
|
||||||
|
BUILD_TYPE="$1"
|
||||||
|
|
||||||
set -e +x
|
set -e +x
|
||||||
|
|
||||||
ROOT="$(git rev-parse --show-toplevel)"
|
ROOT="$(git rev-parse --show-toplevel)"
|
||||||
@ -33,6 +35,16 @@ function build_and_zip() {
|
|||||||
cd ${ROOT}
|
cd ${ROOT}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if [[ "$BUILD_TYPE" == 'local' ]];
|
||||||
|
then
|
||||||
|
if [[ "$WAYLAND_DISPLAY" == "" ]];
|
||||||
|
then
|
||||||
|
build_and_zip xorg-glow amdguid-glow
|
||||||
|
else
|
||||||
|
build_and_zip wayland amdguid-wayland
|
||||||
|
fi
|
||||||
|
else
|
||||||
build_and_zip xorg-glium amdguid-glium
|
build_and_zip xorg-glium amdguid-glium
|
||||||
build_and_zip xorg-glow amdguid-glow
|
build_and_zip xorg-glow amdguid-glow
|
||||||
build_and_zip wayland amdguid-wayland
|
build_and_zip wayland amdguid-wayland
|
||||||
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user