Browse files

Allow to use portable browser, via settings

  • Loading branch information...
1 parent f3b748f commit 875fa106af2f4204aecc8827e72edf81e9442e0d @titoBouzout committed Mar 2, 2013
Showing with 43 additions and 21 deletions.
  1. +5 −1 Side Bar.sublime-settings
  2. +38 −20 SideBar.py
View
6 Side Bar.sublime-settings
@@ -24,5 +24,9 @@
"disabled_menuitem_empty": true,
//if installed in a default location maybe this works.
- "default_browser": "chrome" //one of this list: firefox, chrome, chromium, opera, safari
+ "default_browser": "chrome", //one of this list: firefox, chrome, chromium, opera, safari
+
+ "portable_browser": "" // for example: C:/Program Files (x86)/Nightly/firefox.exe
+
+
}
View
58 SideBar.py
@@ -1275,16 +1275,20 @@ def try_open(self, url, browser):
import subprocess
browser = browser.lower().strip();
+ items = []
+
if browser == 'chrome':
if sublime.platform() == 'osx':
- items = ['open']
+ items.extend(['open'])
commands = ['-a', '/Applications/Google Chrome.app', url]
elif sublime.platform() == 'windows':
# read local app data path from registry
aKey = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, r"Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders")
reg_value, reg_type = _winreg.QueryValueEx (aKey, "Local AppData")
- items = [
+ if s.get('portable_browser') != '':
+ items.extend([s.get('portable_browser')])
+ items.extend([
'%HOMEPATH%\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe'
,reg_value+'\\Chrome\\Application\\chrome.exe'
@@ -1299,25 +1303,31 @@ def try_open(self, url, browser):
,'%HOMEPATH%\\Local\ Settings\\Application\ Data\\Google\\Chrome\\Application\\chrome.exe'
,'%HOMEPATH%\\Local Settings\\Application Data\\Google\\Chrome\\Application\\chrome.exe'
,'chrome.exe'
- ]
+ ])
+
+
commands = ['-new-tab', url]
else:
- items = [
+
+ if s.get('portable_browser') != '':
+ items.extend([s.get('portable_browser')])
+ items.extend([
'/usr/bin/google-chrome'
,'chrome'
- ]
+ ])
commands = ['-new-tab', url]
elif browser == 'chromium':
if sublime.platform() == 'osx':
- items = ['open']
+ items.extend(['open'])
commands = ['-a', '/Applications/Chromium.app', url]
elif sublime.platform() == 'windows':
# read local app data path from registry
aKey = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, r"Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders")
reg_value, reg_type = _winreg.QueryValueEx (aKey, "Local AppData")
-
- items = [
+ if s.get('portable_browser') != '':
+ items.extend([s.get('portable_browser')])
+ items.extend([
'%HOMEPATH%\\AppData\\Local\\Google\\Chrome SxS\\Application\\chrome.exe'
, reg_value+'\\Chromium\\Application\\chromium.exe'
@@ -1340,20 +1350,24 @@ def try_open(self, url, browser):
,'%HOMEPATH%\\Local Settings\\Application Data\\Google\\Chrome\\Application\\chrome.exe'
,'chrome.exe'
- ]
+ ])
commands = ['-new-tab', url]
else:
- items = [
+ if s.get('portable_browser') != '':
+ items.extend([s.get('portable_browser')])
+ items.extend([
'/usr/bin/chromium'
,'chromium'
- ]
+ ])
commands = ['-new-tab', url]
elif browser == 'firefox':
if sublime.platform() == 'osx':
- items = ['open']
+ items.extend(['open'])
commands = ['-a', '/Applications/Firefox.app', url]
else:
- items = [
+ if s.get('portable_browser') != '':
+ items.extend([s.get('portable_browser')])
+ items.extend([
'/usr/bin/firefox'
,'%PROGRAMFILES%\\Nightly\\firefox.exe'
@@ -1364,14 +1378,16 @@ def try_open(self, url, browser):
,'firefox'
,'firefox.exe'
- ]
+ ])
commands = ['-new-tab', url]
elif browser == 'opera':
if sublime.platform() == 'osx':
- items = ['open']
+ items.extend(['open'])
commands = ['-a', '/Applications/Opera.app', url]
else:
- items = [
+ if s.get('portable_browser') != '':
+ items.extend([s.get('portable_browser')])
+ items.extend([
'/usr/bin/opera'
,'/usr/bin/opera-next'
,'/usr/bin/operamobile'
@@ -1387,22 +1403,24 @@ def try_open(self, url, browser):
,'opera'
,'opera.exe'
- ]
+ ])
commands = ['-newtab', url]
elif browser == 'safari':
if sublime.platform() == 'osx':
- items = ['open']
+ items.extend(['open'])
commands = ['-a', 'Safari', url]
else:
- items = [
+ if s.get('portable_browser') != '':
+ items.extend([s.get('portable_browser')])
+ items.extend([
'/usr/bin/safari'
,'%PROGRAMFILES%\\Safari\\Safari.exe'
,'%PROGRAMFILES(X86)%\\Safari\\Safari.exe'
,'Safari'
,'Safari.exe'
- ]
+ ])
commands = ['-new-tab', '-url', url]
else:
sublime.error_message('Browser "'+browser+'" not found!\nUse any of the following: firefox, chrome, chromium, opera, safari')

0 comments on commit 875fa10

Please sign in to comment.