#!/usr/bin/python3
# Unity Mail, QuickList URL processor
# Author: Dmitry Shachnev <mitya57@gmail.com>
# License: GNU GPL 3 or higher; http://www.gnu.org/licenses/gpl.html

import sys
import subprocess

from os.path import exists
from UnityMail.config import config_dir, open_url_or_command, print_names

if (exists('/usr/share/unity-mail/unity-mail-autostart.desktop') and
not exists(config_dir+'/autostart/unity-mail-autostart.desktop')):
	# First run of Unity Mail, open um-config
	subprocess.call('um-config')
elif len(sys.argv) > 1:
	open_url_or_command(sys.argv[1])
else:
	print('Error: please specify URL name.')
	print_names()
	sys.exit(1)
