Coder Social home page Coder Social logo

themer's Introduction

Themer

Themer is a colorscheme generator and manager for your Linux desktop.

Installation

AUR (Arch)

Install python-themer-git with the AUR manager of your choice, for example trizen:

$ trizen -S python-themer-git

or perform a manual build if you prefer:

$ git clone https://aur.archlinux.org/packages/python-themer-git
$ cd python-themer
$ makepkg -sic

PyPi

themer is now available in the PyPi repository as well. You can use a pip to install it:

$ pip install themer

Manual Installation

First, check out the git repository:

$ git clone https://github.com/s-ol/themer.git

Install with python setup.py install

$ cd themer
$ sudo python setup.py install

Configuration

You can create multiple template dirs for themer in ~/.config/themer/templates. The default template is i3, see data/default for the default configuration.

Structure of Themer

The main directory

Everything Themer does happens in .config/themer/. In short, things are created from templates and end up in current.

In a running setup this directory will contain the following:

  • templates, a directory holding the templates for all your themes. This is where new themes are generated from.
  • an arbitrary number of themes (which are directories). These hold the config files that are specifically generated for this one theme. (They also contain a file called colors.yaml, where you can look up and change variables used in the theme.) These themes are for internal use mostly and while you can create these themes by hand, most of the time you won't.
  • current, a symbolic link to the currently active theme directory.

