Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a97760c

Browse files
Merge pull request #5 from abrahamgitonga/dateScript
initialised a lising of all network profiles# password display not ye…
2 parents 6b824df + 6fb616f commit a97760c

File tree

1 file changed

+29
-5
lines changed

1 file changed

+29
-5
lines changed

date.sh

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,37 @@ echo Hellow $1,Today is $(date +"%A, %B %d, %Y %H:%M:%S" )
55
#uname -a command retrieves your kernel info
66
kernel_details=$(uname -a)
77
echo "You are using the following kernel: $kernel_details"
8+
# Check network connection profiles
9+
network_profiles=$(nmcli connection show)
10+
if [ -n "$network_profiles" ]; then
11+
echo "Network connection profiles:"
12+
echo "$network_profiles" | grep -v "docker0" | awk '{print $1}'
13+
wifi_connected=$(echo "$network_profiles" | grep "WiFi" | awk '{print $1}')
14+
else
15+
echo "No network connection profiles found."
16+
fi
17+
18+
# Check WiFi password
19+
if [ -n "$wifi_connected" ]; then
20+
read -p "WiFi password: " wifi_password
21+
echo "You entered: $wifi_password"
22+
fi
823

9-
# Check WiFi state using nmcli
10-
wifi_state=$(nmcli -t -f WIFI general)
11-
if [ "$wifi_state" == "enabled" ]; then
12-
echo "WiFi is enabled."
24+
# Check if WiFi is connected using nmcli
25+
wifi_connection=$(nmcli -t -f NAME,STATE connection show --active)
26+
if [ -n "$wifi_connection" ]; then
27+
echo "WiFi is connected to: $wifi_connection"
28+
29+
# Prompt for the WiFi password
30+
read -p "Do you want to display the WiFi password? (y/n): " display_password
31+
if [ "$display_password" == "y" ]; then
32+
#command to retrieve WiFi password
33+
#still working on this part not working correctly
34+
wifi_password=$(nmcli -g 802-11-wireless-security.psk connection show "$wifi_connection" | awk 'NR==2')
35+
echo "WiFi password: $wifi_password"
36+
fi
1337
else
14-
echo "WiFi is disabled."
38+
echo "WiFi is not connected."
1539
fi
1640

1741
# Check screen brightness level using xrandr

0 commit comments

Comments
 (0)