How to use the scc.paths.get_profiles_path function in scc

To help you get started, we’ve selected a few scc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kozec / sc-controller / python / scc / gui / app.py View on Github external
def generate_new_name(self):
		"""
		Generates name for new profile.
		That is 'New Profile X', where X is number that makes name unique.
		"""
		i = 1
		new_name = _("New Profile %s") % (i,)
		filename = os.path.join(get_profiles_path(), new_name + ".sccprofile")
		while os.path.exists(filename):
			i += 1
			new_name = _("New Profile %s") % (i,)
			filename = os.path.join(get_profiles_path(), new_name + ".sccprofile")
		return new_name
github kozec / sc-controller / scc / gui / app.py View on Github external
def convert_old_profiles(self):
		"""
		Checks all available profiles and automatically converts anything with
		version 1.3 or lower.
		"""
		from scc.parser import ActionParser
		to_convert = {}
		for name in os.listdir(get_profiles_path()):
			if name.endswith("~"):
				# Ignore backups - https://github.com/kozec/sc-controller/issues/440
				continue
			try:
				p = Profile(ActionParser())
				p.load(os.path.join(get_profiles_path(), name))
			except:
				# Just ignore invalid profiles here
				continue
			if p.original_version < 1.4:
				to_convert[name] = p
		
		if to_convert:
			log.warning("Auto-converting old profile files to version 1.4. This should take only moment.")
			log.warning("All files are modified in-place, but backup files are created. Feel free to remove them later.")
			for name in to_convert:
github kozec / sc-controller / scc / gui / global_settings.py View on Github external
def _save_osk_profile(self, profile):
		"""
		Saves on-screen keyboard profile and calls daemon.reconfigure()
		Used by methods that are changing it.
		"""
		profile.save(os.path.join(get_profiles_path(),
				OSDKeyboard.OSK_PROF_NAME + ".sccprofile"))
		self.app.dm.reconfigure()
github kozec / sc-controller / scc / scripts.py View on Github external
def cmd_list_profiles(argv0, argv):
	"""
	Lists available profiles
	
	Usage: scc list-profiles [-a]
	
	Arguments:
	  -a   Include names begining with dot
	"""
	from scc.paths import get_profiles_path, get_default_profiles_path
	paths = [ get_default_profiles_path(), get_profiles_path() ]
	include_hidden = "-a" in argv
	lst = set()
	for path in paths:
		try:
			for x in os.listdir(path):
				if x.endswith(".sccprofile"):
					if not include_hidden and x.startswith("."):
						continue
					lst.add(x[0:-len(".sccprofile")])
		except OSError:
			pass
	for x in sorted(lst):
		print x
	return 0
github kozec / sc-controller / python / scc / gui / app.py View on Github external
def new_profile(self, profile, name):
		filename = os.path.join(get_profiles_path(), name + ".sccprofile")
		self.current_file = Gio.File.new_for_path(filename)
		self.save_profile(self.current_file, profile)
		controller = self.profile_switchers[0].get_controller()
		if controller:
			controller.set_profile(filename)
		else:
			self.dm.set_profile(filename)
		self.profile_switchers[0].set_profile(name, create=True)
github kozec / sc-controller / python / scc / gui / global_settings.py View on Github external
def _save_osk_profile(self, profile):
		"""
		Saves on-screen keyboard profile and calls daemon.reconfigure()
		Used by methods that are changing it.
		"""
		profile.save(os.path.join(get_profiles_path(),
				OSDKeyboard.OSK_PROF_NAME + ".sccprofile"))
		self.app.dm.reconfigure()
github kozec / sc-controller / scc / tools.py View on Github external
def find_profile(name):
	"""
	Returns filename for specified profile name.
	This is done by searching for name + '.sccprofile' in ~/.config/scc/profiles
	first and in /usr/share/scc/default_profiles if file is not found in first
	location.
	
	Returns None if profile cannot be found.
	"""
	filename = "%s.sccprofile" % (name,)
	for p in (get_profiles_path(), get_default_profiles_path()):
		path = os.path.join(p, filename)
		if os.path.exists(path):
			return path
	return None
github kozec / sc-controller / python / scc / tools.py View on Github external
def profile_is_override(name):
	"""
	Returns True if named profile exists both in user config directory and
	default_profiles directory.
	"""
	filename = "%s.sccprofile" % (name,)
	if os.path.exists(os.path.join(get_profiles_path(), filename)):
		if os.path.exists(os.path.join(get_default_profiles_path(), filename)):
			return True
	return False
github kozec / sc-controller / scc / gui / app.py View on Github external
def generate_new_name(self):
		"""
		Generates name for new profile.
		That is 'New Profile X', where X is number that makes name unique.
		"""
		i = 1
		new_name = _("New Profile %s") % (i,)
		filename = os.path.join(get_profiles_path(), new_name + ".sccprofile")
		while os.path.exists(filename):
			i += 1
			new_name = _("New Profile %s") % (i,)
			filename = os.path.join(get_profiles_path(), new_name + ".sccprofile")
		return new_name