For most people templates only holds 1 directory (called i3 by default) for their setup. If you like to switch your DE or the general appearance of your window manager you might want to add more of them. If you are only interested in small changes like colors and wallpapers (which don't change the structure of your configs, only the details) you are probably fine with one. (This is an abstraction layer which exists for historical reasons and might be removed in the future).

The templates

So what does a template look like? A useful template contains:

  • One or more file-templates. They should (but don't have to) end with .tpl and contain your config. Variables should have the form {{ variable_name }} and will be replaced by their value when themer renders them.
  • A (potentially empty) directory of plugins. If plugins are placed here they can be activated by mentioning them in config.yaml
  • config.yaml, which tells themer how to use the other files.

config.yaml has 3 sections:

  • variables, where primary: red means hat the files listed below will be rendered with {{ primary }} replaced by red
  • plugins, divided in parsers and activators, each with a list of activated plugins.
  • files, where fromfile: tofile means that fromfile (which is supposed to be the name of a file-template) is rendered to tofile in the rendered theme.

Usage

Integrating Themer with your Setup

All the following steps will show you how to use themer to generate themes, but you also need to configure your DE to use the generated theme.

themer does not assume anything about the tools you use in your DE, you need to tell your DE about themer. The current theme will always be available in $XDG_HOME/themer/current (usually .config/themer/current). To use themer, symlink the seperate files from there to their destination.

For example, this is how to set up i3 with themer:

$ mkdir -p .i3
$ ln -s ~/.config/themer/current/i3.conf .i3/config

Generating Themes

Generate a theme from a wallpaper:

$ themer generate themename wallpaper.png

...or install a colorscheme from sweyla.com:

$ themer generate themename 693812

(this will install http://sweyla.com/themes/seed/693812/)

you can also use an Xresources-style file:

$ themer generate themename /home/me/.Xresources

Plugins enable you to generate themes from other sources as well, see below.

Viewing Installed Themes

You can list all generated themes with themer list:

$ themer list
themeone
themetwo

Viewing Installed Plugins

$ themer plugins
Enabled activators:
  themer.activators.wallfix.WallfixActivator
  themer.activators.i3.I3Activator
Enabled parsers:
  themer.parsers.SweylaColorParser
  themer.parsers.KmeansColorParser
  themer.parsers.CachedColorParser
  themer.ColorParser

Activating Themes

You can activate an existing theme with themer activate:

$ themer activate sometheme

This will symlink all defined templates to ~/.config/themer/current. You should, in turn, symlink all the global configuration files to there. For example for i3:

$ ln -s ~/.config/themer/current/i3.conf ~/.i3/config

To view the currently activated theme's colors use themer current.

If you have modified the templates or a themes colors.yaml, activating the theme again will not apply those changes. Instead use themer render to update your configuration:

$ themer render sometheme

You can also re-render all of your themes (for example if you changed a lot in your configuration) by supplying all instead of a theme's name:

$ themer render all

Deleting Themes

Deleting generated themes is possible using themer delete:

$ themer delete sometheme

Screenshots

Plugins

Plugins can be installed anywhere into your PYTHONPATH, but the plugins directory under the used template dir is automatically added to sys.path, so you may want to place them there (usually this is ~/.config/themer/templates/i3/plugins). They are loaded via their python module-an-classname string; e.g. mymodule.activator.MyActivator. Plugins are configured on a template-directory basis, in the config.yaml file (default ~/.config/themer/templates/i3/config.yaml).

There are two kinds of plugins: Activators and Parsers. Activators should inherit from themer.ThemeActivator, Parsers should inherit from themer.ColorParser.

ThemeActivators

Activators are run once every time a theme is activated. Use them to reload configuration files, set desktop wallpapers etc.

Each Activator should implement the method activate. The constructor is passed the values for theme_name, theme_dir and logger. All of these and colors can be accessed via the instance's properties.

Example:

from themer import ThemeActivator
import os

class I3Activator(ThemeActivator):
    def activate(self):
        os.system('i3-msg -q restart')

ColorParsers

Parsers are used to generate colorschemes from files and strings.

Each ColorParser should implement the method read, which should return the color dictionary generated from the input string in self.data (or obtained via the constructor's first argument). A ColorParser can additionally return a path to a wallpaper to be used by setting self.wallpaper to anything other than None.

Additionally, Parsers need to have a check attribute. It is used to determine whether a Parser should be used for a given color source. check can either be a function, in which case it is passed the color-source string and expected to return a truthy value if it wants to handle that color source, or a string. If it is a string it will be used as a regex and matched against the color source string.

The themer.check_file_regex helper can be used to build a check function that checks filenames against a regex and verifies their existence on the filesystem.

The constructor is passed the values for data, config and logger. All of these can be accessed via the instance's properties. The default constructor also sets self.colors to a new dictionary and self.wallpaper to None.

Example:

from themer import ColorParser, check_file_regex

class NewColorParser(ColorParser):
    check = check_file_regex('\.yaml$')
    def read(self):
        with open(self.data) as fh: # load colors from a yaml file
            self.colors = yaml.load(fh)
        return self.colors

Credits

Original script by Charles Leifer
Maintained and developed further by Sol Bekic

themer's People

Contributors

97-109-107 avatar amar1729 avatar artur-shaik avatar averybiskup avatar betapundit avatar cheripai avatar glg-mbarillet avatar haltode avatar jotran avatar kaligule avatar magnetotail avatar morteza25 avatar nsand avatar phijor avatar rapidash1 avatar ritece avatar s-ol avatar soudini avatar ssebs avatar zarak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

themer's Issues

"too many values to unpack" in KmeansColorParser

Traceback (most recent call last):
  File "/usr/bin/themer", line 284, in <module>
    generate(color_file, config, template_dir, theme_name)
  File "/usr/bin/themer", line 136, in generate
    colors = parse.read()
  File "/usr/lib/python3.4/site-packages/Themer-1.0-py3.4.egg/themer/parsers/__init__.py", line 158, in read
  File "/usr/lib/python3.4/site-packages/Themer-1.0-py3.4.egg/themer/parsers/__init__.py", line 141, in get_dominant_colors
  File "/usr/lib/python3.4/site-packages/kmeans/__init__.py", line 103, in kmeans
    tolerance=tolerance, max_iterations=max_iterations)
  File "/usr/lib/python3.4/site-packages/kmeans/__init__.py", line 60, in _kmeans
    (r, g, b), count = center
ValueError: too many values to unpack (expected 3)

Cannot properly read wallpaper

I'm having issues running themer on Archlinux with i3wm.

When I run themer generate test wallpaper (wallpaper can either be .jpg or .png it doesn't change anything), I always get the same config generated by themer. And when I look at the wallpaper in the generated theme I get this:

wallpaper

I have no problem seing the original wallpaper with feh or other programs, and I tried with different wallpapers.

Clearify how config.yaml works

This file is almost undocumented. Especially interesting would be:

  • What values are allowed? Can I add a variable of any name if I want?
  • Which values are required? Can I remove any variable I don't care fore (eg "transparency")
  • If I generate a theme from a picture, what variables are set?
  • If I dont specify a template underr "files:" but it exists in the file system, will it be rendered to a default or just be ignored? What happens if it is specified but does not exist?

`generate` silently, seemingly randomly fails

I must be doing something wrong since no one else seems to be having this issue, but for me, themer generate [...] works only occasionally. This seems to be input image-dependent.

For some images, I get a complaint about not using PyPI:

Falling back to python kmeans implementation.
            Consider installing 'kmeans' from PyPI for much faster image sampling
Activate now? yN

This is the only case when themer generate actually works. About 5/34 images do this, i.e. actually work.

For others, I just get a nag about activating the theme:

Activate now? yN

These generate the correct colors in colors.yaml, however looking at wallpaper.png I always get a piece of abstract art like this:
wallpaper
The shapes are always the same, but their colors change depending on the colors in the input image. This is the most usual: 27/34 images induce this behavior.

Still others simply crash:

Traceback (most recent call last):
  File "/usr/bin/themer", line 294, in <module>
    generate(color_file, config, template_dir, theme_name)
  File "/usr/bin/themer", line 145, in generate
    colors = parse.read()
  File "/usr/lib/python3.5/site-packages/themer/parsers/__init__.py", line 158, in read
    colors = self.get_dominant_colors()
  File "/usr/lib/python3.5/site-packages/themer/parsers/__init__.py", line 141, in get_dominant_colors
    rgbs = kmeans.kmeans(points, self.k)
  File "/usr/lib/python3.5/site-packages/themer/parsers/__init__.py", line 93, in kmeans
    distance = self.ec_dist(p, clusters[i][1])
  File "/usr/lib/python3.5/site-packages/themer/parsers/__init__.py", line 73, in ec_dist
    sum((a[0][i] - b[0][i]) ** 2 for i in range(3)))
  File "/usr/lib/python3.5/site-packages/themer/parsers/__init__.py", line 73, in <genexpr>
    sum((a[0][i] - b[0][i]) ** 2 for i in range(3)))
TypeError: 'int' object is not subscriptable

This is the most rare — about 2/34.

What's going on? I installed themer from AUR:

➜  ~ pacman -Qs python-themer
local/python-themer-git v1.6.r0.gfc24e5b-1

Any help will be appreciated.

wallfix.py doesn't set wallpaper

This might be a mistake on my site but it looks to me like wallfix.py creates and crops wallpapers, but doesn't activate them. Am I supposed to have an extra activator for that? Then why does it log "Setting wallpaper"?

Where are template destinationions defined?

If I wanted to add a new template to be compiled along with the default ones, I figure I could go ahead and add it here and create the appropriate template.

files:
  xresources.tpl: Xresources
  index.tpl: index.html
  i3status.tpl: i3status.conf
  i3.tpl: i3.conf
  new.tpl: new.conf

What I'm unsure about is how where do I define where new.conf should be placed after rendering.

KeyError 'Plugins'

When I installed themer and try running the "themer plugins" command, i get this error:

Enabled activators:
Traceback (most recent call last):
  File "/usr/bin/themer", line 4, in <module>
    __import__('pkg_resources').run_script('Themer==1.0', 'themer')
  File "/usr/lib/python3.4/site-packages/pkg_resources/__init__.py", line 723, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/usr/lib/python3.4/site-packages/pkg_resources/__init__.py", line 1643, in run_script
    exec(script_code, namespace, namespace)
  File "/usr/lib/python3.4/site-packages/Themer-1.0-py3.4.egg/EGG-INFO/scripts/themer", line 218, in <module>
KeyError: 'plugins'

Add jinja filters for color formatting in templates

Hi,
it seems that by default, the colors are formatted as #RRGGBB. Only information I could find about the syntax for template files were the i3 examples — is it possible to format colors differently? For example, transparency in lemonbar is specified in the color as #AARRGGBB. If you want transparency in Termite, you need rgba(r, g, b, a), where r, g, b are 8-bit ints and a is a float. With lemonbar, I can transform to the correct format with bash, but I have no idea how to handle Termite.

No such file or directory: '/usr/share/themer/default'

Hi,

I tried to install themer via pip and are receiving No such file or directory: '/usr/share/themer/default' whenever I try to start it. I am noting that there is no such thing as a /usr/share/themer/ on my computer.

Is this a bug or is it a feature? I am running the latest version of Fedora 26.

AttributeError: module 're' has no attribute '_pattern_type'

Just got this after installing with pip and trying out:

Traceback (most recent call last):
  File "/home/ben/.local/bin/themer", line 323, in <module>
    generate(color_file, config, template_dir, theme_name, options.bright)
  File "/home/ben/.local/bin/themer", line 167, in generate
    if (isinstance(parser.check, str) or isinstance(parser.check, re._pattern_type)) and not re.search(parser.check, color_source, re.IGNORECASE):
AttributeError: module 're' has no attribute '_pattern_type'

I'm not versed in Python, but re appears to have gotten an update that changes the API.

Generating theme error in wallfix.py

Whenever I try to generate any theme, I get this error:

Traceback (most recent call last):
File "/usr/bin/themer", line 266, in
load_plugins(config)
File "/usr/bin/themer", line 191, in load_plugins
plugins[kind].append(imp(name))
File "/usr/bin/themer", line 184, in imp
mod = import('.'.join(name.split('.')[:-1]))
File "/usr/lib/python3.5/site-packages/themer/activators/wallfix.py", line 22, in
RATIO = float(WIDTH) / HEIGHT
NameError: name 'WIDTH' is not defined

Seperate Color-parsing and "themer generate"

I would like a more generalized architecture where Parsers can not only set colors but also other parameters and where parsers may not set colors for example.

themer generate might need to be modified so that it supports using multiple parsers at the same time. Maybe something like
themer generate name wallpaper.jpg someparam:value https://fontfrom.he/re could work?
Every parameter parsed seperately by a (different) parser.

"unexpected keyword argument 'make_bright'" when generating from .Xresources

When trying to generate a theme from a ~/.Xresources file, i get this error:

[karl@karlLaptop i3]$ themer generate i3 $HOME/.Xresources
Traceback (most recent call last):
File "/usr/bin/themer", line 323, in <module>
    generate(color_file, config, template_dir, theme_name, options.bright)
File "/usr/bin/themer", line 169, in generate
    parse = parser(color_source, config, logger, make_bright=bright)
TypeError: __init__() got an unexpected keyword argument 'make_bright'

Writing a better README

need to write a better readme file so that noobs like me could understand.Sorry if I was rude

Kmeans fails for PNGs

At least very often?

Traceback (most recent call last):
  File "/usr/bin/themer", line 294, in <module>
    generate(color_file, config, template_dir, theme_name)
  File "/usr/bin/themer", line 145, in generate
    colors = parse.read()
  File "/usr/lib/python3.4/site-packages/themer/parsers/__init__.py", line 202, in read
    res = super(WallhavenColorParser, self).read(*args)
  File "/usr/lib/python3.4/site-packages/themer/parsers/__init__.py", line 158, in read
    colors = self.get_dominant_colors()
  File "/usr/lib/python3.4/site-packages/themer/parsers/__init__.py", line 141, in get_dominant_colors
    rgbs = kmeans.kmeans(points, self.k)
  File "/usr/lib/python3.4/site-packages/kmeans/__init__.py", line 103, in kmeans
    tolerance=tolerance, max_iterations=max_iterations)
  File "/usr/lib/python3.4/site-packages/kmeans/__init__.py", line 60, in _kmeans
    (r, g, b), count = center
ValueError: too many values to unpack (expected 3)

setup.py tries to install to root instead of fake-root, fails on Arch

I tried to install themer from the AUR, but it always failed with:

error: could not create directory '/usr/share/themer'

After a bit of digging, I found out that setup.py tries to install to root, which one does not have the permissions to when building from AUR. Instead, the package should try to install to the current working directory, aka the fake-root --root="${pkgdir}".

I forked themer and removed the prefix / and it now happily builds with makepkg.

Merge themer-render and themer-activate

Split from #46.

This means always rendering to current and not storing anything except colors.yaml (which should be called something better) and the source file(s) / wallpaper in the theme directory.

Better module structure

  • Move default ColorParsers and ThemeActivators into a file separate from the Interfaces.
  • Thin out the main script (Themer class in themer?)
  • Merge wallfix into the activator
  • Enable/Disable Plugins via config file -> allows to ship default activators more comfort- and compactly

"Can't find '__main__' module in 'themer'"

I have both Python 2.7 and Python 3 installed on 64-bit Linux Mint running in Virtualbox. Unfortunately, I have never written a line of Python in my life, and am running into this error when I run python3 themer generate themename ~/wallpaper.jpg:

/usr/bin/python3: can't find '__main__' module in 'themer'

If I run the command without python3, I get the same error as Issue 6:

Traceback (most recent call last):
  File "/usr/local/bin/themer", line 5, in <module>
    pkg_resources.run_script('Themer==1.0', 'themer')
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 528, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1400, in run_script
    script_code = compile(script_text,script_filename,'exec')
  File "/usr/local/lib/python2.7/dist-packages/Themer-1.0-py2.7.egg/EGG-INFO/scripts/themer", line 195
    print(msg,file=sys.stderr)
                  ^
SyntaxError: invalid syntax

I hope this is just a noob mistake on my end!

hex conversion in python 3.5

With Python 3.5.1 I get the following error when attempting to generate a theme from an image.

Kicked from themer/parsers/__init__.py at line 128:
TypeError: %x format: an integer is required, not float

This issue in another package deals with the same problem, indicating that the hex formatting is to blame.

Clearify how templates work (and use a better default name)

After instalation of themer I have the following structure in my .config/themer/templates

templates
└── i3
    ├── Xdefaults.tpl
    ├── config.yaml
    ├── i3.tpl
    ├── index.tpl
    └── plugins
        └── __init__.py

It is unclear to me (and not explained in the readme or elsewhere) why there is an Xdefaults template in the i3 directory. Shouldn't there only be i3-related files in there? I had expected something like:

templates
├── config.yaml
├── index.tpl
├── i3
|   └── i3.tpl
├── i3bar
|   └── i3bar.tpl
└── Xdefaults
    └── Xdefaults.tpl

Or perhaps:

templates
└── setupname
    ├── config.yaml
    ├── index.tpl
    ├── i3
    |   └── i3.tpl
    ├── i3bar
    |   └── i3bar.tpl
    └── Xdefaults
        └── Xdefaults.tpl

So it would be great if the readme could explain how the template directory should work and what goes into the config.

Wallfix Activator not found

On a new install, generating a theme fails when it cant find any activator.

themer generate default ~/Downloads/wallpaper.png 
Traceback (most recent call last):
  File "/usr/bin/themer", line 266, in <module>
    load_plugins(config)
  File "/usr/bin/themer", line 191, in load_plugins
    plugins[kind].append(imp(name))
  File "/usr/bin/themer", line 184, in imp
    mod = __import__('.'.join(name.split('.')[:-1]))
ImportError: No module named themer.activators.wallfix

Python 2.7 Compatibility

Hi there,

Trying to get themer working under Ubuntu. Have installed python-setuptools, python-yaml & python-markupsafe, and am now encountering the following issue when calling themer generate themename image:

Traceback (most recent call last):
  File "/usr/local/bin/themer", line 4, in <module>
    __import__('pkg_resources').run_script('Themer==0.5', 'themer')
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 534, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1444, in run_script
    script_code = compile(script_text, script_filename,'exec')
  File "/usr/local/lib/python2.7/dist-packages/Themer-0.5-py2.7.egg/EGG-INFO/scripts/themer", line 211
    print(msg,file=sys.stderr)
                  ^
SyntaxError: invalid syntax

Any pointers?

Cheers!

Do you have a logo?

I'm an aspiring Graphic Designer, and student in programming and Information Technology. I want to give back to the industry by participating in Open Source Projects.

I will create a logo and any other graphic that you might need, and most likely help with the coding when I'm skilled enough.
Thanks.

path relative to?

Hi there - in the setup you mention:

For example, this is how to set up i3 with themer:

$ mkdir -p .i3
$ ln -s ~/.config/themer/current/i3.conf .i3/config

Is the $ mkdir -p .i3 command relative to your home directory?

Also - my true I3 config is sitting in something like ~/Documents/GIT/i3-config with symlinks over to ~/.config/i3/config

Anything special needed to account for that?

What is the full process for adding a plugin?

I'm in the middle of writing an iTerm2 parser to generate colorschemes for iTerm2. So far, I've:

  • written a file iTerm.py with the appropriate definition and class functions for a ColorParser
  • placed it in ~/.config/themer/templates/i3/plugins
  • placed it in themer's env/lib/python2.7/site-packages/themer/plugins/ directory
  • added the line - themer.parsers.iTerm to config.yaml under plugins/parsers
  • written the iterm2.tpl file and placed it under ~/.config/themer/templates/i3/ (with the other .tpls)
  • added the line iterm2.tpl: iterm.itermcolors to config.yaml under files

Output of $ themer plugins:

Enabled activators:
	themer.activators.wallfix.WallfixActivator
	themer.activators.i3.I3Activator
Enabled parsers:
	themer.parsers.SweylaColorParser
	themer.parsers.WallhavenColorParser
	themer.parsers.KmeansColorParser
	themer.parsers.CachedColorParser
	themer.parsers.unsplash.UnsplashColorParser
	themer.ColorParser
	themer.parsers.iTerm

However, the output of $ themer -d generate cm ~/wallpapers/cloudmountain.jpg:

Reading config file: /Users/Amar/.config/themer/templates/i3/config.yaml
xrandr: Failed to get size of gamma for output default
Loaded plugin "themer.activators.wallfix.WallfixActivator"
Loaded plugin "themer.activators.i3.I3Activator"
Loaded plugin "themer.parsers.SweylaColorParser"
Loaded plugin "themer.parsers.WallhavenColorParser"
Loaded plugin "themer.parsers.KmeansColorParser"
Loaded plugin "themer.parsers.CachedColorParser"
Loaded plugin "themer.parsers.unsplash.UnsplashColorParser"
Loaded plugin "themer.ColorParser"
Traceback (most recent call last):
  File "/Users/Amar/Documents/Projects/themer/env/bin/themer", line 268, in <module>
    load_plugins(config)
  File "/Users/Amar/Documents/Projects/themer/env/bin/themer", line 193, in load_plugins
    plugins[kind].append(imp(name))
  File "/Users/Amar/Documents/Projects/themer/env/bin/themer", line 188, in imp
    mod = getattr(mod, n)
AttributeError: 'module' object has no attribute 'iTerm'

Note: I am using a git clone'd version of themer (not from PyPi) and it's running under a virtual environment rather than having been sudo installed.

Rerendering a theme does not use new variables from config.yaml

When I tried to add new variables for fonts for different applications these did not get used after "themer render all". The placeholders were just left empty. When I generated a new theme I noticed, that my new variables suddenly appeared in the colors.yaml of the new theme. It seems that themer does not update the colors.yaml with new variables when these get added. Therefore it is not possible to add new variables by simply putting them in the config.yaml.

Allow cascading config.yaml s

Split from #46.

Look for a include key first and merge config into config found at that path location (recursively).

This should allow selectively overriding variables in a setup.
Note: objects need to be merged recursively and there should be a way to un-set a value.

Install default config using setuptools

» LayLowz » [~]: themer generate green_theme wallhaven-68460.png 
/usr/lib/python3/dist-packages/pkg_resources.py:1049: UserWarning: /home/LayLowz/.python-eggs is writable by group/others and vulnerable to attack when used with get_resource_filename. Consider a more secure location (set with .set_extraction_path or the PYTHON_EGG_CACHE environment variable).
  warnings.warn(msg, UserWarning)
Traceback (most recent call last):
  File "/usr/local/bin/themer", line 4, in &lt;module&gt;
    __import__('pkg_resources').run_script('Themer==1.0', 'themer')
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 534, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/usr/lib/python3/dist-packages/pkg_resources.py", line 1445, in run_script
    exec(script_code, namespace, namespace)
  File "/usr/local/lib/python3.4/dist-packages/Themer-1.0-py3.4.egg/EGG-INFO/scripts/themer", line 255, in &lt;module&gt;
  File "/usr/local/lib/python3.4/dist-packages/Themer-1.0-py3.4.egg/EGG-INFO/scripts/themer", line 59, in read_config
AttributeError: 'NoneType' object has no attribute 'get'

Am I doing something wrong with the install?

I'm not sure what i'm doing wrong, but i installed themer manually by cloning the repo, but when i try to run it, i get

Traceback (most recent call last):
  File "/usr/local/bin/themer", line 4, in <module>
    __import__('pkg_resources').run_script('Themer==1.8.2', 'themer')
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 742, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 1674, in run_script
    exec(script_code, namespace, namespace)
  File "/Library/Python/2.7/site-packages/Themer-1.8.2-py2.7.egg/EGG-INFO/scripts/themer", line 46, in <module>
    
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 171, in copytree
    names = os.listdir(src)
OSError: [Errno 2] No such file or directory: '/usr/share/themer/default'

Details:

  • Mac os sierra
  • python3.6.2 and python2.7.10
  • all dependencies of themer installed
  • Got hella red errors when i ran setup.py like _imaging.c:951:14: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32] or sometimes _imaging.c:559:25: warning: implicit conversion loses integer precision: 'long long' to 'int' [-Wshorten-64-to-32] ( i can't paste everything here because its way too long)
  • the reason i'm installing it manually is that when i installed it with pip3 , the command themer wasn't found

I'm not sure what i'm doing wrong, can someone please take a look? The script seems awesome and i can't wait to use it!

KeyError when running themer.

When running themer plugins, I get a KeyError on line 225 on 'plugins'

└─(✓)110$> themer plugins
Enabled parsers:
Traceback (most recent call last):
  File "/usr/bin/themer", line 225, in <module>
    for name in config['plugins'][kind]:
KeyError: 'plugins'

A similar issue appears when running themer generate (same error, different place):

└─(✗)111$> themer generate contrast ~/pictures/Contrast.jpg 
Traceback (most recent call last):
  File "/usr/bin/themer", line 263, in <module>
    load_plugins(config)
  File "/usr/bin/themer", line 188, in load_plugins
    for name in config['plugins'][kind]:
KeyError: 'plugins'

Images with alpha channel break kmeans and wallfix

If kmeans is installed from pypi, it's broken because themer passes (r, g, b, a) to it where it only expects (r, g, b). See the below exception

$ themer generate color-squares downloads/JmTbnY8.png
# example value ((31, 124, 141, 255), 1)
Traceback (most recent call last):
  File "/home/coxley/.local/bin/themer", line 323, in <module>
    generate(color_file, config, template_dir, theme_name, options.bright)
  File "/home/coxley/.local/bin/themer", line 170, in generate
    colors = parse.read()
  File "/home/coxley/.local/lib/python3.6/site-packages/themer/parsers/__init__.py", line 159, in read
    colors = self.get_dominant_colors()
  File "/home/coxley/.local/lib/python3.6/site-packages/themer/parsers/__init__.py", line 142, in get_dominant_colors
    rgbs = kmeans.kmeans(points, self.k)
  File "/home/coxley/.local/lib/python3.6/site-packages/kmeans/__init__.py", line 104, in kmeans
    tolerance=tolerance, max_iterations=max_iterations)
  File "/home/coxley/.local/lib/python3.6/site-packages/kmeans/__init__.py", line 61, in _kmeans
    (r, g, b), count = center
