← recipes

Commit 6f7f7b84

2
files
+106
added
-28
deleted
@@ -5,6 +5,9 @@
5 5 # systemie. Bez zależności poza nmcli (jest w NetworkManagerze) i xfce4-terminal
6 6 # jako hostem okna.
7 7 #
8 +# Komunikaty są dwujęzyczne (PL/EN) – język wybierany z LC_ALL/LC_MESSAGES/LANG,
9 +# domyślnie angielski (gdy język nieustawiony).
10 +#
8 11 # Tryby:
9 12 # pagan-wifi – interaktywny wybór sieci
10 13 # pagan-wifi --list – sama lista wykrytych sieci (do diagnostyki/testów)
@@ -12,8 +15,83 @@
12 15
13 16 set -u
14 17
15 -# Terse output nmcli jest stabilny maszynowo, ale komunikaty dla użytkownika
16 -# zostawiamy po polsku (piszemy je sami, nie tłumaczymy nmcli).
18 +# ── Język (PL/EN) ───────────────────────────────────────────────────────────
19 +_pw_detect_lang() {
20 + _l="${LC_ALL:-${LC_MESSAGES:-${LANG:-}}}"
21 + case "$_l" in
22 + pl|pl_*|pl.*|PL|PL_*|PL.*) printf '%s' pl ;;
23 + *) printf '%s' en ;;
24 + esac
25 +}
26 +PW_LANG="$(_pw_detect_lang)"
27 +
28 +# t <klucz> – tekst interfejsu w wybranym języku (nieznany klucz = sam klucz).
29 +t() {
30 + if [ "$PW_LANG" = en ]; then
31 + case "$1" in
32 + status_ifaces) printf '%s' "=== Interfaces (nmcli device) ===" ;;
33 + status_ips) printf '%s' "=== IP addresses ===" ;;
34 + status_conn) printf '%s' "=== Connectivity ===" ;;
35 + inet_ok) printf '%s' "Internet: OK (1.1.1.1 replies)" ;;
36 + inet_fail) printf '%s' "Internet: no reply from 1.1.1.1" ;;
37 + prompt_pass) printf '%s' 'Password for "%s" (hidden): ' ;;
38 + connecting) printf '%s' 'Connecting to "%s"...' ;;
39 + connected) printf '%s' "Connected." ;;
40 + connect_fail) printf '%s' "Could not connect. Check the password or try again." ;;
41 + no_nmcli) printf '%s' "nmcli not found. Install/start NetworkManager: sudo systemctl start NetworkManager" ;;
42 + no_iface) printf '%s' "No Wi-Fi adapter detected." ;;
43 + no_iface_hint1) printf '%s' "Check the adapter is visible: lsusb / ip link" ;;
44 + no_iface_hint2) printf '%s' "And that its driver loaded: dmesg | grep -i firmware" ;;
45 + iface) printf '%s' "Wi-Fi adapter: %s" ;;
46 + scanning) printf '%s' "Scanning for networks (this may take a moment)..." ;;
47 + no_networks) printf '%s' "No Wi-Fi networks found." ;;
48 + choose) printf '%s' 'Select a network number (or "q" to quit): ' ;;
49 + bad_choice) printf '%s' "Invalid choice." ;;
50 + no_such) printf '%s' "No network number %s." ;;
51 + help_title) printf '%s' "pagan-wifi - choose a Wi-Fi network (NetworkManager)" ;;
52 + help_usage) printf '%s' " pagan-wifi interactive network chooser" ;;
53 + help_list) printf '%s' " pagan-wifi --list list detected networks" ;;
54 + help_status) printf '%s' " pagan-wifi --status interface state and IP addresses" ;;
55 + *) printf '%s' "$1" ;;
56 + esac
57 + else
58 + case "$1" in
59 + status_ifaces) printf '%s' "=== Interfejsy (nmcli device) ===" ;;
60 + status_ips) printf '%s' "=== Adresy IP ===" ;;
61 + status_conn) printf '%s' "=== Łączność ===" ;;
62 + inet_ok) printf '%s' "Internet: OK (1.1.1.1 odpowiada)" ;;
63 + inet_fail) printf '%s' "Internet: brak odpowiedzi z 1.1.1.1" ;;
64 + prompt_pass) printf '%s' 'Hasło do "%s" (nie będzie widoczne): ' ;;
65 + connecting) printf '%s' 'Łączenie z "%s"...' ;;
66 + connected) printf '%s' "Połączono." ;;
67 + connect_fail) printf '%s' "Nie udało się połączyć. Sprawdź hasło albo spróbuj ponownie." ;;
68 + no_nmcli) printf '%s' "Brak polecenia nmcli. Zainstaluj/uruchom NetworkManager: sudo systemctl start NetworkManager" ;;
69 + no_iface) printf '%s' "Nie wykryto karty Wi-Fi." ;;
70 + no_iface_hint1) printf '%s' "Sprawdź, czy adapter jest widoczny: lsusb / ip link" ;;
71 + no_iface_hint2) printf '%s' "Oraz czy sterownik się załadował: dmesg | grep -i firmware" ;;
72 + iface) printf '%s' "Karta Wi-Fi: %s" ;;
73 + scanning) printf '%s' "Szukam sieci (chwilę to potrwa)..." ;;
74 + no_networks) printf '%s' "Nie znaleziono żadnej sieci Wi-Fi." ;;
75 + choose) printf '%s' 'Numer sieci (lub "q" aby wyjść): ' ;;
76 + bad_choice) printf '%s' "Niepoprawny wybór." ;;
77 + no_such) printf '%s' "Nie ma sieci o numerze %s." ;;
78 + help_title) printf '%s' "pagan-wifi – wybór sieci Wi-Fi (NetworkManager)" ;;
79 + help_usage) printf '%s' " pagan-wifi interaktywny wybór sieci" ;;
80 + help_list) printf '%s' " pagan-wifi --list lista wykrytych sieci" ;;
81 + help_status) printf '%s' " pagan-wifi --status stan interfejsów i adresy IP" ;;
82 + *) printf '%s' "$1" ;;
83 + esac
84 + fi
85 +}
86 +
87 +# tfmt <klucz> [argi...] – tekst z podstawieniem (dane użytkownika jako
88 +# argumenty printf, nie jako format – bezpieczne dla SSID z „%”).
89 +tfmt() {
90 + _k="$1"; shift
91 + # shellcheck disable=SC2059
92 + printf "$(t "$_k")" "$@"
93 +}
94 +
17 95 msg() { printf '%s\n' "$*"; }
18 96 err() { printf '%s\n' "$*" >&2; }
19 97
@@ -59,19 +137,19 @@ list_networks() {
59 137 }
60 138
61 139 show_status() {
62 - msg "=== Interfejsy (nmcli device) ==="
140 + msg "$(t status_ifaces)"
63 141 nmcli -t -f DEVICE,TYPE,STATE,CONNECTION device 2>/dev/null | tr ':' '\t' || true
64 142 msg ""
65 - msg "=== Adresy IP ==="
143 + msg "$(t status_ips)"
66 144 if command -v ip >/dev/null 2>&1; then
67 145 ip -4 -brief addr 2>/dev/null || ip -4 addr 2>/dev/null || true
68 146 fi
69 147 msg ""
70 - msg "=== Łączność ==="
148 + msg "$(t status_conn)"
71 149 if ping -c1 -W3 1.1.1.1 >/dev/null 2>&1; then
72 - msg "Internet: OK (1.1.1.1 odpowiada)"
150 + msg "$(t inet_ok)"
73 151 else
74 - msg "Internet: brak odpowiedzi z 1.1.1.1"
152 + msg "$(t inet_fail)"
75 153 fi
76 154 }
77 155
@@ -81,7 +159,7 @@ connect_network() {
81 159
82 160 _pass=""
83 161 if [ "$_sec" != "--" ] && [ "$_sec" != "" ]; then
84 - printf 'Hasło do "%s" (nie będzie widoczne): ' "$_ssid"
162 + tfmt prompt_pass "$_ssid"
85 163 if command -v stty >/dev/null 2>&1; then
86 164 stty -echo 2>/dev/null || true
87 165 read -r _pass
@@ -92,7 +170,7 @@ connect_network() {
92 170 fi
93 171 fi
94 172
95 - msg "Łączenie z \"$_ssid\"..."
173 + msg "$(tfmt connecting "$_ssid")"
96 174 if [ -n "$_pass" ]; then
97 175 if nmcli device wifi connect "$_ssid" password "$_pass"; then
98 176 _rc=0
@@ -109,9 +187,9 @@ connect_network() {
109 187 _pass=""
110 188
111 189 if [ "$_rc" -eq 0 ]; then
112 - msg "Połączono."
190 + msg "$(t connected)"
113 191 else
114 - err "Nie udało się połączyć. Sprawdź hasło albo spróbuj ponownie."
192 + err "$(t connect_fail)"
115 193 fi
116 194 msg ""
117 195 show_status
@@ -120,26 +198,26 @@ connect_network() {
120 198
121 199 interactive() {
122 200 if ! have_nmcli; then
123 - err "Brak polecenia nmcli. Zainstaluj/uruchom NetworkManager: sudo systemctl start NetworkManager"
201 + err "$(t no_nmcli)"
124 202 return 1
125 203 fi
126 204
127 205 _iface="$(wifi_iface)"
128 206 if [ -z "$_iface" ]; then
129 - err "Nie wykryto karty Wi-Fi."
130 - err "Sprawdź, czy adapter jest widoczny: lsusb / ip link"
131 - err "Oraz czy sterownik się załadował: dmesg | grep -i firmware"
207 + err "$(t no_iface)"
208 + err "$(t no_iface_hint1)"
209 + err "$(t no_iface_hint2)"
132 210 msg ""
133 211 show_status
134 212 return 1
135 213 fi
136 214
137 - msg "Karta Wi-Fi: $_iface"
138 - msg "Szukam sieci (chwilę to potrwa)..."
215 + msg "$(tfmt iface "$_iface")"
216 + msg "$(t scanning)"
139 217 _list="$(list_networks)"
140 218
141 219 if [ -z "$_list" ]; then
142 - err "Nie znaleziono żadnej sieci Wi-Fi."
220 + err "$(t no_networks)"
143 221 return 1
144 222 fi
145 223
@@ -148,7 +226,7 @@ interactive() {
148 226 printf '%s\n' "$_list" | awk -F'\t' '{ printf "%2d) %-32s %3s%% %s\n", NR, $3, $1, $2 }'
149 227 printf '%s\n' "$_list" > "$_tmp"
150 228
151 - printf '\nNumer sieci (lub "q" aby wyjść): '
229 + printf '\n%s' "$(t choose)"
152 230 read -r _choice
153 231 case "$_choice" in
154 232 q|Q|"")
@@ -159,7 +237,7 @@ interactive() {
159 237
160 238 case "$_choice" in
161 239 *[!0-9]*)
162 - err "Niepoprawny wybór."
240 + err "$(t bad_choice)"
163 241 rm -f "$_tmp"
164 242 return 1
165 243 ;;
@@ -168,7 +246,7 @@ interactive() {
168 246 _entry="$(sed -n "${_choice}p" "$_tmp")"
169 247 rm -f "$_tmp"
170 248 if [ -z "$_entry" ]; then
171 - err "Nie ma sieci o numerze $_choice."
249 + err "$(tfmt no_such "$_choice")"
172 250 return 1
173 251 fi
174 252
@@ -188,10 +266,10 @@ case "${1:-}" in
188 266 show_status
189 267 ;;
190 268 --help|-h)
191 - msg "pagan-wifi – wybór sieci Wi-Fi (NetworkManager)"
192 - msg " pagan-wifi interaktywny wybór sieci"
193 - msg " pagan-wifi --list lista wykrytych sieci"
194 - msg " pagan-wifi --status stan interfejsów i adresy IP"
269 + msg "$(t help_title)"
270 + msg "$(t help_usage)"
271 + msg "$(t help_list)"
272 + msg "$(t help_status)"
195 273 ;;
196 274 *)
197 275 interactive
@@ -1,7 +1,7 @@
1 1 pkgname: pagan-welcome
2 -pkgver: '1.0'
3 -pkgrel: '3'
4 -pkgdesc: Centrum startowe PaganLinux - nowosci, instalator, aktualizacje, sklep i ustawienia (GTK3)
2 +pkgver: '1.1'
3 +pkgrel: '1'
4 +pkgdesc: Centrum startowe PaganLinux - nowosci, instalator, aktualizacje (wbudowany terminal) i sklep (GTK3)
5 5 url: 'https://git.paganlinux.eu/pagan-welcome.git'
6 6 arch: x86_64
7 7 license: