Last active
June 6, 2026 22:29
-
-
Save felipealfonsog/9f6bd90d84c13f52bff643688009e278 to your computer and use it in GitHub Desktop.
NetworkManager CLI Manager for Arch Linux
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Colors for a more user-friendly interface | |
| RED='\033[0;31m' | |
| GREEN='\033[0;32m' | |
| BLUE='\033[0;34m' | |
| YELLOW='\033[1;33m' | |
| NC='\033[0m' # No color | |
| # Ensure it runs as a regular user, using sudo only when required | |
| printf "${BLUE}=== NetworkManager Manager for Arch Linux ===${NC}\n" | |
| while true; do | |
| echo "----------------------------------------" | |
| echo -e "${YELLOW}1)${NC} View network status" | |
| echo -e "${YELLOW}2)${NC} List saved connections" | |
| echo -e "${YELLOW}3)${NC} Scan and connect to Wi-Fi" | |
| echo -e "${YELLOW}4)${NC} Enable/Disable Wi-Fi interface" | |
| echo -e "${YELLOW}5)${NC} Activate an existing connection" | |
| echo -e "${YELLOW}6)${NC} Deactivate an active connection" | |
| echo -e "${YELLOW}7)${NC} Exit" | |
| echo "----------------------------------------" | |
| read -p "Select an option [1-7]: " option | |
| case $option in | |
| 1) | |
| echo -e "\n${GREEN}--- General Status ---${NC}" | |
| nmcli general status | |
| echo -e "\n${GREEN}--- Devices ---${NC}" | |
| nmcli device status | |
| ;; | |
| 2) | |
| echo -e "\n${GREEN}--- Saved Connections ---${NC}" | |
| nmcli connection show | |
| ;; | |
| 3) | |
| echo -e "\n${BLUE}Scanning Wi-Fi networks...${NC}" | |
| nmcli device wifi rescan | |
| nmcli device wifi list | |
| echo "----------------------------------------" | |
| read -p "Enter the network SSID (Name): " ssid | |
| read -s -p "Enter the password (leave blank for open networks): " pass | |
| echo "" | |
| if [ -z "$pass" ]; then | |
| nmcli device wifi connect "$ssid" | |
| else | |
| nmcli device wifi connect "$ssid" password "$pass" | |
| fi | |
| ;; | |
| 4) | |
| echo -e "\n${YELLOW}1)${NC} Enable Wi-Fi" | |
| echo -e "${YELLOW}2)${NC} Disable Wi-Fi" | |
| read -p "Select [1-2]: " wifi_option | |
| if [ "$wifi_option" == "1" ]; then | |
| nmcli radio wifi on | |
| echo -e "${GREEN}Wi-Fi enabled.${NC}" | |
| elif [ "$wifi_option" == "2" ]; then | |
| nmcli radio wifi off | |
| echo -e "${RED}Wi-Fi disabled.${NC}" | |
| fi | |
| ;; | |
| 5) | |
| echo -e "\n${GREEN}Available connections:${NC}" | |
| nmcli connection show | awk 'NR>1 {print $1}' | |
| echo "----------------------------------------" | |
| read -p "Connection name to ACTIVATE: " conn_name | |
| nmcli connection up id "$conn_name" | |
| ;; | |
| 6) | |
| echo -e "\n${RED}Active connections:${NC}" | |
| nmcli connection show --active | awk 'NR>1 {print $1}' | |
| echo "----------------------------------------" | |
| read -p "Connection name to DEACTIVATE: " conn_name | |
| nmcli connection down id "$conn_name" | |
| ;; | |
| 7) | |
| echo -e "\n${BLUE}Goodbye!${NC}" | |
| exit 0 | |
| ;; | |
| *) | |
| echo -e "\n${RED}Invalid option.${NC}" | |
| ;; | |
| esac | |
| echo "" | |
| read -p "Press [Enter] to continue..." | |
| clear | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment