← Back to team overview

elementary-dev-community team mailing list archive

[Merge] lp:~elementary-dev-community/capnet-assist/multiple-displays into lp:capnet-assist

 

Cameron Norman has proposed merging lp:~elementary-dev-community/capnet-assist/multiple-displays into lp:capnet-assist.

Requested reviews:
  elementary Apps team (elementary-apps)

For more details, see:
https://code.launchpad.net/~elementary-dev-community/capnet-assist/multiple-displays/+merge/261458

This allows the script to work when the display name is not :0
-- 
Your team elementary Developer Community is subscribed to branch lp:~elementary-dev-community/capnet-assist/multiple-displays.
=== modified file '90captive_portal_test'
--- 90captive_portal_test	2015-04-14 21:43:56 +0000
+++ 90captive_portal_test	2015-06-09 00:32:04 +0000
@@ -22,8 +22,12 @@
 #launch the browser, but on boot we need to wait that nm-applet starts
 start_browser() {
     local user="$1"
+    local display="$2"
+
+    export DISPLAY="$display"
     wait_for_process nm-applet
-    $logger "Running browser as '$user' to login in captive portal"
+
+    $logger "Running browser as '$user' with display '$display' to login in captive portal"
     su "$user" -s /bin/sh -c "captive-login 2>/dev/null"
 }
 
@@ -32,18 +36,10 @@
     up|vpn-up)
     $logger -p user.debug "DetectCaptivePortal script triggered"
 
-    # assume the DISPLAY where to show the browser
-    if [ -z $DISPLAY ];then
-        export DISPLAY=':0'
-    fi
-
-    $logger -p user.debug "Display set as: $DISPLAY"
-
-    #get the usernames
-    users=$(who | grep "$DISPLAY" | awk '{print $1}')
-
-    for u in $users; do
-        start_browser $u || $logger -p user.err "captive-login browser failed for user: $u"
+    # Match 2nd column of who's output with ' :[at least one digit] '
+    who | awk '$2 ~ /:[0-9]+/ { print $1 " " $2; };' | \
+    while read user display; do
+        start_browser $user $display || $logger -p user.err "failed for user: '$user' display: '$display')"
     done
     ;;
     *)


Follow ups