예제 #1
0
def get_pngbytes(icon):
    """Return the pngbytes of a svg/png icon."""
    from src.app import App
    icon_for_replace = icon.theme
    icon_extension = icon.theme_ext
    icon_size = icon.icon_size
    if icon_extension == 'svg':
        if icon_size != App.icon_size():
            png_bytes = App.svg().to_bin(icon_for_replace, App.icon_size())
        else:
            png_bytes = App.svg().to_bin(icon_for_replace)
    elif icon_extension == "png":
        with open(icon_for_replace, 'rb') as png_file:
            png_bytes = png_file.read()
    else:
        png_bytes = None
    return png_bytes
예제 #2
0
    def install_icon(self, icon, icon_path):
        """Install icon to the current directory."""
        ext_orig = icon.orig_ext
        theme_icon = icon.theme
        ext_theme = icon.theme_ext
        icon_size = icon.icon_size
        output_icon = path.join(str(icon_path), icon.original)

        # Backup the output_icon
        if not self.backup_ignore:
            self.backup.create(output_icon)

        if ext_theme == ext_orig:
            if theme_icon != output_icon:
                symlink_file(theme_icon, output_icon)
        elif ext_theme == "svg" and ext_orig == "png":
            from src.app import App
            if icon_size != App.icon_size():
                App.svg().to_png(theme_icon, output_icon, App.icon_size())
            else:
                App.svg().to_png(theme_icon, output_icon)

            mchown(output_icon)
예제 #3
0
args = parser.parse_args()
App.set_args(args)

if (not DESKTOP_ENV or DESKTOP_ENV == "other") and not App.icon_size():
    exit(_("You need to run the script using 'sudo -E'.\nPlease try again"))

print(_("Welcome to Hardcode-Tray!"))
print(_("Desktop Environment: {}").format(DESKTOP_ENV.title()))
print(_("Scaling Factor: {}").format(App.scaling_factor()))
print(_("Icon Size: {}").format(App.icon_size()))
if not isinstance(App.theme(), dict):
    print(_("Icon Theme: {}").format(App.theme()))
else:
    print(_("Dark Icon Theme: {}").format(App.theme("dark")))
    print(_("Light Icon Theme: {}").format(App.theme("light")))
print(_("Conversion Tool: {}").format(App.svg()))
print(_("To Do: "), end="")
print(", ".join(map(lambda x: x.title(), App.get("only")))
      if App.get("only") else _("All"))


action = App.get("action")
if action == Action.APPLY:
    print(_("Applying now.."))
elif action == Action.REVERT:
    print(_("Reverting now.."))
elif action == Action.CLEAR_CACHE:
    print(_("Clearing cache..."))
print("\n")
App.execute()