Skip to content

Instantly share code, notes, and snippets.

@qsun
Created April 25, 2012 02:18
Show Gist options
  • Save qsun/2485561 to your computer and use it in GitHub Desktop.
Save qsun/2485561 to your computer and use it in GitHub Desktop.
GUI chrome profile selector
#!/usr/bin/env python
import subprocess
from os import fork
CHROME='/opt/google/chrome/chrome'
PROFILES = {
'*normal': '/home/qsun/.chrome-profiles/gmail',
'new one': '/tmp/chrome-profiles/temp',
'pretty web': '/home/qsun/.chrome-profiles/prettyweb',
'freelancer': '/home/qsun/.chrome-profiles/freelancer'
}
def display_choice(profiles):
args = ['zenity']
args.append('--text="available profiles:')
args.append('--radiolist')
args.append('--list')
args.append('--column=')
args.append('--column=Profile')
for name in profiles.keys():
if name.find('*') == 0:
args.append('TRUE')
args.append(name[1:])
else:
args.append('FALSE')
args.append(name)
return subprocess.check_output(args).rstrip()
def start_chrome(profile_location):
print profile_location
subprocess.call([CHROME, '--user-data-dir=%s'%profile_location])
if __name__ == '__main__':
choice = display_choice(PROFILES)
start_chrome(PROFILES[choice])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment