index : nmrs-tui
A fast, Vim-friendly NetworkManager TUI built in Rust.
about summary refs log tree commit diff
author y2w8 <yousefalharby416@gmail.com> 2026-06-16 01:39:59 +0300
committer y2w8 <yousefalharby416@gmail.com> 2026-06-16 19:09:14 +0300
commit a2d2b510f74801ee4148c45152d29ca103356b3d [patch]
tree 463171442395f2df179bc4cd55abb1f032ef8d8b
parent 9153954f48f75af34bd5e65879003d8913e070a0
download a2d2b510f74801ee4148c45152d29ca103356b3d.tar.gz

Add: github release and CI, CHANGELOG, update readme, better performance.

Diffstat

-rw-r--r-- .gitignore 1
-rw-r--r-- CHANGELOG.md 5
-rw-r--r-- Cargo.lock 197
-rw-r--r-- Cargo.toml 22
-rw-r--r-- README.md 49
-rw-r--r-- config.ron 6
-rw-r--r-- justfile 23
-rw-r--r-- release.toml 11
-rw-r--r-- src/action.rs 217
-rw-r--r-- src/app.rs 19
-rw-r--r-- src/cli.rs 6
-rw-r--r-- src/config.rs 7
-rw-r--r-- src/events.rs 144
-rw-r--r-- src/logger.rs 16
-rw-r--r-- src/main.rs 13
-rw-r--r-- src/network_manager.rs 14
-rw-r--r-- src/timer.rs 7
-rw-r--r-- src/tui.rs 143
-rw-r--r-- .github/workflows/ci.yml 25
-rw-r--r-- .github/workflows/release.yml 74
-rw-r--r-- src/ui/help.rs 17
-rw-r--r-- src/ui/input.rs 2
-rw-r--r-- src/ui/list.rs 5
-rw-r--r-- src/ui/mod.rs 91
-rw-r--r-- src/ui/popup.rs 37
-rw-r--r-- src/ui/table.rs 122
-rw-r--r-- src/ui/toast.rs 15
 27 files changed, 783 insertions(+), 505 deletions(-)

diff --git a/.gitignore b/.gitignore
index ea8c4bf..9ee36c7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,1 +1,2 @@
/target
PLANS.md
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..f99d9f6 100644
--- /dev/null
+++ b/CHANGELOG.md
@@ -1,0 +1,5 @@
# Changelog
All notable changes to the `nmrs-tui` crate will be documented in this file.

## [Unreleased]
First release!!
diff --git a/Cargo.lock b/Cargo.lock
index 75b67ae..a7b499c 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -74,6 +74,15 @@
checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c"

[[package]]
name = "approx"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cab112f0a86d568ea0e627cc1d6be74a1e9cd55214684db5561995f6dad897c6"
dependencies = [
 "num-traits",
]

[[package]]
name = "async-broadcast"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -254,9 +263,9 @@

[[package]]
name = "bitflags"
version = "2.12.0"
version = "2.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2c61cd05405eb1d0f3a4660f802bad76ece84b6e722426342ba5dd511f724e97"
checksum = "b4388bee8683e3d04af747c73422af53102d2bd24d9eadb6cbc100baef4b43f8"
dependencies = [
 "serde_core",
]
@@ -288,6 +297,12 @@
version = "3.20.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649"

[[package]]
name = "by_address"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "64fa3c856b712db6612c019f14756e64e4bcea13337a6b33b696333a9eaa2d06"

[[package]]
name = "bytemuck"
@@ -410,6 +425,12 @@
]

[[package]]
name = "critical-section"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "790eea4361631c5e7d22598ecd5723ff611904e3344ce8720784c93e3d83d40b"

[[package]]
name = "crossbeam-utils"
version = "0.8.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -421,10 +442,11 @@
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d8b9f2e4c67f833b660cdb0a3523065869fb35570177239812ed4c905aeff87b"
dependencies = [
 "bitflags 2.12.0",
 "bitflags 2.13.0",
 "crossterm_winapi",
 "derive_more",
 "document-features",
 "futures-core",
 "mio",
 "parking_lot",
 "rustix",
@@ -661,6 +683,12 @@
 "bit-set",
 "regex",
]

[[package]]
name = "fast-srgb8"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd2e7510819d6fbf51a5545c8f922716ecfb14df168a3242f7d33e0239efe6a1"

[[package]]
name = "fastrand"
@@ -887,6 +915,11 @@
version = "0.17.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a"
dependencies = [
 "allocator-api2",
 "equivalent",
 "foldhash 0.2.0",
]

[[package]]
name = "heck"
@@ -1021,6 +1054,12 @@
checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66"

[[package]]
name = "libm"
version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981"

[[package]]
name = "libredox"
version = "0.1.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1035,7 +1074,7 @@
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f50e8f47623268b5407192d26876c4d7f89d686ca130fdc53bced4814cd29f8"
dependencies = [
 "bitflags 2.12.0",
 "bitflags 2.13.0",
]

[[package]]
@@ -1061,17 +1100,17 @@

[[package]]
name = "log"
version = "0.4.30"
version = "0.4.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "616ec5685824bcc94416c6d4a7a446eea774a31efd7062c8480ba6fd06d7a6e5"
checksum = "953f07c43838f8e6f9758cab68bf5bed85465e7587ebe0b823f1bcd81978ad3a"

[[package]]
name = "lru"
version = "0.16.4"
version = "0.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f66e8d5d03f609abc3a39e6f08e4164ebf1447a732906d39eb9b99b7919ef39"
checksum = "8a860605968fce16869fd239cf4237a82f3ac470723415db603b0e8b6c8d4fb9"
dependencies = [
 "hashbrown 0.16.1",
 "hashbrown 0.17.1",
]

