Skip to content

Commit

Permalink
20191230 Update
Browse files Browse the repository at this point in the history
- Complete rework of code

- Various bug-fixes

- Added unit tests

- CI and Coverage
  • Loading branch information
stav121 committed Dec 30, 2019
1 parent 6df8514 commit c42f438
Show file tree
Hide file tree
Showing 116 changed files with 2,363 additions and 1,423 deletions.
33 changes: 33 additions & 0 deletions .circleci/config.yml
@@ -0,0 +1,33 @@
version: 2
jobs:
build:
working_directory: ~/i3wm-themer
docker:
- image: circleci/python:3.6.4
steps:
- checkout
- run: sudo chown -R circleci:circleci /usr/local/bin
- run: sudo chown -R circleci:circleci /usr/local/lib/python3.6/site-packages
- restore_cache:
key: deps10-{{ .Branch }}-{{ checksum "Pipfile.lock" }}
- run:
name: Setup testing environment
command: |
pip install coverage --user
pip install pytest --user
pip install -r requirements.txt
echo $HOME
- save_cache:
key: deps9-{{ .Branch }}-{{ checksum "Pipfile.lock" }}
paths:
- ".venv"
- "/usr/local/bin"
- "/usr/local/lib/python3.6/site-packages"
- run:
name: Running tests
command: |
$HOME/.local/bin/coverage run -m pytest
$HOME/.local/bin/coverage report --include="i3wmthemer/*"
$HOME/.local/bin/coverage html
- store_artifacts:
path: htmlcov
11 changes: 9 additions & 2 deletions .gitignore
@@ -1,2 +1,9 @@
src/__pycache__
src/*.pyc
test-reports/
.pytest_cache/
*__pycache__
*.pyc
.idea/
*.iml
./*.png
./*.jpg
.coverage
12 changes: 12 additions & 0 deletions Pipfile
@@ -0,0 +1,12 @@
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]

[packages]
PyYAML = "==5.1"

[requires]
python_version = "3.6"
38 changes: 38 additions & 0 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 11 additions & 33 deletions README.md
@@ -1,22 +1,16 @@
<h1>i3wm-themer</h1>
<h1>i3wm-themer</h1>

![](https://img.shields.io/circleci/build/github/unix121/i3wm-themer/master)
![](https://img.shields.io/codacy/coverage/79aa404309114b25bdc87f00107a0b94/master)
![](https://img.shields.io/codacy/grade/79aa404309114b25bdc87f00107a0b94/master)
![](https://img.shields.io/github/last-commit/unix121/i3wm-themer/master)
![](https://img.shields.io/github/license/unix121/i3wm-themer)
<ul>
Personal collection of themes and scripts for <a href="https://www.i3wm.org">i3wm</a>.

![](workflow/workflow.gif?raw=true)
</ul>

<h3>Update [April 4, 2018]</h3>
<ul>
Due to the high amount of requests to update this repository, I took the time to *completely* rework
it from the ground up. The old script is gone, the old configs are long gone. There is a <a
href="src/i3wm-themer.py">new script</a> used to apply/modify the themes for i3wm, polybar and .Xresources, all the old themes have been
reworked and a few new added. The script now uses a <a href="src/config.yaml">configuration file</a> used to locate your configs
more accurately and the themes are now presented in a <a href="src/themes">JSON</a> format to make them easier to read/modify/add your own.
This time I decided to add a few <a href="src/defaults">default configuration files</a> for you to use, to avoid the "oh my dots are now
messed up" complains. With all that said, I hope you enjoy the fully reworked repo, I put a lot of
effort to make it meet everyone's needs/likings.
</ul>

<h1>Why?</h1>
<ul>
<li>You like CLI tools too much</li>
Expand Down Expand Up @@ -65,7 +59,7 @@ Either manually or use one of the scripts created for some distros:
If you are not on one of the above, install them using your Package manager.

Make sure you have the requirements mentioned earlier installed.
Edit the <a href="src/config.yaml">config.yaml</a> file and add your full path of i3wm config, polybar config and .Xresources
Edit the <a href="defaults/config.yaml">config.yaml</a> file and add your full path of i3wm config, polybar config and .Xresources
files. In the end it should look something like this:

i3-config: /home/[USER]/.i3/config
Expand All @@ -74,11 +68,9 @@ files. In the end it should look something like this:

Where `[USER]` is your `$USER`.

All further commands are to be executed from the /src directory.

Copy the script in the <a href="scripts/">scripts</a> folder to your polybar directory:

cp -r ../scripts/* /home/$USER/.config/polybar/
cp -r scripts/* /home/$USER/.config/polybar/

Backup your files:

Expand All @@ -88,7 +80,7 @@ Backup your files:
This step will copy the files that you set in the `config.yaml` for safekeeping in case things go
wrong.

Install the `config files` located in the <a href="src/defaults">src/defaults/</a> directory (not 100% required but
Install the `config files` located in the <a href="defaults">defaults/</a> directory (not 100% required but
I suggest you do so just to be sure).

python i3wm-themer.py --config config.yaml --install defaults/
Expand Down Expand Up @@ -118,31 +110,17 @@ caution!

<h2>Available Themes</h2>
<ul>
Just take a look at the <a href="src/themes/">Theme collection</a> and pick the ones you like.
Just take a look at the <a href="themes/">Theme collection</a> and pick the ones you like.

![](workflow/themepreview.png?raw=true)

</ul>

<h2>Contribute to the project</h2>
<ul>
If you want to contribute to the project you can do it in two ways:
<ul>
<li>Add new themes by following this <a href="templates/README.md">guide</a></li>
<li>Help with the script by helping cross out more things from the <a href="src/README.md">TODO</a> list</li>
</ul>
</ul>

<h2>Author</h2>
<ul>
<a href="https://github.com/unix121">Stavros Grigoriou (unix121)</a>
</ul>

<h2>Support this project</h2>
<ul>
<a href="https://patreon.com/unix121">Patreon</a>
</ul>

<h2>Credits</h2>
<ul>
This whole project wouldn't be possible without the creators of all those awesome tools:
Expand Down
Empty file added __init__.py
Empty file.
3 changes: 1 addition & 2 deletions change.sh
@@ -1,5 +1,4 @@
#!/bin/env sh
### Script written by James Shane ( github.com/jamesshane )

cd src
python i3wm-themer.py --config config.yaml --load themes/$1.json
python i3wm-themer.py --config config.yaml --load themes/"$1".json
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
46 changes: 46 additions & 0 deletions i3wm-themer.py
@@ -0,0 +1,46 @@
#!/bin/env python3

"""
i3-wm theme changing utility.
Author : Stavros Grigoriou (@unix121)
"""

import argparse

from i3wmthemer.models.configuration import ConfigurationLoader
from i3wmthemer.models.theme import Theme
from i3wmthemer.utils.backup import BackupUtils
from i3wmthemer.utils.fileutils import FileUtils
from i3wmthemer.utils.install import InstallationUtils

if __name__ == "__main__":
parser = argparse.ArgumentParser(description='i3wm-themer by Stavros Grigoriou (@unix121)')
parser.add_argument('-c', '--config', type=str, required=True, help='Load config file')
parser.add_argument('-b', '--backup', type=str, help='Backup files')
parser.add_argument('-i', '--install', type=str, help='Install i3wm-themer\'s default configuration files')
parser.add_argument('-l', '--load', type=str, help='Load theme from JSON file')
args = parser.parse_args()

# TODO :: Default
if args.config is None:
exit(0)

# Load the configuration
configLoader = ConfigurationLoader(args.config)
configuration = configLoader.load()

if args.backup is not None:
BackupUtils.backup_config(args.backup, configuration)
exit(0)

if args.install is not None:
InstallationUtils.install_defaults(args.install, configuration)
configuration.refresh_all('')
exit(0)

if args.load is not None:
file = FileUtils.load_theme_from_file(args.load)
theme = Theme(file)
theme.load(configuration)
exit(0)
Empty file added i3wmthemer/__init__.py
Empty file.
Empty file.
84 changes: 84 additions & 0 deletions i3wmthemer/enumeration/attributes.py
@@ -0,0 +1,84 @@
from enum import Enum, unique


@unique
class XresourcesAttr(Enum):
"""
Attributes that should be parsed from the configuration file for Xresources.
"""
NAME = 'xresources'
BACKGROUND = 'background'
FOREGROUND = 'foreground'
CURSOR = 'cursorcolor'
COLOR0 = 'color0'
COLOR1 = 'color1'
COLOR2 = 'color2'
COLOR3 = 'color3'
COLOR4 = 'color4'
COLOR5 = 'color5'
COLOR6 = 'color6'
COLOR7 = 'color7'
COLOR8 = 'color8'
COLOR9 = 'color9'
COLOR10 = 'color10'
COLOR11 = 'color11'
COLOR12 = 'color12'
COLOR13 = 'color13'
COLOR14 = 'color14'
COLOR15 = 'color15'
ROFI_WIND = 'rofi.color-window'
ROFI_NORM = 'rofi.color-normal'
ROFI_ACTI = 'rofi.color-active'
ROFI_URGE = 'rofi.color-urgent'


@unique
class I3Attr(Enum):
"""
Attributes that should be parsed from the configuration file for i3.
"""
NAME = 'i3wm'
BACKGROUND = 'client.background'
FOCUSED = 'client.focused'
UNFOCUSED = 'client.unfocused'
INACTIVE = 'client.focused_inactive'
URGENT = 'client.urgent'
PLACEHOLDER = 'client.placeholder'


@unique
class PolybarAttr(Enum):
"""
Attributes that should be parsed from the configuration file for Polybar.
"""
NAME = 'polybar'
BACKGROUND = 'background'
FOREGROUND = 'foreground'
MOD_L = 'modules-left'
MOD_C = 'modules-center'
MOD_R = 'modules-right'
LABEL_UN_BACK = 'label-unfocused-background'
LABEL_UN_FORE = 'label-unfocused-foreground'
LABEL_MOD_BACK = 'label-mode-background'
LABEL_MOD_FORE = 'label-mode-foreground'
LABEL_FOC_BACK = 'label-focused-background'
LABEL_FOC_FORE = 'label-focused-foreground'
LABEL_VIS_BACK = 'label-visible-background'
LABEL_VIS_FORE = 'label-visible-foreground'
FORMAT_BACK = 'format-background'
FORMAT_FORE = 'format-foreground'
LABEL_OPEN_FORE = 'label-open-foreground'
LABEL_CLOSE_FORE = 'label-close-foreground'
LABEL_SEP_FOREGROUND = 'label-separator-foreground'
FORMAT_CON_FORE = 'format-connected-foreground'
FORMAT_CON_BACK = 'format-connected-background'
FORMAT_CON_PRE_FORE = 'format-connected-prefix-foreground'
RAMP_SIG_FOREGROUND = 'ramp-signal-foreground'


@unique
class NitrogenAttr(Enum):
"""
Attributes that should be parsed from the configuration file for Nitrogen.
"""
NAME = 'wallpaper'
Empty file added i3wmthemer/models/__init__.py
Empty file.
17 changes: 17 additions & 0 deletions i3wmthemer/models/abstract_theme.py
@@ -0,0 +1,17 @@
from abc import ABC, abstractmethod


class AbstractTheme(ABC):
"""
Abstract Theme.
"""

@abstractmethod
def load(self, configuration):
"""
Method that must be implemented.
Should load the theme in the proper file in the configuration.
:param configuration: the configuration.
"""
raise NotImplementedError

0 comments on commit c42f438

Please sign in to comment.