Remove code to bring windows to front, and to get pid of processes, because these stopped working long ago. Also remove wmctrl dependency.

This commit is contained in:
Micah Lee 2015-11-08 17:30:47 -08:00
parent 94d184a26b
commit dd86ff7e40
7 changed files with 5 additions and 62 deletions

View File

@ -12,7 +12,7 @@ Then install dependencies, build a package, and install:
### Debian, Ubuntu, Linux Mint, etc.
```sh
sudo apt-get install build-essential dh-python python-all python-stdeb python-gtk2 python-psutil python-twisted python-lzma python-txsocksx wmctrl gnupg fakeroot xz-utils tor
sudo apt-get install build-essential dh-python python-all python-stdeb python-gtk2 python-psutil python-twisted python-lzma python-txsocksx gnupg fakeroot xz-utils tor
./build_deb.sh
sudo dpkg -i deb_dist/torbrowser-launcher_*.deb
```
@ -22,7 +22,7 @@ Optionally you can install `python-pygame` if you want to play a modem sound whi
### Red Hat, Fedora, CentOS, etc.
```sh
sudo yum install python-psutil python-twisted wmctrl gnupg fakeroot rpm-build python-txsocksx tor pygtk2
sudo yum install python-psutil python-twisted gnupg fakeroot rpm-build python-txsocksx tor pygtk2
./build_rpm.sh
sudo yum install dist/torbrowser-launcher-*.rpm
```

View File

@ -36,7 +36,7 @@
@{PROC}/tty/drivers r,
@{PROC}/uptime r,
/usr/bin/ r,
/usr/bin/{gpg,wmctrl,dirname,expr,file,getconf,id} rix,
/usr/bin/{gpg,dirname,expr,file,getconf,id} rix,
/usr/bin/torbrowser-launcher r,
/usr/share/file/magic.mgc r,
/usr/share/file/magic/ r,

View File

@ -6,7 +6,7 @@ VERSION=`cat share/torbrowser-launcher/version`
rm -r build dist
# build binary package
python setup.py bdist_rpm --requires="python-psutil, python-twisted, python-txsocksx, wmctrl, gnupg, fakeroot, tor, pygtk2"
python setup.py bdist_rpm --requires="python-psutil, python-twisted, python-txsocksx, gnupg, fakeroot, tor, pygtk2"
# install it
echo ""

View File

@ -1,6 +1,6 @@
[DEFAULT]
Package: torbrowser-launcher
Depends: python-gtk2, python-psutil, python-twisted, python-lzma, gnupg, wmctrl, xz-utils, python-txsocksx, tor
Depends: python-gtk2, python-psutil, python-twisted, python-lzma, gnupg, xz-utils, python-txsocksx, tor
Build-Depends: dh-python
Recommends: python-pygame
Suite: trusty

View File

@ -53,13 +53,6 @@ def main():
common = Common(tor_browser_launcher_version)
# is torbrowser-launcher already running?
tbl_pid = common.get_pid(common.paths['tbl_bin'], True)
if tbl_pid:
print _('Tor Browser Launcher is already running (pid {0}), bringing to front').format(tbl_pid)
common.bring_window_to_front(tbl_pid)
sys.exit()
if settings:
# settings mode
app = Settings(common)

View File

@ -235,44 +235,3 @@ class Common:
json.dump(self.settings, open(self.paths['settings_file'], 'w'))
return True
# get the process id of a program
@staticmethod
def get_pid(bin_path, python=False):
pid = None
for p in psutil.process_iter():
try:
if p.pid != os.getpid():
exe = None
if python:
if len(p.cmdline) > 1:
if 'python' in p.cmdline[0]:
exe = p.cmdline[1]
else:
if len(p.cmdline) > 0:
exe = p.cmdline[0]
if exe == bin_path:
pid = p.pid
except:
pass
return pid
# bring program's x window to front
@staticmethod
def bring_window_to_front(pid):
# figure out the window id
win_id = None
p = subprocess.Popen(['wmctrl', '-l', '-p'], stdout=subprocess.PIPE)
for line in p.stdout.readlines():
line_split = line.split()
cur_win_id = line_split[0]
cur_win_pid = int(line_split[2])
if cur_win_pid == pid:
win_id = cur_win_id
# bring to front
if win_id:
subprocess.call(['wmctrl', '-i', '-a', win_id])

View File

@ -100,15 +100,6 @@ class Launcher:
self.common.settings['update_over_tor'] = False
self.common.save_settings()
# is firefox already running?
if self.common.settings['installed_version']:
firefox_pid = self.common.get_pid('./Browser/firefox')
if firefox_pid:
print _('Firefox is open, bringing to focus')
# bring firefox to front
self.common.bring_window_to_front(firefox_pid)
return
# check for updates?
check_for_updates = False
if self.common.settings['check_for_updates']: