GithubHelp home page GithubHelp logo

marreknozka / i3-jinja-config Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 1.0 19 KB

Create an i3 config from Jinja2 template.

License: GNU General Public License v3.0

Python 100.00%
i3 i3wm i3-config i3-gaps jinja

i3-jinja-config's Introduction

i3-jinja-config

Create an i3 config from Jinja2 template.

Why?

I am managing multiple computers and my configuration depends on screen/display keyboard etc... ... depend on hostname.

Jinja2 temlate allows me to use conditions and to include configs into config.

Inspiration

How it Work

The jinja-create-config.py script take all files withs .j2 suffix and render them to file named without .j2.

For example:

  • config.j2 --> config
  • py3status.conf.j2 --> py3status.conf

Usege

Save the jinja-create-config.py in your ~/.i3 directory and save your configuration into ~/.i3/config.j2 instead ~/.i3/config.

... in your ~/.xinitrc or ~/.Xsession

#create i3 config
~/.i3/jinja-create-config.py

#start i3
exec i3

... in your i3 configuration ~/.i3/config.j2

{%- if hostname == 'foo' %}
  set $primary DVI-I-1
  set $secondary VGA-1

  set $STATUS_FONT pango:Terminus 15
  set $STATUS_CONFFILE ~/.i3/i3blocks_foo.conf
{%- else %}
  set $primary DVI-1
  set $secondary VGA-0

  set $STATUS_FONT pango:Terminus 22
  set $STATUS_CONFFILE ~/.i3/i3blocks_bar.conf
{%- endif %}

# ...

bar {
    status_command i3blocks -c $STATUS_CONFFILE
    font $STATUS_FONT
    output $primary
    position top
    tray_output primary
}

... call jinja-create-config.py by reload and restart.

# Yes really is necessary use i3-msg
# reload the configuration file
bindsym $mod+Shift+c exec "~/.i3/jinja-create-config.py; i3-msg reload"
# restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
bindsym $mod+Shift+r exec "~/.i3/jinja-create-config.py; i3-msg restart"

If you want split the configuration into multiple files:

# Floating windows
{% include 'floating.j2' %}

Use the force of Jinja templating language.

i3-jinja-config's People

Contributors

marreknozka avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

wwalker

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.