mirror of
https://github.imc.re/void-land/hyprland-void-dots
synced 2025-06-06 03:03:44 +02:00
feat: nmcli shell
This commit is contained in:
parent
b06c02940e
commit
3fee9a288c
2 changed files with 46 additions and 0 deletions
26
configs/shell/zsh/.scripts/nmcli.sh
Executable file
26
configs/shell/zsh/.scripts/nmcli.sh
Executable file
|
@ -0,0 +1,26 @@
|
|||
#!/bin/bash
|
||||
|
||||
source ~/.scripts/utils/main.sh
|
||||
|
||||
list_wifi_networks() {
|
||||
echo "Available Wi-Fi Networks:"
|
||||
nmcli dev wifi list
|
||||
}
|
||||
|
||||
connect_to_wifi() {
|
||||
echo "Enter the name (SSID) of the Wi-Fi network you want to connect to:"
|
||||
read ssid
|
||||
|
||||
echo "Enter the password for the Wi-Fi network:"
|
||||
read -s password
|
||||
|
||||
sudo nmcli dev wifi connect "$ssid" password "$password"
|
||||
}
|
||||
|
||||
list_wifi_networks
|
||||
|
||||
if ask_prompt "Do you want to connect to a Wi-Fi network ?"; then
|
||||
connect_to_wifi
|
||||
else
|
||||
echo "No network connection requested. Exiting."
|
||||
fi
|
20
configs/shell/zsh/.scripts/utils/main.sh
Executable file
20
configs/shell/zsh/.scripts/utils/main.sh
Executable file
|
@ -0,0 +1,20 @@
|
|||
#!/bin/bash
|
||||
|
||||
check_sudo() {
|
||||
if [ "$(id -u)" != 0 ]; then
|
||||
echo "Please run the script with sudo."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
ask_prompt() {
|
||||
local question="$1"
|
||||
while true; do
|
||||
read -p "$question (Y/N): " choice
|
||||
case "$choice" in
|
||||
[Yy]) return 0 ;;
|
||||
[Nn]) return 1 ;;
|
||||
*) echo "Please enter Y or N." ;;
|
||||
esac
|
||||
done
|
||||
}
|
Loading…
Add table
Reference in a new issue