Skip to content

Commit 16066c4

Browse files
Finalize robustness pass and set minimum size to 119x35
1 parent a9d1b9f commit 16066c4

7 files changed

Lines changed: 93 additions & 53 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "nettui"
3-
version = "0.1.8"
3+
version = "0.1.9"
44
edition = "2024"
55
description = "Unified TUI for Wi-Fi and Ethernet"
66
license = "GPL-3.0-only"

README.md

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ This project was inspired by and builds upon ideas from Impala by pythops.
2525
- link up/down toggle on selected interface
2626
- toggle link admin state up/down (`ip link set`)
2727
- DHCP renew (`networkctl renew`)
28-
- Toast/error popups and terminal size guard
28+
- Toast/error popups and terminal size guard (`119x35` minimum)
2929

3030
## Runtime assumptions
3131

@@ -111,11 +111,41 @@ cargo test
111111

112112
## Omarchy integration (optional)
113113

114-
Recommended launch command for Omarchy-style app-id handling:
114+
Current Omarchy launcher behavior:
115115

116116
```bash
117-
omarchy-launch-or-focus-tui nettui
117+
omarchy-launch-wifi
118118
```
119119

120-
If Omarchy chooses to make `nettui` the default network TUI later, this command can become the single
121-
launcher entry for both Wi-Fi and Ethernet workflows.
120+
On recent Omarchy, this already prefers `nettui` when installed.
121+
122+
To force `nettui` as default network TUI:
123+
124+
1. Install `nettui`:
125+
126+
```bash
127+
yay -S nettui-bin
128+
```
129+
130+
2. Verify launcher script prefers `nettui`:
131+
132+
```bash
133+
grep -n "nettui" ~/.local/share/omarchy/bin/omarchy-launch-wifi
134+
grep -n "nettui" ~/.local/share/omarchy/bin/omarchy-launch-ethernet
135+
```
136+
137+
3. If needed, patch both launchers:
138+
139+
```bash
140+
sed -i 's/omarchy-launch-or-focus-tui impala/omarchy-launch-or-focus-tui nettui/g' ~/.local/share/omarchy/bin/omarchy-launch-wifi
141+
sed -i 's/omarchy-launch-or-focus-tui ethtui/omarchy-launch-or-focus-tui nettui/g' ~/.local/share/omarchy/bin/omarchy-launch-ethernet
142+
```
143+
144+
4. Set dedicated floating window size for `nettui` (Hyprland):
145+
146+
```bash
147+
grep -q "match:class org.omarchy.nettui" ~/.config/hypr/apps/system.conf || echo "windowrule = size 1190 735, match:class org.omarchy.nettui" >> ~/.config/hypr/apps/system.conf
148+
hyprctl reload
149+
```
150+
151+
5. Click network module in Waybar to verify `nettui` opens.

src/app.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -844,11 +844,11 @@ impl App {
844844
}
845845

846846
fn restore_ethernet_selection(&mut self, selected_iface: Option<String>) {
847-
if let Some(name) = selected_iface {
848-
if let Some(idx) = self.ethernet.ifaces.iter().position(|i| i.name == name) {
849-
self.ethernet_state.select(Some(idx));
850-
return;
851-
}
847+
if let Some(name) = selected_iface
848+
&& let Some(idx) = self.ethernet.ifaces.iter().position(|i| i.name == name)
849+
{
850+
self.ethernet_state.select(Some(idx));
851+
return;
852852
}
853853
select_first_if_any(&mut self.ethernet_state, self.ethernet.ifaces.len());
854854
}
@@ -889,9 +889,7 @@ pub fn determine_start_tab(
889889
StartupTabPolicy::PreferActive => {
890890
if ethernet.has_active() {
891891
ActiveTab::Ethernet
892-
} else if wifi.is_active() {
893-
ActiveTab::Wifi
894-
} else if wifi.has_adapter() {
892+
} else if wifi.is_active() || wifi.has_adapter() {
895893
ActiveTab::Wifi
896894
} else {
897895
ActiveTab::Ethernet

src/backend/iwd.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,12 @@ impl IwdBackend {
296296
}
297297
}
298298

299+
impl Default for IwdBackend {
300+
fn default() -> Self {
301+
Self::new()
302+
}
303+
}
304+
299305
#[derive(Debug, Clone)]
300306
struct KnownMeta {
301307
security: String,

src/backend/networkd.rs

Lines changed: 42 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -45,21 +45,21 @@ impl NetworkdBackend {
4545
.output()
4646
.await;
4747

48-
if let Ok(pkexec_out) = pkexec_out {
49-
if pkexec_out.status.success() {
50-
return Ok(CommandResult {
51-
program: "networkctl".to_string(),
52-
args: vec!["renew".to_string(), iface.to_string()],
53-
used_sudo: true,
54-
status: pkexec_out.status.code().unwrap_or(0),
55-
stdout: String::from_utf8_lossy(&pkexec_out.stdout)
56-
.trim()
57-
.to_string(),
58-
stderr: String::from_utf8_lossy(&pkexec_out.stderr)
59-
.trim()
60-
.to_string(),
61-
});
62-
}
48+
if let Ok(pkexec_out) = pkexec_out
49+
&& pkexec_out.status.success()
50+
{
51+
return Ok(CommandResult {
52+
program: "networkctl".to_string(),
53+
args: vec!["renew".to_string(), iface.to_string()],
54+
used_sudo: true,
55+
status: pkexec_out.status.code().unwrap_or(0),
56+
stdout: String::from_utf8_lossy(&pkexec_out.stdout)
57+
.trim()
58+
.to_string(),
59+
stderr: String::from_utf8_lossy(&pkexec_out.stderr)
60+
.trim()
61+
.to_string(),
62+
});
6363
}
6464

6565
let sudo_out = Command::new("sudo")
@@ -142,27 +142,27 @@ impl NetworkdBackend {
142142
.output()
143143
.await;
144144

145-
if let Ok(pkexec_out) = pkexec_out {
146-
if pkexec_out.status.success() {
147-
return Ok(CommandResult {
148-
program: "ip".to_string(),
149-
args: vec![
150-
"link".to_string(),
151-
"set".to_string(),
152-
"dev".to_string(),
153-
iface.to_string(),
154-
state_arg.to_string(),
155-
],
156-
used_sudo: true,
157-
status: pkexec_out.status.code().unwrap_or(0),
158-
stdout: String::from_utf8_lossy(&pkexec_out.stdout)
159-
.trim()
160-
.to_string(),
161-
stderr: String::from_utf8_lossy(&pkexec_out.stderr)
162-
.trim()
163-
.to_string(),
164-
});
165-
}
145+
if let Ok(pkexec_out) = pkexec_out
146+
&& pkexec_out.status.success()
147+
{
148+
return Ok(CommandResult {
149+
program: "ip".to_string(),
150+
args: vec![
151+
"link".to_string(),
152+
"set".to_string(),
153+
"dev".to_string(),
154+
iface.to_string(),
155+
state_arg.to_string(),
156+
],
157+
used_sudo: true,
158+
status: pkexec_out.status.code().unwrap_or(0),
159+
stdout: String::from_utf8_lossy(&pkexec_out.stdout)
160+
.trim()
161+
.to_string(),
162+
stderr: String::from_utf8_lossy(&pkexec_out.stderr)
163+
.trim()
164+
.to_string(),
165+
});
166166
}
167167

168168
let sudo_out = Command::new("sudo")
@@ -226,6 +226,12 @@ impl NetworkdBackend {
226226
}
227227
}
228228

229+
impl Default for NetworkdBackend {
230+
fn default() -> Self {
231+
Self::new()
232+
}
233+
}
234+
229235
impl EthernetBackend for NetworkdBackend {
230236
fn list_ifaces(&self) -> Result<Vec<EthernetIface>> {
231237
list_ethernet_ifaces()

src/ui/layout.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ use ratatui::{
99
};
1010

1111
pub fn render(app: &mut App, frame: &mut Frame) {
12-
const MIN_W: u16 = 126;
13-
const MIN_H: u16 = 27;
12+
const MIN_W: u16 = 119;
13+
const MIN_H: u16 = 35;
1414

1515
let area = frame.area();
1616
if area.width < MIN_W || area.height < MIN_H {

0 commit comments

Comments
 (0)