summary refs log tree commit diff
diff options
context:
space:
mode:
-rwxr-xr-xbin/connmenu17
1 files changed, 12 insertions, 5 deletions
diff --git a/bin/connmenu b/bin/connmenu
index cc584e4..d09a3d1 100755
--- a/bin/connmenu
+++ b/bin/connmenu
@@ -7,6 +7,8 @@
 # * use menu (my bemenu wrapper)
 # * replace dmenu_notify with notify-send
 # * include icons in menu prompts
+# * report script errors instead of failing silently
+# * make use of bemenu's password mode
 
 set -e
 [ -n "$DEBUG" ] && set -x
@@ -104,16 +106,21 @@ create_dmenu() {
 # $1 = question
 # $2 = var name
 dmenu_ask() {
-	IFS= read -r "$2" < <(: | dmenu -p "󱛆 $1")
-	if [[ ! "${!2}" ]]; then
+	local msg=$1
+	local var=$2
+	shift 2
+
+	IFS= read -r "${var?}" < <(: | dmenu -p "󱛆 $msg" "$@")
+	if [[ ! "${!var}" ]]; then
 		(
 			notifyicon=wifi-alert
-			notifysend "invalid $2"
+			notifysend "invalid $var"
 		)
 		exit 1
 	fi
 }
 
+trap '{ notify-send connman "an error occured" -c error -i "$(iconez -sn wifi-alert)"; }' ERR
 get_services
 index="$(create_dmenu | dmenu -l 10 -i -p '󱛆 select wifi service' | sed 's/^ *//g' | cut -d ' ' -f 1)"
 
@@ -123,7 +130,7 @@ if [[ "$index" == setup ]]; then
 	name="${name// /_}"
 	dmenu_ask 'please provide VPN domain' domain
 	dmenu_ask 'please provide identity' identity
-	dmenu_ask 'please provide password' password
+	dmenu_ask 'please provide password' password --password
 	cat >"$VPN_STORAGE_PATH/$name.config" <<-EOF
 		[provider_$name]
 		Type = PPTP
@@ -160,7 +167,7 @@ if [[ "$security" =~ ^(ieee8021x|psk|wep)$ ]]; then
 	if [[ -f "$config_file" && no != "$(echo -e 'yes\nno' | dmenu -p '󱛆 use previous profile?')" ]]; then
 		echo "use old profile: $config_file"
 	else
-		dmenu_ask 'please provide password' password
+		dmenu_ask 'please provide password' password --password
 		case "$security" in
 		ieee8021x)
 			dmenu_ask 'please provide identity' identity