Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
683 changes: 391 additions & 292 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ async-channel = "2"
crossterm = { version = "0.29", default-features = false, features = [
"event-stream",
] }
ratatui = "0.30"
ratatui = { version = "0.30", features = ["serde"] }
tui-input = { version = "0.15", features = [
"crossterm",
], default-features = false }
Expand All @@ -29,8 +29,8 @@ iwdrs = "0.2.6"
chrono = "0.4"
log = "0.4"
env_logger = "0.11"
strum = { version = "0.27.2", features = ["derive"] }
strum_macros = "0.27"
strum = { version = "0.28", features = ["derive"] }
strum_macros = "0.28"
libc = "0.2"
hex = "0.4.3"
tui-qrcode = "0.2.2"
Expand Down
13 changes: 11 additions & 2 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ This will produce an executable file at `target/release/impala` that you can cop
$ impala
```

## 🛠️Custom keybindings
## 🛠️Custom keybindings and themes

Keybindings can be customized in the config file `$HOME/.config/impala/config.toml`
Keybindings and themes can be customized in the config file `$HOME/.config/impala/config.toml`

```toml

Expand Down Expand Up @@ -98,6 +98,15 @@ share = "p"
[station.new_network]
show_all = "a"
connect_hidden = ""

[theme]
background = "dark gray"
border = "green"
text_color = "white"
hidden_color = "dark gray"
info_color = "green"
warning_color = "yellow"
error_color = "red"
```

## Contributing
Expand Down
12 changes: 8 additions & 4 deletions src/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use iwdrs::{adapter::Adapter as iwdAdapter, session::Session};
use ratatui::{
Frame,
layout::{Alignment, Constraint, Direction, Flex, Layout},
style::{Color, Style},
style::Style,
widgets::{Block, BorderType, Borders, Cell, Clear, Padding, Row, Table},
};

Expand Down Expand Up @@ -54,7 +54,7 @@ impl Adapter {
Ok(())
}

pub fn render(&self, frame: &mut Frame, device_addr: String) {
pub fn render(&self, frame: &mut Frame, device_addr: String, config: Arc<Config>) {
let popup_layout = Layout::default()
.direction(ratatui::layout::Direction::Vertical)
.constraints([
Expand Down Expand Up @@ -113,11 +113,15 @@ impl Adapter {
.title_alignment(Alignment::Center)
.padding(Padding::uniform(1))
.borders(Borders::ALL)
.border_style(Style::default().fg(Color::Green))
.border_style(Style::default().fg(config.theme.border))
.border_type(BorderType::Thick),
)
.column_spacing(3)
.row_highlight_style(Style::default().bg(Color::DarkGray).fg(Color::White));
.row_highlight_style(
Style::default()
.bg(config.theme.background)
.fg(config.theme.text_color),
);

frame.render_widget(Clear, area);
frame.render_widget(device_infos_table, area);
Expand Down
71 changes: 71 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use ratatui::style::Color;
use toml;

use dirs;
Expand All @@ -22,6 +23,9 @@ pub struct Config {

#[serde(default)]
pub ap: AccessPoint,

#[serde(default)]
pub theme: Theme,
}

fn default_switch_mode() -> char {
Expand Down Expand Up @@ -150,6 +154,73 @@ fn default_ap_stop() -> char {
'x'
}

// Theme
#[derive(Deserialize, Debug)]
pub struct Theme {
#[serde(default = "default_background")]
pub background: Color,

#[serde(default = "default_border")]
pub border: Color,

#[serde(default = "default_text_color")]
pub text_color: Color,

#[serde(default = "default_hidden_color")]
pub hidden_color: Color,

#[serde(default = "default_info_color")]
pub info_color: Color,

#[serde(default = "default_warning_color")]
pub warning_color: Color,

#[serde(default = "default_error_color")]
pub error_color: Color,
}

fn default_background() -> Color {
Color::DarkGray
}

fn default_border() -> Color {
Color::Green
}

fn default_text_color() -> Color {
Color::White
}

fn default_hidden_color() -> Color {
Color::DarkGray
}

fn default_info_color() -> Color {
Color::Green
}

fn default_warning_color() -> Color {
Color::Yellow
}

fn default_error_color() -> Color {
Color::Red
}

impl Default for Theme {
fn default() -> Self {
Self {
background: default_background(),
border: default_border(),
text_color: default_text_color(),
hidden_color: default_hidden_color(),
info_color: default_info_color(),
warning_color: default_warning_color(),
error_color: default_error_color(),
}
}
}

impl Config {
pub fn new() -> Self {
let conf_path = dirs::config_dir()
Expand Down
10 changes: 7 additions & 3 deletions src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use iwdrs::{device::Device as iwdDevice, modes::Mode, session::Session};
use ratatui::{
Frame,
layout::{Constraint, Direction, Flex, Layout},
style::{Color, Style, Stylize},
style::{Style, Stylize},
text::{Line, Span},
widgets::{Block, BorderType, Borders, Padding, Row, Table, TableState},
};
Expand Down Expand Up @@ -147,13 +147,17 @@ impl Device {
.title(" Device ")
.title_style(Style::default().bold())
.borders(Borders::ALL)
.border_style(Style::default().fg(Color::Green))
.border_style(Style::default().fg(config.theme.border))
.border_type(BorderType::Thick)
.padding(Padding::horizontal(1)),
)
.column_spacing(1)
.flex(Flex::SpaceAround)
.row_highlight_style(Style::default().bg(Color::DarkGray).fg(Color::White));
.row_highlight_style(
Style::default()
.bg(config.theme.background)
.fg(config.theme.text_color),
);

let mut device_state = TableState::default().with_selected(0);
frame.render_stateful_widget(device_table, device_block, &mut device_state);
Expand Down
7 changes: 3 additions & 4 deletions src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,10 @@ impl EventHandler {
}
Some(Ok(evt)) = crossterm_event => {
match evt {
CrosstermEvent::Key(key) => {
if key.kind == crossterm::event::KeyEventKind::Press {
CrosstermEvent::Key(key)
if key.kind == crossterm::event::KeyEventKind::Press => {
sender_cloned.send(Event::Key(key)).unwrap();
}
},
},
CrosstermEvent::Resize(x, y) => {
sender_cloned.send(Event::Resize(x, y)).unwrap();
},
Expand Down
Loading