*: Wrap lines at 80 columns where appropriate
Wrap lines at 80 columns where appropriate and I had the energy to think about how/where to wrap. There are still lines longer than that, which I plan to wrap in the future. But that is enough for now.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
# Inspired by https://github.com/cramermarius/rofi-menus/blob/master/scripts/powermenu.sh
|
||||
# Inspired by:
|
||||
# https://github.com/cramermarius/rofi-menus/blob/master/scripts/powermenu.sh
|
||||
|
||||
# entries with associated commands
|
||||
declare -A entries
|
||||
|
||||
@@ -30,10 +30,21 @@ KNOWNCON=$(nmcli connection show)
|
||||
# Really janky way of telling if there is currently a connection
|
||||
CONSTATE=$(nmcli -fields WIFI g)
|
||||
|
||||
CURRSSID=$(LANGUAGE=C nmcli -t -f active,ssid dev wifi | awk -F: '$1 ~ /^yes/ {print $2}')
|
||||
CURRSSID=$(LANGUAGE=C \
|
||||
nmcli -t -f active,ssid dev wifi \
|
||||
| awk -F: '$1 ~ /^yes/ {print $2}'
|
||||
)
|
||||
|
||||
if [[ ! -z $CURRSSID ]]; then
|
||||
HIGHLINE=$(echo "$(echo "$LIST" | awk -F "[ ]{2,}" '{print $1}' | grep -Fxn -m 1 "$CURRSSID" | awk -F ":" '{print $1}') + 1" | bc )
|
||||
HIGHLINE=$(
|
||||
echo "$(
|
||||
echo "$LIST" \
|
||||
| awk -F "[ ]{2,}" '{print $1}' \
|
||||
| grep -Fxn -m 1 "$CURRSSID" \
|
||||
| awk -F ":" '{print $1}'
|
||||
) + 1" \
|
||||
| bc
|
||||
)
|
||||
fi
|
||||
|
||||
# HOPEFULLY you won't need this as often as I do
|
||||
@@ -53,15 +64,25 @@ fi
|
||||
|
||||
|
||||
|
||||
CHENTRY=$(echo -e "$TOGGLE\nmanual\n$LIST" | uniq -u | rofi -dmenu -p "Wi-Fi SSID: " -lines "$LINENUM" -a "$HIGHLINE" -location "$POSITION" -yoffset "$YOFF" -xoffset "$XOFF" -font "$FONT" -width -"$RWIDTH")
|
||||
CHENTRY=$(
|
||||
echo -e "$TOGGLE\nmanual\n$LIST" \
|
||||
| uniq -u \
|
||||
| rofi -dmenu -p "Wi-Fi SSID: " -lines "$LINENUM" -a "$HIGHLINE" \
|
||||
-location "$POSITION" -yoffset "$YOFF" -xoffset "$XOFF" \
|
||||
-font "$FONT" -width -"$RWIDTH"
|
||||
)
|
||||
#echo "$CHENTRY"
|
||||
CHSSID=$(echo "$CHENTRY" | sed 's/\s\{2,\}/\|/g' | awk -F "|" '{print $1}')
|
||||
#echo "$CHSSID"
|
||||
|
||||
# If the user inputs "manual" as their SSID in the start window, it will bring them to this screen
|
||||
# If the user inputs "manual" as their SSID in the start window, it will bring
|
||||
# them to this screen
|
||||
if [ "$CHENTRY" = "manual" ] ; then
|
||||
# Manual entry of the SSID and password (if appplicable)
|
||||
MSSID=$(echo "enter the SSID of the network (SSID,password)" | rofi -dmenu -p "Manual Entry: " -font "$FONT" -lines 1)
|
||||
MSSID=$(
|
||||
echo "enter the SSID of the network (SSID,password)" \
|
||||
| rofi -dmenu -p "Manual Entry: " -font "$FONT" -lines 1
|
||||
)
|
||||
# Separating the password from the entered string
|
||||
MPASS=$(echo "$MSSID" | awk -F "," '{print $2}')
|
||||
|
||||
@@ -83,17 +104,26 @@ elif [ "$CHENTRY" = "toggle off" ]; then
|
||||
|
||||
else
|
||||
|
||||
# If the connection is already in use, then this will still be able to get the SSID
|
||||
# If the connection is already in use, then this will still be able to get
|
||||
# the SSID
|
||||
if [ "$CHSSID" = "*" ]; then
|
||||
CHSSID=$(echo "$CHENTRY" | sed 's/\s\{2,\}/\|/g' | awk -F "|" '{print $3}')
|
||||
CHSSID=$(
|
||||
echo "$CHENTRY" \
|
||||
| sed 's/\s\{2,\}/\|/g' \
|
||||
| awk -F "|" '{print $3}'
|
||||
)
|
||||
fi
|
||||
|
||||
# Parses the list of preconfigured connections to see if it already contains the chosen SSID. This speeds up the connection process
|
||||
# Parses the list of preconfigured connections to see if it already contains
|
||||
# the chosen SSID. This speeds up the connection process
|
||||
if [[ $(echo "$KNOWNCON" | grep "$CHSSID") = "$CHSSID" ]]; then
|
||||
nmcli con up "$CHSSID"
|
||||
else
|
||||
if [[ "$CHENTRY" =~ "WPA2" ]] || [[ "$CHENTRY" =~ "WEP" ]]; then
|
||||
WIFIPASS=$(echo "if connection is stored, hit enter" | rofi -dmenu -p "password: " -lines 1 -font "$FONT" )
|
||||
WIFIPASS=$(
|
||||
echo "if connection is stored, hit enter" \
|
||||
| rofi -dmenu -p "password: " -lines 1 -font "$FONT"
|
||||
)
|
||||
fi
|
||||
nmcli dev wifi con "$CHSSID" password "$WIFIPASS"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user