summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorMax Krasnyansky <maxk@qualcomm.com>2002-04-15 16:53:01 +0000
committerMax Krasnyansky <maxk@qualcomm.com>2002-04-15 16:53:01 +0000
commit386647e4e954416f41107db5438223193e8e9167 (patch)
tree3436e48077d0e5906458b5b8f909a808d8360a5f /scripts
parentc7073a0113d641580f49b171b8ece52f59f76e15 (diff)
Working X display and authentication setting
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/bluepin46
1 files changed, 28 insertions, 18 deletions
diff --git a/scripts/bluepin b/scripts/bluepin
index db1f8196..a1c51ab2 100755
--- a/scripts/bluepin
+++ b/scripts/bluepin
@@ -3,28 +3,34 @@
# Bluetooth PIN helper
# Written by Maxim Krasnyansky <maxk@qualcomm.com>
#
+import sys, os, string, popen2
-import sys, os, string
-
-#
-# FIXME:
-#
-# We have to find actual user and proper X display here. And if
-# it's not available (no one's logged in) we should lookup some
-# file for predefined PINs.
-#
-# For now we just assume that we have access to local X display
-# and whoever is logged in there will get a window pop.
+# X Display initialization.
+# Find running X Server and parse it's arguments.
+# Set enviroment variables DISPLAY and XAUTHORITY
+# using info extracted from X Server args.
#
-
-os.environ['DISPLAY'] = ':0'
-
-# For X Window display access blueping has to find a user and use
-# his(her) .Xauthority file.
-# os.environ['XAUTHORITY'] = '/home/maxk/.Xauthority'
+def set_display():
+ disp = ":0"
+ auth = ""
+ ps = "/bin/ps -C X --format args --no-headers"
+
+ r,w = popen2.popen2(ps)
+ arg = string.split(r.read())
+ for i in range(1, len(arg)):
+ if arg[i][0] != '-':
+ disp = arg[i]
+ elif arg[i] == "-auth":
+ auth = arg[i+1]
+ break
+
+ os.environ['DISPLAY'] = disp
+ os.environ['XAUTHORITY'] = auth
+
+# Set X display before initializing GTK
+set_display()
from gtk import *
-#import GdkImlib, GtkExtra
# Dialog Class
DLG_OK = 1
@@ -113,6 +119,10 @@ def dialog(title, mesg, args, modal = FALSE):
return dlg.result
def main(*args):
+ if len(sys.argv) < 2:
+ print "ERR"
+ sys.exit()
+
dir = sys.argv[1]
bdaddr = sys.argv[2]