[[package]]
@@ -1129,7 +1168,7 @@
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46"
dependencies = [
 "bitflags 2.12.0",
 "bitflags 2.13.0",
 "cfg-if",
 "cfg_aliases",
 "libc",
@@ -1138,12 +1177,12 @@

[[package]]
name = "nmrs"
version = "3.1.5"
source = "git+https://github.com/cachebag/nmrs.git#c9e03c58d36889f04b0708fe37b0373cd2681996"
version = "3.2.0"
source = "git+https://github.com/networkmanager-rs/nmrs?rev=b6cbb46ce2a3e0259a7e0c2bbcb859fede083315#b6cbb46ce2a3e0259a7e0c2bbcb859fede083315"
dependencies = [
 "async-trait",
 "base64",
 "bitflags 2.12.0",
 "bitflags 2.13.0",
 "futures",
 "futures-timer",
 "log",
@@ -1160,6 +1199,7 @@
version = "0.1.0"
dependencies = [
 "anyhow",
 "bitflags 2.13.0",
 "clap",
 "crossterm",
 "dirs",
@@ -1170,6 +1210,7 @@
 "serde",
 "simplelog",
 "tokio",
 "tokio-stream",
 "zbus",
]

@@ -1253,6 +1294,30 @@
dependencies = [
 "futures-core",
 "pin-project-lite",
]

[[package]]
name = "palette"
version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4cbf71184cc5ecc2e4e1baccdb21026c20e5fc3dcf63028a086131b3ab00b6e6"
dependencies = [
 "approx",
 "fast-srgb8",
 "libm",
 "palette_derive",
]

[[package]]
name = "palette_derive"
version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f5030daf005bface118c096f510ffb781fc28f9ab6a32ab224d8631be6851d30"
dependencies = [
 "by_address",
 "proc-macro2",
 "quote",
 "syn 2.0.117",
]

[[package]]
@@ -1488,9 +1553,9 @@

[[package]]
name = "ratatui"
version = "0.30.0"
version = "0.30.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d1ce67fb8ba4446454d1c8dbaeda0557ff5e94d39d5e5ed7f10a65eb4c8266bc"
checksum = "1695748e3a735b34968c887ceea5a380b43545903868ae8f5b666593100f6b68"
dependencies = [
 "instability",
 "ratatui-core",
@@ -1498,21 +1563,25 @@
 "ratatui-macros",
 "ratatui-termwiz",
 "ratatui-widgets",
 "serde",
]

[[package]]
name = "ratatui-core"
version = "0.1.0"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ef8dea09a92caaf73bff7adb70b76162e5937524058a7e5bff37869cbbec293"
checksum = "42d3603f354bba8c595fa47860e60142d7372b7210c27044c6a7d0e1a4336b44"
dependencies = [
 "bitflags 2.12.0",
 "bitflags 2.13.0",
 "compact_str",
 "hashbrown 0.16.1",
 "critical-section",
 "hashbrown 0.17.1",
 "indoc",
 "itertools",
 "kasuari",
 "lru",
 "palette",
 "serde",
 "strum",
 "thiserror 2.0.18",
 "unicode-segmentation",
@@ -1522,9 +1591,9 @@

[[package]]
name = "ratatui-crossterm"
version = "0.1.0"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "577c9b9f652b4c121fb25c6a391dd06406d3b092ba68827e6d2f09550edc54b3"
checksum = "2b2867bedcbd6a690ca4f8672a687b730ec07660c79844517b084311b529980c"
dependencies = [
 "cfg-if",
 "crossterm",
@@ -1534,9 +1603,9 @@

[[package]]
name = "ratatui-macros"
version = "0.7.0"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7f1342a13e83e4bb9d0b793d0ea762be633f9582048c892ae9041ef39c936f4"
checksum = "80fac59720679490d89d200df411faa249be728681adcabed3d047ae72c48f1d"
dependencies = [
 "ratatui-core",
 "ratatui-widgets",
@@ -1544,9 +1613,9 @@

[[package]]
name = "ratatui-termwiz"
version = "0.1.0"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0f76fe0bd0ed4295f0321b1676732e2454024c15a35d01904ddb315afd3d545c"
checksum = "386b8ff8f74ed749509391c56d549761a2fcdb408e1f42e467286bcb7dac8967"
dependencies = [
 "ratatui-core",
 "termwiz",
@@ -1554,17 +1623,18 @@

[[package]]
name = "ratatui-widgets"
version = "0.3.0"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7dbfa023cd4e604c2553483820c5fe8aa9d71a42eea5aa77c6e7f35756612db"
checksum = "7ef4f17dd7ac3abf5adc2b920a03c61eee4bfe6a88fa5191936895525371d79c"
dependencies = [
 "bitflags 2.12.0",
 "hashbrown 0.16.1",
 "bitflags 2.13.0",
 "hashbrown 0.17.1",
 "indoc",
 "instability",
 "itertools",
 "line-clipping",
 "ratatui-core",
 "serde",
 "strum",
 "time",
 "unicode-segmentation",
@@ -1577,7 +1647,7 @@
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d"
dependencies = [
 "bitflags 2.12.0",
 "bitflags 2.13.0",
]

[[package]]
@@ -1626,7 +1696,7 @@
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4147b952f3f819eca0e99527022f7d6a8d05f111aeb0a62960c74eb283bec8fc"
dependencies = [
 "bitflags 2.12.0",
 "bitflags 2.13.0",
 "once_cell",
 "serde",
 "serde_derive",
@@ -1649,7 +1719,7 @@
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190"
dependencies = [
 "bitflags 2.12.0",
 "bitflags 2.13.0",
 "errno",
 "libc",
 "linux-raw-sys",
@@ -1825,18 +1895,18 @@

[[package]]
name = "strum"
version = "0.27.2"
version = "0.28.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af23d6f6c1a224baef9d3f61e287d2761385a5b88fdab4eb4c6f11aeb54c4bcf"
checksum = "9628de9b8791db39ceda2b119bbe13134770b56c138ec1d3af810d045c04f9bd"
dependencies = [
 "strum_macros",
]

[[package]]
name = "strum_macros"
version = "0.27.2"
version = "0.28.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7695ce3845ea4b33927c055a39dc438a45b059f7c1b3d91d38d10355fb8cbca7"
checksum = "ab85eea0270ee17587ed4156089e10b9e6880ee688791d45a905f5b1ca36f664"
dependencies = [
 "heck",
 "proc-macro2",
@@ -1917,7 +1987,7 @@
dependencies = [
 "anyhow",
 "base64",
 "bitflags 2.12.0",
 "bitflags 2.13.0",
 "fancy-regex",
 "filedescriptor",
 "finl_unicode",
@@ -2048,6 +2118,31 @@
 "proc-macro2",
 "quote",
 "syn 2.0.117",
]

[[package]]
name = "tokio-stream"
version = "0.1.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32da49809aab5c3bc678af03902d4ccddea2a87d028d86392a4b1560c6906c70"
dependencies = [
 "futures-core",
 "pin-project-lite",
 "tokio",
 "tokio-util",
]

[[package]]
name = "tokio-util"
version = "0.7.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ae9cec805b01e8fc3fd2fe289f89149a9b66dd16786abd8b19cfa7b48cb0098"
dependencies = [
 "bytes",
 "futures-core",
 "futures-sink",
 "pin-project-lite",
 "tokio",
]

[[package]]
@@ -2183,9 +2278,9 @@

[[package]]
name = "uuid"
version = "1.23.2"
version = "1.23.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d258b83ceec21034727ecee8c382cfa6c3e133699b0742c64571814fb420c9f7"
checksum = "144d6b123cef80b301b8f72a9e2ca4370ddec21950d0a103dd22c437006d2db7"
dependencies = [
 "atomic",
 "getrandom 0.4.2",
@@ -2307,7 +2402,7 @@
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe"
dependencies = [
 "bitflags 2.12.0",
 "bitflags 2.13.0",
 "hashbrown 0.15.5",
 "indexmap",
 "semver",
@@ -2504,7 +2599,7 @@
checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2"
dependencies = [
 "anyhow",
 "bitflags 2.12.0",
 "bitflags 2.13.0",
 "indexmap",
 "log",
 "serde",
@@ -2536,9 +2631,9 @@

[[package]]
name = "zbus"
version = "5.15.0"
version = "5.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3bcbf15c8708d7fc1be0c993622e0a5cbd5e8b52bfa40afa4c3e0cd8d724ac1"
checksum = "eee682d202a77e4a9f3b2c2bdf48a7b28af5c08c34ddf66f98c93e5e39464285"
dependencies = [
 "async-broadcast",
 "async-executor",
@@ -2571,9 +2666,9 @@

[[package]]
name = "zbus_macros"
version = "5.15.0"
version = "5.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "51fa5406ad9175a8c825a931f8cf347116b531b3634fcb0b627c290f1f2516ff"
checksum = "adf1bd45a81a103745b1757754762a26e8cd01e4532e4d6c8ec431624b80d1d6"
dependencies = [
 "proc-macro-crate",
 "proc-macro2",
@@ -2603,9 +2698,9 @@

[[package]]
name = "zvariant"
version = "5.11.0"
version = "5.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c1567a6ec68df868cbbfde844cfc6d81649fe5109a62b116b19fabd53e618ee"
checksum = "a192a0bde63360d77a7523c833d4b4ce6070a927e2c53246e4c540b1a3e27be0"
dependencies = [
 "endi",
 "enumflags2",
@@ -2617,9 +2712,9 @@

[[package]]
name = "zvariant_derive"
version = "5.11.0"
version = "5.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c7d5b780599bbde114e39d9a0799577fad1ced5105d38515745f7b3099d8ceda"
checksum = "90bc6cde9c01c511074be97f7ccb6c19d0da89e3f8662e812e999dcfd4638737"
dependencies = [
 "proc-macro-crate",
 "proc-macro2",
@@ -2630,9 +2725,9 @@

[[package]]
name = "zvariant_utils"
version = "3.3.1"
version = "3.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d464f5733ffa07a3164d656f18533caace9d0638596721355d73256a410d691"
checksum = "1e8535915cfa75547e559d8c68e8139909a4aeee076831e4ef7fc59d8172c4d6"
dependencies = [
 "proc-macro2",
 "quote",
diff --git a/Cargo.toml b/Cargo.toml
index 2bcaf64..a7deacb 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,17 +1,27 @@
[package]
name = "nmrs-tui"
version = "0.1.0"
license = "GPL-3.0"
description = "A fast, keyboard-first TUI for NetworkManager — built in Rust."
authors = ["Yousef Al-Harbi <yousefalharby416@gmail.com>"]
repository = "https://github.com/y2w8/nmrs-tui"
edition = "2024"
rust-version = "1.96.0"
readme = "README.md"
keywords = ["networkmanager", "tui", "linux"]
categories = ["tui"]

[dependencies]
anyhow = "1.0.102"
crossterm = "0.29.0"
ratatui = "0.30.0"
crossterm = { version = "0.29.0", features = ["event-stream"] }
ratatui = "0.30.1"
serde = "1.0.228"
tokio = { version = "1.50.0", features = ["rt-multi-thread", "macros"] }
nmrs = { git = "https://github.com/cachebag/nmrs.git" }
zbus = "5.15.0"
log = "0.4.29"
tokio = { version = "1.52.3", features = ["rt-multi-thread", "macros"] }
tokio-stream = { version = "0.1", features = ["sync"] }
nmrs = { git = "https://github.com/networkmanager-rs/nmrs", rev = "b6cbb46ce2a3e0259a7e0c2bbcb859fede083315" }
bitflags = "2.13.0"
zbus = "5.16.0"
log = "0.4.32"
simplelog = "0.12.2"
dirs = "6.0.0"
ron = "0.12.1"
diff --git a/README.md b/README.md
index 200ec5b..dfae58d 100644
--- a/README.md
+++ b/README.md
@@ -1,24 +1,22 @@
# <p align="center"> nmrs-tui 🦀 </p>

<p align="center">
  <strong>A fast, aesthetic, and Vim-friendly NetworkManager TUI built in Rust.</strong>
  <strong>A fast, keyboard-first TUI for NetworkManager — built in Rust.</strong>
</p>

<p align="center">
  <img src="https://img.shields.io/badge/status-heavy%20development-orange" alt="Status">
  <img src="https://img.shields.io/badge/license-GPL--3-blue" alt="License">
  <img src="https://img.shields.io/badge/built%20with-Ratatui-red" alt="Ratatui">
  <img src="https://img.shields.io/badge/status-BETA-orange?style=for-the-badge" alt="Status">
  <img src="https://img.shields.io/badge/license-GPL--3-blue?style=for-the-badge" alt="License">
  <img src="https://img.shields.io/badge/built%20with-Ratatui-red?style=for-the-badge" alt="Ratatui">
</p>

---
> [!IMPORTANT]
> `nmrs-tui` is currently in its early stages. Expect breaking changes and frequent updates as we move toward a stable release.

`nmrs-tui` is a terminal user interface for [nmrs](https://github.com/cachebag/nmrs), inspired from [impala](https://github.com/pythops/impala).

## ✨ Features
- **Available Networks:** Real-time scanning and listing of WiFi networks.
- **Known Networks:** Easily manage and connect to your saved profiles (WIP).
- **Known Networks:** Easily manage and connect to your saved profiles.
- **Device Management:** View and control your network interfaces (WIP).
- **Customizable:** (WIP).
- **Vim-like Keybindings:** Navigate your networks with Vim-like keybinds.
@@ -26,43 +24,30 @@
## 🚀 Installation

### Prerequisites
- **NetworkManager** must be installed and running.
- [**NetworkManager**](https://wiki.archlinux.org/title/NetworkManager) must be installed and running.
- **Rust** if you are building from source.

### 📦 Cargo
```sh
cargo install nmrs-tui
```
The binary will be available at `~/.cargo/bin/nmrs-tui`.
Make sure to add path `export PATH="$HOME/.cargo/bin:$PATH"`

### Build from Source
```bash
git clone https://github.com/y2w8/nmrs-tui.git
cd nmrs-tui
cargo build --release
```
The binary will be available at `target/release/nmrs-tui`.

## ⌨️ Keybindings
| Key | Action |
| ------------- | -------------- |
| `Shift+Tab`/`Tab`/`h`/`l` | Switch between tabs (Known/Available/Devices) |
| `↓`/`j` | Move selection down |
| `↑`/`k` | Move selection up |
| `Enter`/`Space` | Connect to selected network |
| `Esc` | Cancel / Close popup |
| `q` | Quit application |

The binary will be available at `./target/release/nmrs-tui`.

## 🛠️ Debugging & Logs
If you encounter issues, `nmrs-tui` provides detailed logging. You can set the log level using the `RUST_LOG` environment variable:
If you encounter issues, `nmrs-tui` provides detailed logging. You can set the log level using the `NMRS_LOG` environment variable:
```bash
RUST_LOG=debug nmrs-tui
NMRS_LOG=trace nmrs-tui
```
Logs are stored in your OS cache directory (e.g., `~/.cache/nmrs-tui/nmrs-tui.log`).

## 🏗️ Project Structure

- `src/main.rs`: Entry point.
- `src/tui.rs`: Main loop.
- `src/ui/`: UI components including `table`, `popup`, and `input` logic.
- `src/events.rs`: Keyboard event handling and application logic.
- `src/network_manager.rs`: Integration with the `nmrs` backend.
- `src/logger.rs`: Logging implementation.
Logs are stored in your cache directory `~/.cache/nmrs-tui/nmrs-tui.log`, fallback to cwd.

## 🤝 Contributing

diff --git a/config.ron b/config.ron
index dd43862..e2f6c70 100644
--- a/config.ron
+++ b/config.ron
@@ -1,3 +1,3 @@
(
int: 0
)
/* @[crate::config::Config] */

Config()
diff --git a/justfile b/justfile
index 9083985..0a37b4a 100644
--- a/justfile
+++ b/justfile
@@ -5,7 +5,24 @@
  cargo run

debug:
  RUST_LOG=debug cargo run
  NMRS_LOG=trace cargo run

deploy:
  cargo build --release
check:
  cargo check

package:
  cargo package

publish:
  cargo publish

release level="patch":
  cargo release {{level}} --execute

fmt:
    cargo fmt --all

lint:
    cargo clippy --all-targets --all-features -- -D warnings

ci: fmt lint
diff --git a/release.toml b/release.toml
new file mode 100644
index 0000000..75dc17e 100644
--- /dev/null
+++ b/release.toml
@@ -1,0 +1,11 @@
push = true
publish = true
tag = true
sign-tag = false
pre-release-commit-message = "chore: release {{version}}"
tag-message = "Release {{version}}"

# Changelog integration
pre-release-replacements = [
  { file = "CHANGELOG.md", search = "## \\[Unreleased\\]", replace = "## [Unreleased]\n\n## [{{version}}] - {{date}}", exactly = 1 },
]
diff --git a/src/action.rs b/src/action.rs
index fc88655..93e3f11 100644
--- a/src/action.rs
+++ b/src/action.rs
@@ -11,8 +11,8 @@
    },
};

#[derive(Clone)]
pub enum Actions {
#[derive(Debug, Clone)]
pub enum Action {
    Quit,
    Tick(Duration),
    Refresh,
@@ -20,9 +20,11 @@
    SetInputMode(InputMode),

    // Network Commands
    NetworkScanResult(Vec<Network>, Vec<Network>, Vec<WifiDevice>),
    Connect(String, Option<String>, WifiSecurity),
    NetworkScanResult(Box<(Vec<Network>, Vec<Network>, Vec<WifiDevice>)>),
    Connect(Box<(String, Option<String>, WifiSecurity)>),
    Forget(String),
    #[allow(dead_code)]
    EditNetwork(String),
    TogglePower,
    Disconnect,

@@ -37,24 +39,24 @@
    ),
}

pub struct Action {
    tx: UnboundedSender<Actions>,
    rx: UnboundedReceiver<Actions>,
pub struct ActionHandler {
    tx: UnboundedSender<Action>,
    rx: UnboundedReceiver<Action>,
}

impl Action {
impl ActionHandler {
    pub fn new() -> Self {
        let (tx, rx) = mpsc::unbounded_channel::<Actions>();
        let (tx, rx) = mpsc::unbounded_channel::<Action>();

        Self { tx, rx }
    }

    /// Returns action_tx.
    pub fn sender(&self) -> UnboundedSender<Actions> {
    pub fn sender(&self) -> UnboundedSender<Action> {
        self.tx.clone()
    }

    pub fn send(&self, action: Actions) {
    pub fn send(&self, action: Action) {
        match self.tx.send(action) {
            Ok(_) => {}
            Err(e) => {
@@ -63,19 +65,13 @@
        }
    }

    pub fn drain(&mut self) -> Vec<Actions> {
        let mut actions: Vec<Actions> = Vec::new();
        while let Ok(action) = self.rx.try_recv() {
            actions.push(action);
        }
        actions
    }

    pub async fn handle_actions(app: &mut App) -> anyhow::Result<()> {
        for action in app.action.drain() {
        while let Ok(action) = app.action.rx.try_recv() {
            debug!("Action: {:?}", action);

            match action {
                Actions::Quit => app.quit(),
                Actions::Tick(delta) => {
                Action::Quit => app.quit(),
                Action::Tick(delta) => {
                    // Toast duration timer
                    app.toasts.iter_mut().for_each(|toast| {
                        toast.duration = toast.duration.saturating_sub(delta);
@@ -83,7 +79,7 @@
                    app.toasts.retain(|toast| !toast.duration.is_zero());

                    // Timers
                    let finished: Vec<Actions> = app
                    let finished: Vec<Action> = app
                        .timers_mut()
                        .into_iter()
                        .filter(|t| t.enabled)
@@ -102,7 +98,7 @@
                        app.action.send(action);
                    }
                }
                Actions::Refresh => {
                Action::Refresh => {
                    if app.scan.enabled {
                        let action_tx = app.action.sender();
                        let network_manager = app.network_manager.clone();
@@ -112,23 +108,28 @@
                                network_manager.get_devices()
                            ) {
                                Ok(((known, available), devices)) => {
                                    let _ = action_tx.send(Actions::NetworkScanResult(
                                    let _ = action_tx.send(Action::NetworkScanResult(Box::new((
                                        known, available, devices,
                                    ));
                                    ))));
                                }
                                Err(e) => {
                                    error!("Refresh Failed: {}", e)
                                Err(_) => {
                                    let _ = action_tx.send(Action::ShowToast(
                                        None,
                                        "Refresh failed!".into(),
                                        Urgency::Critical,
                                        None,
                                    ));
                                }
                            }
                        });
                    }
                }
                Actions::SetFocus(new_focus) => {
                Action::SetFocus(new_focus) => {
                    debug!("Set focus to: {:?}!", new_focus);
                    app.last_focus = app.focus;
                    app.focus = new_focus;
                }
                Actions::SetInputMode(new_inputmode) => {
                Action::SetInputMode(new_inputmode) => {
                    debug!("Set InputMode to: {:?}!", new_inputmode);
                    app.input.mode = new_inputmode;
                    app.input.value.clear();
@@ -136,7 +137,8 @@
                }

                // Network
                Actions::NetworkScanResult(known, available, devices) => {
                Action::NetworkScanResult(box_data) => {
                    let (known, available, devices) = *box_data;
                    app.network_manager.current_network =
                        app.network_manager.current_network().await;

@@ -144,143 +146,124 @@
                    app.available_networks.set_items(available);
                    app.devices.set_items(devices);
                }
                Actions::Connect(ssid, interface, credentials) => {
                    let msg = format!("Connecting to {}...", ssid);
                    debug!("{}", msg);
                    app.action
                        .send(Actions::ShowToast(None, msg.into(), Urgency::Normal, None));
                Action::Connect(box_data) => {
                    let (ssid, interface, credentials) = *box_data;
                    app.action.send(Action::ShowToast(
                        None,
                        format!("Connecting to {}...", ssid).into(),
                        Urgency::Normal,
                        None,
                    ));

                    let action_tx = app.action.sender();
                    let network_manager = app.network_manager.clone();
                    tokio::spawn(async move {
                        let msg;
                        let urgency;
                        match network_manager.connect(&ssid, interface, credentials).await {
                            Ok(Ok(_)) => {
                                let msg = "Connected!";
                                info!("{}", msg);
                                let _ = action_tx.send(Actions::ShowToast(
                                    None,
                                    msg.into(),
                                    Urgency::Success,
                                    None,
                                ));
                                msg = "Connected!";
                                urgency = Urgency::Success;
                            }
                            Ok(Err(ConnectionError::NotFound)) => {
                                let msg = "Network not visible — is it in range?";
                                error!("{}", msg);
                                let _ = action_tx.send(Actions::ShowToast(
                                    None,
                                    msg.into(),
                                    Urgency::Critical,
                                    None,
                                ));
                                msg = "Network not visible — is it in range?";
                                urgency = Urgency::Critical;
                            }
                            Ok(Err(ConnectionError::AuthFailed)) => {
                                let _ = action_tx.send(Actions::Forget(ssid.to_string()));
                                let msg = "Wrong password!";
                                error!("{}", msg);
                                let _ = action_tx.send(Actions::ShowToast(
                                    None,
                                    msg.into(),
                                    Urgency::Critical,
                                    None,
                                ));
                                let _ = action_tx.send(Action::Forget(ssid.to_string()));
                                msg = "Wrong password!";
                                urgency = Urgency::Critical;
                            }
                            Ok(Err(ConnectionError::Timeout)) => {
                                let msg = "Connection timed out — try increasing the timeout";
                                error!("{}", msg);
                                let _ = action_tx.send(Actions::ShowToast(
                                    None,
                                    msg.into(),
                                    Urgency::Critical,
                                    None,
                                ));
                                msg = "Connection timed out — try increasing the timeout";
                                urgency = Urgency::Critical;
                            }
                            Ok(Err(ConnectionError::DhcpFailed)) => {
                                let msg = "Failed to get an IP address";
                                error!("{}", msg);
                                let _ = action_tx.send(Actions::ShowToast(
                                    None,
                                    msg.into(),
                                    Urgency::Critical,
                                    None,
                                ));
                                msg = "Failed to get an IP address";
                                urgency = Urgency::Critical;
                            }
                            Ok(Err(e)) => {
                                let _ = action_tx.send(Actions::ShowToast(
                                    None,
                                    "Connection failed - check logs".into(),
                                    Urgency::Critical,
                                    None,
                                ));
                                error!("Connection failed: {}", e);
                            Ok(Err(_)) => {
                                msg = "Connection failed!";
                                urgency = Urgency::Critical;
                            }
                            Err(_) => {
                                let msg = "Operation timed out!";
                                msg = "Operation timed out!";
                                urgency = Urgency::Critical;
                                error!("{}", msg);
                                let _ = action_tx.send(Actions::ShowToast(
                                    None,
                                    msg.into(),
                                    Urgency::Critical,
                                    None,
                                ));
                            }
                        }
                        let _ = action_tx.send(Action::ShowToast(None, msg.into(), urgency, None));
                    });
                }
                Actions::Forget(ssid) => {
                Action::Forget(ssid) => {
                    let network_manager = app.network_manager.clone();
                    let action_tx = app.action.sender();
                    tokio::spawn(async move {
                        if let Err(e) = network_manager.forget(&ssid).await {
                            error!("Forget failed: {}", e);
                        if network_manager.forget(&ssid).await.is_err() {
                            let _ = action_tx.send(Action::ShowToast(
                                None,
                                "Forget failed!".into(),
                                Urgency::Critical,
                                None,
                            ));
                        }
                        let _ = action_tx.send(Actions::Refresh);
                        let _ = action_tx.send(Action::Refresh);
                    });
                }
                Actions::TogglePower => {
                // TODO: EditNetwork
                Action::EditNetwork(_) => {}
                Action::TogglePower => {
                    let network_manager = app.network_manager.clone();
                    let action_tx = app.action.sender();
                    tokio::spawn(async move {
                        let enabled = network_manager.nmrs.wifi_state().await.unwrap().enabled;
                        if let Err(e) = network_manager.nmrs.set_wireless_enabled(!enabled).await {
                            debug!("Toggle power failed: {}", e)
                        let msg;
                        let urgency;

                        if network_manager
                            .nmrs
                            .set_wireless_enabled(!enabled)
                            .await
                            .is_err()
                        {
                            msg = "Toggle power failed!".to_string();
                            urgency = Urgency::Critical;
                        } else {
                            msg = format!("Wifi {}", if !enabled { "On" } else { "Off" });
                            urgency = Urgency::Success;
                        };

                        let msg = format!("Wifi {}", if !enabled { "On" } else { "Off" });

                        debug!("{}!", msg);
                        let _ = action_tx.send(Actions::ShowToast(
                            None,
                            msg.into(),
                            Urgency::Warning,
                            None,
                        ));
                        let _ = action_tx.send(Actions::Refresh);
                        let _ = action_tx.send(Action::ShowToast(None, msg.into(), urgency, None));
                        let _ = action_tx.send(Action::Refresh);
                    });
                }
                Actions::Disconnect => {
                Action::Disconnect => {
                    let network_manager = app.network_manager.clone();
                    let action_tx = app.action.sender();
                    tokio::spawn(async move {
                        if let Err(e) = network_manager.disconnect().await {
                            error!("Disconnect failed: {}", e);
                        if network_manager.disconnect().await.is_err() {
                            let _ = action_tx.send(Action::ShowToast(
                                None,
                                "Disconnect failed!".into(),
                                Urgency::Critical,
                                None,
                            ));
                        }
                        let _ = action_tx.send(Actions::Refresh);
                        let _ = action_tx.send(Action::Refresh);
                    });
                }

                // UI
                Actions::NextItem(tab) => match tab {
                Action::NextItem(tab) => match tab {
                    Tabs::KnownNetworks => app.known_networks.next(),
                    Tabs::AvailableNetworks => app.available_networks.next(),
                    Tabs::Devices => app.devices.next(),
                },
                Actions::PreviousItem(tab) => match tab {
                Action::PreviousItem(tab) => match tab {
                    Tabs::KnownNetworks => app.known_networks.previous(),
                    Tabs::AvailableNetworks => app.available_networks.previous(),
                    Tabs::Devices => app.devices.previous(),
                },
                Actions::ShowToast(title, msg, urgency, duration) => {
                Action::ShowToast(title, msg, urgency, duration) => {
                    app.toasts.push(Toast::new(title, msg, urgency, duration));
                }
            }
diff --git a/src/app.rs b/src/app.rs
index a91f771..afb43d3 100644
--- a/src/app.rs
+++ b/src/app.rs
@@ -1,7 +1,7 @@
use std::time::Duration;

use crate::{
    action::{Action, Actions},
    action::{Action, ActionHandler},
    config::Config,
    network_manager::NetworkManager,
    timer::Timer,
@@ -20,6 +20,7 @@
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum Popups {
    Password,
    EditNetwork,
}

#[derive(Debug, Clone, Copy)]
@@ -31,12 +32,12 @@
#[derive(Clone)]
pub enum Selected {
    Network(Network),
    Device(WifiDevice),
    Device(()),
}

pub struct App {
    pub action: Action,
    pub config: Config,
    pub action: ActionHandler,
    pub _config: Config,
    pub network_manager: NetworkManager,
    pub should_quit: bool,

@@ -55,8 +56,8 @@
}

impl App {
    pub async fn new(config: Config) -> Result<Self> {
        let action = Action::new();
    pub async fn new(_config: Config) -> Result<Self> {
        let action = ActionHandler::new();
        let network_manager = NetworkManager::new().await?;

        let device_list = network_manager.get_devices().await?;
@@ -65,7 +66,7 @@

        Ok(Self {
            action,
            config,
            _config,
            network_manager,
            should_quit: false,

@@ -76,7 +77,7 @@
            toasts: Vec::new(),

            // Timers
            scan: Timer::new(Duration::from_secs(3), Actions::Refresh, true),
            scan: Timer::new(Duration::from_secs(3), Action::Refresh, true),

            known_networks: StatefulList::new(known_networks_list),
            available_networks: StatefulList::new(available_networks_list),
@@ -115,7 +116,7 @@
                    .state
                    .selected()
                    .and_then(|i| self.devices.items.get(i))
                    .map(|d| Selected::Device(d.clone())),
                    .map(|_d| Selected::Device(())),
            },
            Focus::Popup(_) => None,
        }
diff --git a/src/cli.rs b/src/cli.rs
index 0116d8a..c83ed1d 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -9,11 +9,13 @@
}

pub struct Cli {
    pub args: Args
    pub args: Args,
}

impl Cli {
    pub fn new() -> Self {
        Self { args: Args::parse() }
        Self {
            args: Args::parse(),
        }
    }
}
diff --git a/src/config.rs b/src/config.rs
index 2aa59f9..3daec83 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -10,13 +10,12 @@

#[derive(Deserialize, Serialize)]
#[serde(default)]
pub struct Config {
    pub int: u16,
}
pub struct Config {}

#[allow(clippy::derivable_impls)]
impl Default for Config {
    fn default() -> Self {
        Self { int: 1 }
        Self {}
    }
}

diff --git a/src/events.rs b/src/events.rs
index fcfffc6..5e9840a 100644
--- a/src/events.rs
+++ b/src/events.rs
@@ -1,11 +1,11 @@
use anyhow::{Ok, Result};
use crossterm::event::{KeyCode, KeyEvent};
use nmrs::WifiSecurity;
use nmrs::{SettingsPatch, WifiSecurity};

use crate::{
    action::Actions,
    action::Action,
    app::{App, Focus, Popups, Selected, Tabs},
    ui::input::InputMode,
    ui::{input::InputMode, toast::Urgency},
};

pub async fn handle_events(app: &mut App, key: KeyEvent) -> Result<()> {
@@ -18,7 +18,7 @@
async fn handle_tabs(app: &mut App, key: KeyEvent, tab: Tabs) -> Result<()> {
    match app.input.mode {
        InputMode::Normal => match key.code {
            KeyCode::Char('q') => app.action.send(Actions::Quit),
            KeyCode::Char('q') => app.action.send(Action::Quit),

            // Navigation
            KeyCode::Tab | KeyCode::Char('l') | KeyCode::Right => {
@@ -35,75 +35,103 @@
                    Tabs::Devices => Focus::Tab(Tabs::AvailableNetworks),
                };
            }
            KeyCode::Char('j') | KeyCode::Down => app.action.send(Actions::NextItem(tab)),
            KeyCode::Char('k') | KeyCode::Up => app.action.send(Actions::PreviousItem(tab)),
            KeyCode::Char('j') | KeyCode::Down => app.action.send(Action::NextItem(tab)),
            KeyCode::Char('k') | KeyCode::Up => app.action.send(Action::PreviousItem(tab)),

            KeyCode::Char('o') => {
                if tab == Tabs::Devices {
                    app.action.send(Actions::TogglePower);
                    app.action.send(Action::TogglePower);
                }
            }

            KeyCode::Char('r') => match tab {
                Tabs::AvailableNetworks | Tabs::KnownNetworks => {
                    app.action.send(Actions::Refresh);
                    app.action.send(Action::Refresh);
                }
                _ => {}
            },

            KeyCode::Enter | KeyCode::Char(' ') => {
                if let Focus::Tab(tab) = app.focus {
                    match tab {
                        Tabs::KnownNetworks => {
                            if let Some(Selected::Network(net)) = app.selected() {
                                let is_saved =
                                    app.network_manager.has_saved_connection(&net.ssid).await?;
                                if is_saved {
                                    match &app.network_manager.current_network().await {
                                        None => {
                                            app.action.send(Actions::Connect(
                                                net.ssid.to_string(),
                                                None,
                                                WifiSecurity::Open,
                                            ));
                                        }
            KeyCode::Enter | KeyCode::Char(' ') => match tab {
                Tabs::KnownNetworks => {
                    if let Some(Selected::Network(net)) = app.selected() {
                        match &app.network_manager.current_network().await {
                            None => {
                                app.action.send(Action::Connect(Box::new((
                                    net.ssid.to_string(),
                                    None,
                                    WifiSecurity::Open,
                                ))));
                            }

                                        Some(current) => {
                                            if current.ssid == net.ssid {
                                                app.action.send(Actions::Disconnect);
                                            } else {
                                                app.action.send(Actions::Connect(
                                                    net.ssid.to_string(),
                                                    None,
                                                    WifiSecurity::Open,
                                                ));
                                            }
                                        }
                                    }
                            Some(current) => match current.ssid == net.ssid {
                                true => {
                                    app.action.send(Action::Disconnect);
                                }
                            }
                        }
                        Tabs::AvailableNetworks => {
                            if let Some(Selected::Network(net)) = app.selected()
                                && net.is_psk
                            {
                                app.action
                                    .send(Actions::SetFocus(Focus::Popup(Popups::Password)));
                                app.action.send(Actions::SetInputMode(InputMode::Editing));
                            }
                                false => {
                                    app.action.send(Action::Connect(Box::new((
                                        net.ssid.to_string(),
                                        None,
                                        WifiSecurity::Open,
                                    ))));
                                }
                            },
                        }
                        Tabs::Devices => {}
                    }
                }
            }

            KeyCode::Char('f') => {
                if let Focus::Tab(tab) = app.focus
                    && tab == Tabs::KnownNetworks
                Tabs::AvailableNetworks => {
                    if let Some(Selected::Network(net)) = app.selected()
                        && net.is_psk
                    {
                        app.action
                            .send(Action::SetFocus(Focus::Popup(Popups::Password)));
                        app.action.send(Action::SetInputMode(InputMode::Editing));
                    }
                }

                Tabs::Devices => {}
            },

            KeyCode::Char('d') => {
                if tab == Tabs::KnownNetworks
                    && let Some(Selected::Network(net)) = app.selected()
                {
                    app.action.send(Actions::Forget(net.ssid.to_string()));
                    app.action.send(Action::Forget(net.ssid.to_string()));
                }
            }

            KeyCode::Char('c') => {
                // if tab == Tabs::KnownNetworks
                //     && let Some(Selected::Network(net)) = app.selected()
                //     && let Some(uuid) = app
                //         .network_manager
                //         .nmrs
                //         .get_saved_connection_uuid(&net.ssid)
                //         .await?
                // {
                //     let saved_conn = app.network_manager.nmrs.get_saved_connection(&uuid).await?;
                //     let mut patch = SettingsPatch::default();
                //     patch.autoconnect = Some(!saved_conn.autoconnect);
                //     app.network_manager
                //         .nmrs
                //         .update_saved_connection(&uuid, patch)
                //         .await?;
                //     app.action.send(Action::ShowToast(
                //         None,
                //         format!("{}", !saved_conn.autoconnect).into(),
                //         Urgency::Success,
                //         None,
                //     ));
                //     app.action
                //          .send(Action::SetFocus(Focus::Popup(Popups::EditNetwork)));
                //     app.action.send(Action::SetInputMode(InputMode::Editing));
                // }
                app.action.send(Action::ShowToast(
                    None,
                    "WIP".into(),
                    Urgency::Critical,
                    None,
                ));
            }
            _ => {}
        },
@@ -118,15 +146,15 @@
        InputMode::Editing => match key.code {
            KeyCode::Enter => {
                if let Some(Selected::Network(net)) = app.selected() {
                    app.action.send(Actions::Connect(
                    app.action.send(Action::Connect(Box::new((
                        net.ssid.to_string(),
                        None,
                        WifiSecurity::WpaPsk {
                            psk: app.input.value.clone(),
                        },
                    ));
                    app.action.send(Actions::SetInputMode(InputMode::Normal));
                    app.action.send(Actions::SetFocus(app.last_focus));
                    ))));
                    app.action.send(Action::SetInputMode(InputMode::Normal));
                    app.action.send(Action::SetFocus(app.last_focus));
                    app.scan.enabled = true;
                }
            }
@@ -140,8 +168,8 @@
            KeyCode::Left => app.input.move_cursor_left(),
            KeyCode::Right => app.input.move_cursor_right(),
            KeyCode::Esc => {
                app.action.send(Actions::SetInputMode(InputMode::Normal));
                app.action.send(Actions::SetFocus(app.last_focus));
                app.action.send(Action::SetInputMode(InputMode::Normal));
                app.action.send(Action::SetFocus(app.last_focus));
                // app.scan.enabled = true;
            }
            _ => {}
diff --git a/src/logger.rs b/src/logger.rs
index 0704120..2842174 100644
--- a/src/logger.rs
+++ b/src/logger.rs
@@ -1,16 +1,13 @@
use anyhow::Result;
use crossterm::ExecutableCommand;
use crossterm::terminal::{LeaveAlternateScreen, disable_raw_mode};
use log::LevelFilter;
use log::{LevelFilter, logger};
use simplelog::{CombinedLogger, Config, WriteLogger};
use std::fs::File;
use std::io::stdout;
use std::panic;
use std::path::PathBuf;
use std::{env, fs};

pub fn init() -> Result<()> {
    let level = match env::var("RUST_LOG")
    let level = match env::var("NMRS_LOG")
        .unwrap_or_default()
        .to_lowercase()
        .as_str()
@@ -30,9 +27,8 @@
    let default_hook = panic::take_hook();
    panic::set_hook(Box::new(move |panic_info| {
        error!("APPLICATION PANIC: {}", panic_info);
        logger().flush();

        let _ = disable_raw_mode_internal();

        default_hook(panic_info);
    }));

@@ -46,10 +42,4 @@
    let dir = base.join("nmrs-tui");
    fs::create_dir_all(&dir).expect("Failed to create log dir");
    dir.join("nmrs-tui.log")
}

fn disable_raw_mode_internal() -> Result<()> {
    disable_raw_mode()?;
    stdout().execute(LeaveAlternateScreen)?;
    Ok(())
}
diff --git a/src/main.rs b/src/main.rs
index accfe0b..e0567f7 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -4,18 +4,19 @@
extern crate log;
extern crate simplelog;

mod action;
mod app;
mod cli;
mod config;
mod events;
mod logger;
mod network_manager;
mod timer;
mod tui;
mod ui;
mod action;
mod timer;

use app::App;
use log::logger;
use tui::Tui;

use crate::{cli::Cli, config::Config};
@@ -33,7 +34,13 @@
        let mut tui = Tui::new()?;

        // Start TUI
        tui.run(&mut app).await?;
        if let Err(e) = tui.run(&mut app).await {
            tui.cleanup()?;

            error!("Fatal error: {:#}", e);
            logger().flush();
            return Err(e);
        }
    }

    Ok(())
diff --git a/src/network_manager.rs b/src/network_manager.rs
index 0fba6ff..2784289 100644
--- a/src/network_manager.rs
+++ b/src/network_manager.rs
@@ -1,5 +1,6 @@
use std::time::Duration;
use std::{cmp::Reverse, time::Duration};

use anyhow::Context;
use nmrs::{ConnectionError, Network, SavedConnection, WifiDevice, WifiSecurity};
use tokio::time::{self, timeout};

@@ -30,10 +31,13 @@
    }

    pub async fn scan_networks(&self) -> anyhow::Result<Vec<Network>> {
        self.nmrs.scan_networks(None).await?;
        self.nmrs
            .scan_networks(None)
            .await
            .context("Failed to trigger WiFi scan via NetworkManager")?;

        let mut networks = self.nmrs.list_networks(None).await?;
        networks.sort_by(|a, b| b.strength.cmp(&a.strength));
        networks.sort_by_key(|b| Reverse(b.strength));
        Ok(networks)
    }

@@ -44,7 +48,7 @@
        let mut new_final = Vec::new();

        for net in &scan_list {
            if self.has_saved_connection(&net.ssid).await? {
            if net.known {
                known_final.push(net.clone());
            } else {
                new_final.push(net.clone());
@@ -61,6 +65,7 @@
        self.nmrs.forget(ssid).await
    }

    // TODO: auto connect.
    pub async fn connect(
        &self,
        ssid: &str,
@@ -78,6 +83,7 @@
        self.nmrs.is_connected(ssid).await
    }

    #[allow(dead_code)]
    pub async fn has_saved_connection(&self, ssid: &str) -> Result<bool, ConnectionError> {
        self.nmrs.has_saved_connection(ssid).await
    }
diff --git a/src/timer.rs b/src/timer.rs
index 8639614..73be6c3 100644
--- a/src/timer.rs
+++ b/src/timer.rs
@@ -1,16 +1,17 @@
use std::time::Duration;

use crate::action::Actions;
use crate::action::Action;

pub struct Timer {
    pub duration: Duration,
    pub remaining: Duration,
    pub on_finish: Actions,
    pub on_finish: Action,
    pub enabled: bool,
}

#[allow(dead_code)]
impl Timer {
    pub fn new(duration: Duration, on_finish: Actions, enabled: bool) -> Self {
    pub fn new(duration: Duration, on_finish: Action, enabled: bool) -> Self {
        Self {
            duration,
            remaining: duration,
diff --git a/src/tui.rs b/src/tui.rs
index 9bdd05a..5aced65 100644
--- a/src/tui.rs
+++ b/src/tui.rs
@@ -1,32 +1,31 @@
use anyhow::{Ok, Result};
use crossterm::{
    ExecutableCommand,
    event::{self, Event},
    event::{Event, EventStream},
    terminal::{self, LeaveAlternateScreen, disable_raw_mode, enable_raw_mode},
};

use ratatui::{
    Terminal,
    Frame, Terminal,
    backend::CrosstermBackend,
    layout::{Constraint, Direction, Layout},
};
use std::{
    io::stdout,
    time::{self},
};
use std::{io::stdout, time::Duration};
use tokio::time;
use tokio_stream::StreamExt;

use crate::{
    action::{Action, Actions},
    action::{Action, ActionHandler},
    app::{App, Focus, Popups, Selected},
    events,
    ui::{
        help,
        popup, table,
        help, popup, table,
        toast::{self, Urgency},
    },
};

pub struct Tui {
    pub terminal: Terminal<CrosstermBackend<std::io::Stdout>>,
    pub should_render: bool,
}

impl Tui {
@@ -40,79 +39,99 @@
        let backend = CrosstermBackend::new(stdout);
        let terminal = Terminal::new(backend)?;

        Ok(Tui { terminal })
        Ok(Tui {
            terminal,
            should_render: true,
        })
    }

    pub async fn run(&mut self, app: &mut App) -> Result<()> {
    pub async fn run(&mut self, app: &mut App) -> anyhow::Result<()> {
        let mut reader = EventStream::new();
        let mut last_tick = time::Instant::now();
        let tick_rate = Duration::from_secs(1);

        while !app.should_quit {
            self.terminal.draw(|f| {
                let size = f.area();

                let main_chunks = Layout::default()
                    .direction(Direction::Vertical)
                    .constraints([Constraint::Length(1), Constraint::Min(0)])
                    .split(size);

                let body_chunks = Layout::new(
                    Direction::Vertical,
                    [
                        Constraint::Percentage(45),
                        Constraint::Percentage(45),
                        Constraint::Percentage(10),
                        Constraint::Length(1),
                    ],
                )
                .split(main_chunks[1]);

                table::draw_known_network(f, &body_chunks, app);
                table::draw_available_network(f, &body_chunks, app);
                table::draw_devices(f, &body_chunks, app);
                help::draw(f, body_chunks[3], app.focus);

                if let Focus::Popup(popup) = app.focus {
                    match popup {
                        Popups::Password => {
                            if let Some(Selected::Network(net)) = app.selected() {
                                popup::draw_auth(f, &app.input, net, app.input.hidden_password)
                            } else {
                                app.action.send(Actions::ShowToast(
                                    None,
                                    "Can't find selected network".into(),
                                    Urgency::Critical,
                                    None,
                                ));
                                app.action.send(Actions::SetFocus(app.last_focus));
                            }
                        }
            if self.should_render {
                self.terminal.draw(|f| {
                    Self::draw(f, app);
                })?;
                self.should_render = false;
            }

            // Render when needed
            tokio::select! {
                // Render & Handle events
                maybe_event = reader.next() => {
                    if let Some(Ok(Event::Key(key))) = maybe_event {
                        events::handle_events(app, key).await?;
                        info!("Event: {:?}!", key);
                        self.should_render = true;
                    }
                }

                toast::draw(f, &app.toasts);
            })?;
                // Render when there no action or event
                _ = time::sleep(tick_rate.saturating_sub(last_tick.elapsed())) => {
                    info!("Ticks!");
                    self.should_render = true;
                }
            }

            let now = time::Instant::now();
            let delta = now.saturating_duration_since(last_tick);
            last_tick = now;
            app.action.send(Action::Tick(delta));

            app.action.send(Actions::Tick(delta));
            ActionHandler::handle_actions(app).await?;
        }

            Action::handle_actions(app).await?;
        self.cleanup()?;
        Ok(())
    }

            if event::poll(std::time::Duration::from_millis(200))?
                && let Event::Key(key) = event::read()?
            {
                events::handle_events(app, key).await?;
    fn draw(f: &mut Frame, app: &mut App) {
        let size = f.area();

        let chunks = Layout::new(
            Direction::Vertical,
            [
                Constraint::Percentage(50), // Known Networks
                Constraint::Percentage(50), // Available Networks
                Constraint::Min(5),         // Devices
                Constraint::Length(1),      // Help
            ],
        )
        .split(size);

        table::draw_known_network(f, chunks[0], app);
        table::draw_available_network(f, chunks[1], app);
        table::draw_devices(f, chunks[2], app);
        help::draw(f, chunks[3], app.focus);

        if let Focus::Popup(popup) = app.focus {
            match popup {
                Popups::Password => {
                    if let Some(Selected::Network(net)) = app.selected() {
                        popup::draw_auth(f, &app.input, net)
                    } else {
                        app.action.send(Action::ShowToast(
                            None,
                            "Can't find selected network".into(),
                            Urgency::Critical,
                            None,
                        ));
                        app.action.send(Action::SetFocus(app.last_focus));
                    }
                }

                Popups::EditNetwork => {}
            }
        }

        self.cleanup()?;
        Ok(())
        toast::draw(f, &app.toasts);
    }

    // terminal cleanup
    fn cleanup(&mut self) -> Result<()> {
    pub fn cleanup(&mut self) -> anyhow::Result<()> {
        disable_raw_mode()?;
        self.terminal.backend_mut().execute(LeaveAlternateScreen)?;
        self.terminal.show_cursor()?;
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 0000000..098418d 100644
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -1,0 +1,25 @@
name: CI

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  ci:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - uses: dtolnay/rust-toolchain@stable
        with:
          components: rustfmt, clippy

      - uses: Swatinem/rust-cache@v2

      - name: Format
        run: cargo fmt --all

      - name: Lint
        run: cargo clippy --all-targets --all-features -- -D warnings
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
new file mode 100644
index 0000000..9b37f25 100644
--- /dev/null
+++ b/.github/workflows/release.yml
@@ -1,0 +1,74 @@
name: Release

on:
  push:
    tags:
      - "v*"

jobs:
  build:
    name: Build ${{ matrix.target }}
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        include:
          - target: x86_64-unknown-linux-gnu
            os: ubuntu-latest
            binary: nmrs-tui
            asset: nmrs-tui-x86_64-linux

          - target: aarch64-unknown-linux-gnu
            os: ubuntu-latest
            binary: nmrs-tui
            asset: nmrs-tui-aarch64-linux

    steps:
      - uses: actions/checkout@v4

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          targets: ${{ matrix.target }}

      - name: Install cross
        run: cargo install cross

      - name: Build
        run: cross build --release --target ${{ matrix.target }}

      - name: Rename binary
        run: cp target/${{ matrix.target }}/release/${{ matrix.binary }} ${{ matrix.asset }}

      - name: Upload artifact
        uses: actions/upload-artifact@v4
        with:
          name: ${{ matrix.asset }}
          path: ${{ matrix.asset }}

  release:
    name: Create Release
    needs: build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Download all artifacts
        uses: actions/download-artifact@v4
        with:
          path: artifacts
          merge-multiple: true

      - name: Get changelog entry
        id: changelog
        run: |
          VERSION=${GITHUB_REF#refs/tags/v}
          NOTES=$(awk "/## \[$VERSION\]/{flag=1; next} /## \[/{flag=0} flag" CHANGELOG.md)
          echo "notes<<EOF" >> $GITHUB_OUTPUT
          echo "$NOTES" >> $GITHUB_OUTPUT
          echo "EOF" >> $GITHUB_OUTPUT

      - name: Upload to GitHub Release
        uses: softprops/action-gh-release@v2
        with:
          body: ${{ steps.changelog.outputs.notes }}
          files: artifacts/*
diff --git a/src/ui/help.rs b/src/ui/help.rs
index 91ee041..309b690 100644
--- a/src/ui/help.rs
+++ b/src/ui/help.rs
@@ -10,21 +10,24 @@
pub fn draw(f: &mut Frame, area: Rect, focus: Focus) {
    let help_msg = match focus {
        Focus::Tab(tab) => match tab {
            Tabs::KnownNetworks => 
                "k,  Up | j,  Down | 󱁐  or ↵  Dis/connect | a Show All | d Remove | t Autoconnect | r Scan | p Share | ⇄ Nav",
            
            Tabs::AvailableNetworks => 
                "k,  Up | j,  Down | 󱁐  or ↵  Connect | r Scan | ⇄ Nav",
            
            Tabs::KnownNetworks => {
                "k,  Up | j,  Down | 󱁐  or ↵  Dis/connect | d Forget | c Edit | r Scan | ⇄ Nav"
            }

            Tabs::AvailableNetworks => "k,  Up | j,  Down | 󱁐  or ↵  Connect | r Scan | ⇄ Nav",

            Tabs::Devices => "r Scan | i Infos | o Toggle Power | ⇄ Nav",
        },
        Focus::Popup(popup) => match popup {
            Popups::Password => "↵  Apply | ⇄ Hide/Show password | 󱊷  Discard",
            Popups::EditNetwork => "wip",
        },
    };

    f.render_widget(
        Paragraph::new(help_msg).alignment(Alignment::Center).style(Style::new().blue()),
        Paragraph::new(help_msg)
            .alignment(Alignment::Center)
            .style(Style::new().blue()),
        area,
    );
}
diff --git a/src/ui/input.rs b/src/ui/input.rs
index c3a4398..ddd9f66 100644
--- a/src/ui/input.rs
+++ b/src/ui/input.rs
@@ -8,7 +8,7 @@
    pub mode: InputMode,
    pub value: String,
    pub hidden_password: bool,
    // cursor postion x.
    /// Cursor postion x.
    pub cx: usize,
}

diff --git a/src/ui/list.rs b/src/ui/list.rs
index b08d4e6..7168aa5 100644
--- a/src/ui/list.rs
+++ b/src/ui/list.rs
@@ -8,10 +8,7 @@
    pub fn new(items: Vec<T>) -> Self {
        let mut state = TableState::default();
        state.select_first();
        Self {
            state,
            items,
        }
        Self { state, items }
    }

    pub fn set_items(&mut self, items: Vec<T>) {
diff --git a/src/ui/mod.rs b/src/ui/mod.rs
index 75ad7aa..6b64e5d 100644
--- a/src/ui/mod.rs
+++ b/src/ui/mod.rs
@@ -25,59 +25,116 @@
}

#[derive(Default)]
pub struct Gaps {
pub struct Margin {
    top: u16,
    bottom: u16,
    left: u16,
    right: u16,
}

#[allow(dead_code)]
impl Margin {
    pub fn new(value: u16) -> Self {
        Self {
            top: value,
            bottom: value,
            left: value,
            right: value,
        }
    }

    pub fn horizontal(mut self, value: u16) -> Self {
        self.left = value;
        self.right = value;
        self
    }

    pub fn vertical(mut self, value: u16) -> Self {
        self.top = value;
        self.bottom = value;
        self
    }

    pub fn top(mut self, value: u16) -> Self {
        self.top = value;
        self
    }

    pub fn bottom(mut self, value: u16) -> Self {
        self.bottom = value;
        self
    }

    pub fn left(mut self, value: u16) -> Self {
        self.left = value;
        self
    }

    pub fn right(mut self, value: u16) -> Self {
        self.right = value;
        self
    }
}

// calculate area position
pub fn position_rect(
pub fn anchor_rect(
    area: Rect,
    mut width: u16,
    mut height: u16,
    position: Position,
    gaps: Gaps,
    margin: Margin,
) -> Rect {
    // Make sure that it does not pass the area width and height to prevent crash.
    width = width.min(area.width);
    height = height.min(area.height);

    let x = match position {
        Position::LeftTop | Position::LeftCenter | Position::LeftBottom => {
            0_u16.saturating_add(gaps.left).saturating_sub(gaps.right)
        }
        Position::LeftTop | Position::LeftCenter | Position::LeftBottom => 0_u16
            .saturating_add(margin.left)
            .saturating_sub(margin.right),

        Position::Top | Position::Center | Position::Bottom => (area.width.saturating_sub(width)
            / 2)
        .saturating_add(gaps.left)
        .saturating_sub(gaps.right),
        .saturating_add(margin.left)
        .saturating_sub(margin.right),

        Position::RightTop | Position::RightCenter | Position::RightBottom => area
            .width
            .saturating_sub(width)
            .saturating_add(gaps.left)
            .saturating_sub(gaps.right),
            .saturating_add(margin.left)
            .saturating_sub(margin.right),
    };

    let y = match position {
        Position::LeftTop | Position::Top | Position::RightTop => {
            0_u16.saturating_add(gaps.top).saturating_sub(gaps.bottom)
        }
        Position::LeftTop | Position::Top | Position::RightTop => 0_u16
            .saturating_add(margin.top)
            .saturating_sub(margin.bottom),

        Position::LeftCenter | Position::Center | Position::RightCenter => {
            (area.height.saturating_sub(height) / 2)
                .saturating_add(gaps.top)
                .saturating_sub(gaps.bottom)
                .saturating_add(margin.top)
                .saturating_sub(margin.bottom)
        }

        Position::LeftBottom | Position::Bottom | Position::RightBottom => area
            .height
            .saturating_sub(height)
            .saturating_add(gaps.top)
            .saturating_sub(gaps.bottom),
            .saturating_add(margin.top)
            .saturating_sub(margin.bottom),
    };

    Rect::new(x, y, width, height)
}

pub fn fill_rect(area: Rect, margin: Margin) -> Rect {
    Rect::new(
        area.x.saturating_add(margin.left),
        area.y.saturating_add(margin.top),
        area.width
            .saturating_sub(margin.left)
            .saturating_sub(margin.right),
        area.height
            .saturating_sub(margin.top)
            .saturating_sub(margin.bottom),
    )
}
diff --git a/src/ui/popup.rs b/src/ui/popup.rs
index 609975b..d36ed9d 100644
--- a/src/ui/popup.rs
+++ b/src/ui/popup.rs
@@ -7,33 +7,25 @@
    widgets::{self, Block, BorderType, Paragraph},
};

use crate::
    ui::{self, Gaps, Position, input::Input}
;
use crate::ui::{self, Margin, Position, input::Input};

#[derive(Default)]
pub struct Options {
    /// width of the popup.
    pub width: u16,

    /// height of the popup.
    pub height: u16,

    /// position of the popup.
    pub position: Position,

    /// gaps of the popup.
    pub gaps: Gaps,
    pub margin: Margin,
}

pub fn popup_area(f: &mut Frame, opt: Options) -> Rect {
    let area = ui::position_rect(f.area(), opt.width, opt.height, opt.position, opt.gaps);
pub fn popup_rect(f: &mut Frame, opt: Options) -> Rect {
    let area = ui::anchor_rect(f.area(), opt.width, opt.height, opt.position, opt.margin);
    f.render_widget(widgets::Clear, area); // Clear the area behind it
    area
}

pub fn draw_auth(f: &mut Frame, input: &Input, network: Network, hidden_password: bool) {
    let popup_area = popup_area(
// TODO: padding.
pub fn draw_auth(f: &mut Frame, input: &Input, network: Network) {
    let popup_rect = popup_rect(
        f,
        Options {
            width: 60,
@@ -54,12 +46,12 @@
    .alignment(Alignment::Center);

    let title_widget = Paragraph::new(title).block(block);
    f.render_widget(title_widget, popup_area);
    f.render_widget(title_widget, popup_rect);

    let input_area = Rect::new(
        popup_area.x + 1,
        popup_area.y + 3,
        popup_area.width.saturating_sub(2),
        popup_rect.x + 1,
        popup_rect.y + 3,
        popup_rect.width.saturating_sub(2),
        1,
    );

@@ -69,7 +61,7 @@
    ])
    .split(input_area);

    let (password, icon): (String, &'static str) = if hidden_password {
    let (password, icon): (String, &'static str) = if input.hidden_password {
        (input.value.chars().map(|_| '*').collect(), " 󰈉  ")
    } else {
        (input.value.to_string(), " 󰈈   ")
@@ -81,7 +73,10 @@
    let icon_widget = Paragraph::new(icon).style(Style::new().green());
    f.render_widget(icon_widget, input_chunks[1]);

    // Cursor position x
    let cx = input_chunks[0].x + input.cx as u16;
    let cx_max = input_chunks[0].x + input_chunks[0].width.saturating_sub(1) as u16;

    // cx_max = position + width - 1 (so the cursor does overlap on eye icon) 
    let cx_max = input_chunks[0].x + input_chunks[0].width.saturating_sub(1); 
    f.set_cursor_position(layout::Position::new(cx.min(cx_max), input_chunks[0].y))
}
diff --git a/src/ui/table.rs b/src/ui/table.rs
index 1da2a17..0719b28 100644
--- a/src/ui/table.rs
+++ b/src/ui/table.rs
@@ -1,8 +1,6 @@
use std::rc::Rc;

use crate::{
    app::{App, Focus, Tabs},
    ui::list::StatefulList,
    ui::{self, Margin, list::StatefulList},
};
use nmrs::DeviceState;
use ratatui::{
@@ -18,19 +16,19 @@
}

pub fn draw<Any>(f: &mut Frame, area: Rect, table_data: &mut TableData<Any>, is_active: bool) {
    let border_style = if is_active {
    let border_style: Style = if is_active {
        Style::new().bold().green()
    } else {
        Style::new()
    };

    let border_type = if is_active {
    let border_type: BorderType = if is_active {
        BorderType::Thick
    } else {
        BorderType::Plain
    };

    let header_style = if is_active {
    let header_style: Style = if is_active {
        Style::new().bold().yellow()
    } else {
        Style::new()
@@ -54,58 +52,8 @@

    f.render_stateful_widget(table, area, &mut table_data.list.state);
}

// TODO: this
// pub fn draw_saved_connections(
//     f: &mut Frame<'_>,
//     body_chunks: &Rc<[Rect]>,
//     app: &mut App,
// ) {
//     let rows: Vec<Row> = app
//         .known_networks
//         .items
//         .iter()
//         .map(|net| -> Row<'_> {
//             Row::new(vec![
//                 Line::from(net.ssid.clone()).centered(),
//                 Line::from(if net.secured { "Secured" } else { "Open" }).centered(),
//                 Line::from(if app.network_manager.is_connected_cached(&net.ssid) {
//                     "Connected"
//                 } else {
//                     "-"
//                 }).centered(),
//                 Line::from(format!("{}%", net.strength.unwrap_or(0))).centered(),
//             ])
//         })
//         .collect();
//     draw(
//         f,
//         body_chunks[0],
//         &mut TableData {
//             title: " Known Networks ",
//             header_cols: vec![
//                 Line::from("Name").centered(),
//                 Line::from("Security").centered(),
//                 Line::from("State").centered(),
//                 Line::from("Signal").centered()
//             ],
//             constraint: vec![
//                 Constraint::Percentage(40),
//                 Constraint::Percentage(20),
//                 Constraint::Percentage(20),
//                 Constraint::Percentage(20),
//             ],
//             cells: rows,
//             list: &mut app.known_networks,
//         },
//     );
// }

pub fn draw_known_network(
    f: &mut Frame<'_>,
    body_chunks: &Rc<[Rect]>,
    app: &mut App,
) {
pub fn draw_known_network(f: &mut Frame<'_>, area: Rect, app: &mut App) {
    let active = if let Focus::Tab(tab) = app.focus
        && tab == Tabs::KnownNetworks
    {
@@ -149,25 +97,33 @@
            Row::new(vec![
                Line::from(net.ssid.clone()).centered(),
                Line::from(security).centered(),
                Line::from(if app.network_manager.current_network.as_ref().is_some_and(|current| current.ssid == net.ssid) {
                    "Connected"
                } else {
                    "-"
                }).centered(),
                Line::from(
                    if app
                        .network_manager
                        .current_network
                        .as_ref()
                        .is_some_and(|current| current.ssid == net.ssid)
                    {
                        "Connected"
                    } else {
                        "-"
                    },
                )
                .centered(),
                Line::from(format!("{}% {}", strength, bars)).centered(),
            ])
        })
        .collect();
    draw(
        f,
        body_chunks[0],
        ui::fill_rect(area, Margin::new(0).horizontal(1).top(1)),
        &mut TableData {
            title: " Known Networks ",
            header_cols: vec![
                Line::from("Name").centered(),
                Line::from("Security").centered(),
                Line::from("State").centered(),
                Line::from("Signal").centered()
                Line::from("Signal").centered(),
            ],
            constraint: vec![
                Constraint::Percentage(40),
@@ -182,11 +138,7 @@
    );
}

pub fn draw_available_network(
    f: &mut Frame<'_>,
    body_chunks: &Rc<[Rect]>,
    app: &mut App,
) {
pub fn draw_available_network(f: &mut Frame<'_>, area: Rect, app: &mut App) {
    let active = if let Focus::Tab(tab) = app.focus
        && tab == Tabs::AvailableNetworks
    {
@@ -235,13 +187,13 @@
        .collect();
    draw(
        f,
        body_chunks[1],
        ui::fill_rect(area, Margin::new(0).horizontal(1)),
        &mut TableData {
            title: " Available Networks ",
            header_cols: vec![
                Line::from("Name").centered(),
                Line::from("Security").centered(),
                Line::from("Signal").centered()
                Line::from("Signal").centered(),
            ],
            constraint: vec![
                Constraint::Percentage(40),
@@ -255,7 +207,7 @@
    );
}

pub fn draw_devices(f: &mut Frame<'_>, body_chunks: &Rc<[Rect]>, app: &mut App) {
pub fn draw_devices(f: &mut Frame<'_>, area: Rect, app: &mut App) {
    let active = if let Focus::Tab(tab) = app.focus
        && tab == Tabs::Devices
    {
@@ -276,11 +228,25 @@

            Row::new(vec![
                Line::from(dev.interface.clone()).centered(),
                Line::from(if matches!(dev.state, DeviceState::Disconnected | DeviceState::Activated | DeviceState::Prepare | DeviceState::Config | DeviceState::NeedAuth | DeviceState::IpConfig | DeviceState::IpCheck | DeviceState::Secondaries | DeviceState::Deactivating) {
                    "On"
                } else {
                    "Off"
                }).centered(),
                Line::from(
                    if matches!(
                        dev.state,
                        DeviceState::Disconnected
                            | DeviceState::Activated
                            | DeviceState::Prepare
                            | DeviceState::Config
                            | DeviceState::NeedAuth
                            | DeviceState::IpConfig
                            | DeviceState::IpCheck
                            | DeviceState::Secondaries
                            | DeviceState::Deactivating
                    ) {
                        "On"
                    } else {
                        "Off"
                    },
                )
                .centered(),
                Line::from(format!("{}", dev.state)).centered(),
                Line::from(freq).centered(),
                Line::from(dev.hw_address.to_string()).centered(),
@@ -289,7 +255,7 @@
        .collect();
    draw(
        f,
        body_chunks[2],
        ui::fill_rect(area, Margin::new(0).horizontal(1)),
        &mut TableData {
            title: " Devices ",
            header_cols: vec![
diff --git a/src/ui/toast.rs b/src/ui/toast.rs
index 92df122..22943ff 100644
--- a/src/ui/toast.rs
+++ b/src/ui/toast.rs
@@ -9,11 +9,12 @@
};

use crate::ui::{
    Gaps, Position,
    Margin, Position,
    popup::{self, Options},
};

#[derive(Clone, Copy, PartialEq)]
#[allow(dead_code)]
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum Urgency {
    Normal,
    Success,
@@ -65,13 +66,13 @@

pub fn draw(f: &mut Frame, toasts: &[Toast]) {
    for (index, toast) in toasts.iter().enumerate() {
        let area = popup::popup_area(
        let area = popup::popup_rect(
            f,
            Options {
                width: 3 + toast.msg.chars().count() as u16,
                height: 4,
                width: 4 + toast.msg.chars().count() as u16, // 4 = borders(2) + padding(2)
                height: 4,                                   // 4 = borders(2) + title(1) + msg(1)
                position: Position::RightTop,
                gaps: Gaps {
                margin: Margin {
                    top: 1 + (index as u16 * 4),
                    right: 1,
                    ..Default::default()
@@ -96,7 +97,7 @@
        let title = Line::raw(toast.title.as_ref())
            .style(title_style.bold())
            .alignment(Alignment::Center);
        let msg = Line::raw(toast.msg.as_ref());
        let msg = Line::raw(toast.msg.as_ref()).alignment(Alignment::Center);

        let block = Block::bordered()
            .border_style(border_style)