ValueError: too many values to unpack (expected 3)

Removing kmeans/manually patching fixes this however then it gets stopped writing

Falling back to python kmeans implementation.
            Consider installing 'kmeans' from PyPI for much faster image sampling
Activate now? yN y
Traceback (most recent call last):
  File "/home/coxley/.local/lib/python3.6/site-packages/PIL/JpegImagePlugin.py", line 602, in _save
    rawmode = RAWMODE[im.mode]
KeyError: 'RGBA'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/coxley/.local/bin/themer", line 336, in <module>
    activate(theme_name)
  File "/home/coxley/.local/bin/themer", line 157, in activate
    act.activate()
  File "/home/coxley/.local/lib/python3.6/site-packages/themer/activators/wallfix.py", line 90, in activate
    self.crop_wallpaper(wallpaper)
  File "/home/coxley/.local/lib/python3.6/site-packages/themer/activators/wallfix.py", line 76, in crop_wallpaper
    cropped.save(dest_jpg, 'JPEG', quality=100)
  File "/home/coxley/.local/lib/python3.6/site-packages/PIL/Image.py", line 1893, in save
    save_handler(self, fp, filename)
  File "/home/coxley/.local/lib/python3.6/site-packages/PIL/JpegImagePlugin.py", line 604, in _save
    raise IOError("cannot write mode %s as JPEG" % im.mode)
OSError: cannot write mode RGBA as JPEG


Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.