[Pkg-privacy-commits] [torbrowser-launcher] 98/476: used wmctrl to finish #17

Ximin Luo infinity0 at moszumanska.debian.org
Sat Aug 22 13:21:26 UTC 2015


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch debian
in repository torbrowser-launcher.

commit dda5a82aaa8f18118c2c790906c5059a4e80b46a
Author: Micah Lee <micahflee at riseup.net>
Date:   Mon Apr 8 23:07:53 2013 -0700

    used wmctrl to finish #17
---
 stdeb.cfg           |  2 +-
 torbrowser-launcher | 29 ++++++++++++++++++++++++++---
 2 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/stdeb.cfg b/stdeb.cfg
index ade8ce9..24b9404 100644
--- a/stdeb.cfg
+++ b/stdeb.cfg
@@ -1,3 +1,3 @@
 [DEFAULT]
 Package: torbrowser-launcher
-Depends: python-gtk2, python-psutil, gnupg, python-twisted
+Depends: python-gtk2, python-psutil, python-twisted, gnupg, wmctrl
diff --git a/torbrowser-launcher b/torbrowser-launcher
index 502a92c..8f57cd5 100755
--- a/torbrowser-launcher
+++ b/torbrowser-launcher
@@ -68,16 +68,39 @@ class TorBrowserLauncher:
                     for p in psutil.process_iter():
                         try:
                             if p.exe == self.paths['file']['vidalia_bin']:
-                                vidalia_pid = p.exe
+                                vidalia_pid = p.pid
                             if p.exe == self.paths['file']['firefox_bin']:
-                                firefox_pid = p.exe
+                                firefox_pid = p.pid
                         except:
                             pass
 
                     if vidalia_pid and not firefox_pid:
-                        print _('Vidalia is already open, but firefox is closed. Launching new firefox.')
+                        print _('Vidalia is already open, but Firefox is closed. Launching new Firefox.')
                         subprocess.Popen([self.paths['file']['firefox_bin'], '-no-remote', '-profile', self.paths['file']['firefox_profile']])
                         return
+                    elif vidalia_pid and firefox_pid:
+                        print _('Vidalia and Firefox are already open, bringing them to focus')
+
+                        # figure out the window ids of vidalia and firefox
+                        vidalia_win_id = None
+                        firefox_win_id = None
+                        p = subprocess.Popen(['wmctrl', '-l', '-p'], stdout=subprocess.PIPE)
+                        for line in p.stdout.readlines():
+                            line_split = line.split()
+                            win_id = line_split[0]
+                            win_pid = int(line_split[2])
+                            if win_pid == vidalia_pid:
+                                vidalia_win_id = win_id
+                            if win_pid == firefox_pid:
+                                firefox_win_id = win_id
+
+                        # bring firefox to front, then vidalia
+                        if firefox_win_id:
+                            subprocess.call(['wmctrl', '-i', '-a', firefox_win_id])
+                        if vidalia_win_id:
+                            subprocess.call(['wmctrl', '-i', '-a', vidalia_win_id])
+
+                        return
 
                 # how long was it since the last update check?
                 # 86400 seconds = 24 hours

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/torbrowser-launcher.git



More information about the Pkg-privacy-commits mailing list