Skip to content

Commit

Permalink
Simple console interface
Browse files Browse the repository at this point in the history
  • Loading branch information
Xifax committed Feb 18, 2014
1 parent 4652277 commit d7cf66e
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions cornucopify.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import uuid
import ConfigParser
import os
import cmd

# init paths and commands
dconf_path = '/org/gnome/terminal/legacy/profiles:'
Expand Down Expand Up @@ -35,13 +36,15 @@ def remove_profiles(theme_name):
"""Remove profiles based on visible name"""
existing_profiles = get_profile_list()

removed = 0
for profile in existing_profiles:
visible_name = os.popen(
'%s %s/:%s/visible-name' %
(dconf_read, dconf_path, profile)
).read().strip().strip("'")
# remove profile, if name matches
if visible_name == theme_name:
removed += 1
os.system(
'%s "%s/:%s/"' %
(dconf_reset, dconf_path, profile)
Expand All @@ -55,6 +58,8 @@ def remove_profiles(theme_name):
(dconf_write, dconf_path, profiles)
)

return removed


def create_profile(theme_name):
"""Create new profile and update profile list"""
Expand Down Expand Up @@ -140,8 +145,28 @@ def write_themes(themes):
for theme_name, colors in themes.iteritems():
write_theme(theme_name, colors)

return themes


class Cornucopifier(cmd.Cmd):
"""Initialize or remove gnome profiles"""

def do_write(self, line):
"""Write all themes from ini to gnome profile"""
themes = write_themes(get_themes())
print 'Total new themes: %d' % len(themes)

def do_remove(self, theme):
"""Remove all profiles with the name [theme]"""
total = remove_profiles(theme)
print 'Total themes removed: %d' % total

def do_EOF(self, line):
"""Exit"""
return True

def postloop(self):
print

# TODO: include function batch remove profiles by name (not by id)
if __name__ == '__main__':
#write_themes(get_themes())
remove_profiles('monokai')
Cornucopifier().cmdloop()

0 comments on commit d7cf66e

Please sign in to comment.