Skip to content

Commit 7b236da

Browse files
committed
Handle VPN names with white spaces
1 parent b97c72c commit 7b236da

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lazy-connect.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function _lazy_connect_init() {
77
echo "**********"
88
echo $secret_key > $config_dir/secret
99

10-
vpnNames=$(osascript <<EOF
10+
osascript <<EOF |
1111
tell application "System Events"
1212
tell process "SystemUIServer"
1313
set vpnMenu to (menu bar item 1 of menu bar 1 where description is "VPN")
@@ -27,8 +27,8 @@ function _lazy_connect_init() {
2727
end tell
2828
end tell
2929
EOF
30-
)
31-
echo $vpnNames | sed -e "s/Connect //g; s/Disconnect //g;" | tr , "\n" | xargs -I{} echo {} > $config_dir/vpns
30+
tr , '\n' | sed 's/ Connect/Connect/g' > $config_dir/vpns
31+
3232
echo "VPN List:"
3333
cat $config_dir/vpns | nl
3434
}
@@ -60,7 +60,7 @@ function _lazy_connect() {
6060
set vpnMenu to (menu bar item 1 of menu bar 1 where description is "VPN")
6161
tell vpnMenu to click
6262
try
63-
click menu item ("Connect " & vpnName) of menu 1 of vpnMenu
63+
click menu item vpnName of menu 1 of vpnMenu
6464
delay 1
6565
keystroke password
6666
keystroke return

0 commit comments

Comments
 (0)