Merge lp:~elementary-dev-community/capnet-assist/multiple-displays into lp:~elementary-apps/capnet-assist/trunk

Proposed by Cameron Norman on 2015-06-09
Status: Merged
Approved by: Cody Garver on 2016-01-15
Approved revision: 24
Merged at revision: 53
Proposed branch: lp:~elementary-dev-community/capnet-assist/multiple-displays
Merge into: lp:~elementary-apps/capnet-assist/trunk
Diff against target: 40 lines (+9/-13)
1 file modified
90captive_portal_test (+9/-13)
To merge this branch: bzr merge lp:~elementary-dev-community/capnet-assist/multiple-displays
Reviewer Review Type Date Requested Status
elementary Apps team 2015-06-09 Pending
Review via email: mp+261458@code.launchpad.net

Commit message

Do not assume DISPLAY is :0 (lp:1480650)

Description of the change

This allows the script to work when the display name is not :0

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '90captive_portal_test'
2--- 90captive_portal_test 2015-04-14 21:43:56 +0000
3+++ 90captive_portal_test 2015-06-09 00:32:04 +0000
4@@ -22,8 +22,12 @@
5 #launch the browser, but on boot we need to wait that nm-applet starts
6 start_browser() {
7 local user="$1"
8+ local display="$2"
9+
10+ export DISPLAY="$display"
11 wait_for_process nm-applet
12- $logger "Running browser as '$user' to login in captive portal"
13+
14+ $logger "Running browser as '$user' with display '$display' to login in captive portal"
15 su "$user" -s /bin/sh -c "captive-login 2>/dev/null"
16 }
17
18@@ -32,18 +36,10 @@
19 up|vpn-up)
20 $logger -p user.debug "DetectCaptivePortal script triggered"
21
22- # assume the DISPLAY where to show the browser
23- if [ -z $DISPLAY ];then
24- export DISPLAY=':0'
25- fi
26-
27- $logger -p user.debug "Display set as: $DISPLAY"
28-
29- #get the usernames
30- users=$(who | grep "$DISPLAY" | awk '{print $1}')
31-
32- for u in $users; do
33- start_browser $u || $logger -p user.err "captive-login browser failed for user: $u"
34+ # Match 2nd column of who's output with ' :[at least one digit] '
35+ who | awk '$2 ~ /:[0-9]+/ { print $1 " " $2; };' | \
36+ while read user display; do
37+ start_browser $user $display || $logger -p user.err "failed for user: '$user' display: '$display')"
38 done
39 ;;
40 *)

Subscribers

People subscribed via source and target branches