commit 2aa70d66fb1d6f4af5a815fbc765058afdba5bbc Author: Owe Bretthauer Date: Sun Dec 31 00:56:01 2017 +0100 initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a732325 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.molecule diff --git a/.yamllint b/.yamllint new file mode 100644 index 0000000..1a3136b --- /dev/null +++ b/.yamllint @@ -0,0 +1,11 @@ +extends: default + +rules: + braces: + max-spaces-inside: 1 + level: error + brackets: + max-spaces-inside: 1 + level: error + line-length: disable + comments-indentation: disable \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..f2e7647 --- /dev/null +++ b/README.md @@ -0,0 +1,103 @@ +I3 WM +===== + +Install and a basic configuration of I3 Window Manager +See: https://i3wm.org/ + +Requirements +------------ + +No requirements. + +Role Variables +-------------- + +*additional i3 packages* + + i3_packages_extra: + +*background image* + + i3_desktop_env: + +*i3 workspaces* + +`__i3_workspaces` could be overwritte with `i3_workspaces` + +*i3 keybindings* + +`__i3_keybindings` coud be overwritten with `i3_keybindings` + +*additional i3 keybindings* + + i3_keybindings_extra: [] + +*monitor settings and bindings to i3 workspaces* + + i3_monitors: [] + +*applications bindings to i3 workspaces* + + i3_applications: [] + +Example Playbook +---------------- + +Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: + + - hosts: all + vars_files: + - vars/main.yml + roles: + - { role: i3 } + +*`vars/main.yml`* + + i3_desktop_env: + background: "~/wallpaper.jpg" + + i3_packages_extra: + - ranger + + i3_keybindings_extra: + - keybinding: + name: Volume (mute/unmute) + key: $mod+F12 + exec: --no-startup-id amixer sset Master toggle + - keybinding: + name: Volue (default) + key: $mod+Shift+F12 + exec: --no-startup-id amixer sset Master 40% + + i3_monitors: + - monitor: + id: 1 + output: "VGA-1" + mode: "1920x1080" + pos: "0x0" + rotate: "normal" + workspaces: [1,2,3,4,5,6] + - monitor: + id: 2 + output: "HDMI-1" + mode: "1920x1080" + pos: "1920x0" + rotate: "normal" + workspaces: [7,8,9,0] + + i3_applications: + - application: + class: "Firefox" + name: "firefox" + workspace: 1 + on_startup: false + - application: + class: "Code" + name: "code" + workspace: 7 + on_startup: true + +License +------- + +Apache diff --git a/defaults/main.yml b/defaults/main.yml new file mode 100644 index 0000000..a856c6b --- /dev/null +++ b/defaults/main.yml @@ -0,0 +1,22 @@ +--- +i3_keybindings_extra: [] +# - keybinding: +# name: example +# key: $mod+Shift+F10 +# exec: --no-startup-id touch /tmp/example.txt + +i3_monitors: [] # see: xrandr +# - monitor: +# id: 1 +# output: "VGA-1" +# mode: "1920x1080" +# pos: "0x0" +# rotate: "normal" +# workspaces: [1,2,3,4,5,6,7,8,9,0] # bind workspace to a specific monitor + +i3_applications: [] +# - application: +# class: "Firefox" +# name: "firefox" +# workspace: 1 # bind application to a specific workspace +# on_startup: false diff --git a/meta/main.yml b/meta/main.yml new file mode 100644 index 0000000..b683f49 --- /dev/null +++ b/meta/main.yml @@ -0,0 +1,15 @@ +--- +galaxy_info: + author: Owe Bretthauer + description: i3wm (https://i3wm.org/) + license: license (Apache) + min_ansible_version: 2.2 + platforms: + - name: Debian + versions: + - stretch + - name: Ubuntu + versions: + - xenial + galaxy_tags: [i3wm] +dependencies: [] diff --git a/molecule/default/Dockerfile.j2 b/molecule/default/Dockerfile.j2 new file mode 100644 index 0000000..f8b4e75 --- /dev/null +++ b/molecule/default/Dockerfile.j2 @@ -0,0 +1,9 @@ +# Molecule managed + +FROM {{ item.image }} + +RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get upgrade -y && apt-get install -y python sudo bash ca-certificates && apt-get clean; \ + elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python2-dnf bash && dnf clean all; \ + elif [ $(command -v yum) ]; then yum makecache fast && yum update -y && yum install -y python sudo yum-plugin-ovl bash && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \ + elif [ $(command -v zypper) ]; then zypper refresh && zypper update -y && zypper install -y python sudo bash python-xml && zypper clean -a; \ + elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; fi diff --git a/molecule/default/INSTALL.rst b/molecule/default/INSTALL.rst new file mode 100644 index 0000000..e26493b --- /dev/null +++ b/molecule/default/INSTALL.rst @@ -0,0 +1,16 @@ +******* +Install +******* + +Requirements +============ + +* Docker Engine +* docker-py + +Install +======= + +.. code-block:: bash + + $ sudo pip install docker-py diff --git a/molecule/default/create.yml b/molecule/default/create.yml new file mode 100644 index 0000000..bfb2149 --- /dev/null +++ b/molecule/default/create.yml @@ -0,0 +1,59 @@ +--- +- name: Create + hosts: localhost + connection: local + gather_facts: false + no_log: "{{ not lookup('env', 'MOLECULE_DEBUG') | bool }}" + vars: + molecule_file: "{{ lookup('env', 'MOLECULE_FILE') }}" + molecule_ephemeral_directory: "{{ lookup('env', 'MOLECULE_EPHEMERAL_DIRECTORY') }}" + molecule_scenario_directory: "{{ lookup('env', 'MOLECULE_SCENARIO_DIRECTORY') }}" + molecule_yml: "{{ lookup('file', molecule_file) | molecule_from_yaml }}" + tasks: + - name: Create Dockerfiles from image names + template: + src: "{{ molecule_scenario_directory }}/Dockerfile.j2" + dest: "{{ molecule_ephemeral_directory }}/Dockerfile_{{ item.image | regex_replace('[^a-zA-Z0-9_]', '_') }}" + with_items: "{{ molecule_yml.platforms }}" + register: platforms + + - name: Discover local Docker images + docker_image_facts: + name: "molecule_local/{{ item.item.name }}" + with_items: "{{ platforms.results }}" + register: docker_images + + - name: Build an Ansible compatible image + docker_image: + path: "{{ molecule_ephemeral_directory }}" + name: "molecule_local/{{ item.item.image }}" + dockerfile: "{{ item.item.dockerfile | default(item.invocation.module_args.dest) }}" + force: "{{ item.item.force | default(true) }}" + with_items: "{{ platforms.results }}" + when: platforms.changed or docker_images.results | map(attribute='images') | select('equalto', []) | list | count >= 0 + + - name: Create molecule instance(s) + docker_container: + name: "{{ item.name }}" + hostname: "{{ item.name }}" + image: "molecule_local/{{ item.image }}" + state: started + recreate: false + log_driver: syslog + command: "{{ item.command | default('bash -c \"while true; do sleep 10000; done\"') }}" + privileged: "{{ item.privileged | default(omit) }}" + volumes: "{{ item.volumes | default(omit) }}" + capabilities: "{{ item.capabilities | default(omit) }}" + ports: "{{ item.exposed_ports | default(omit) }}" + register: server + with_items: "{{ molecule_yml.platforms }}" + async: 7200 + poll: 0 + + - name: Wait for instance(s) creation to complete + async_status: + jid: "{{ item.ansible_job_id }}" + register: docker_jobs + until: docker_jobs.finished + retries: 300 + with_items: "{{ server.results }}" diff --git a/molecule/default/destroy.yml b/molecule/default/destroy.yml new file mode 100644 index 0000000..3ce7478 --- /dev/null +++ b/molecule/default/destroy.yml @@ -0,0 +1,27 @@ +--- +- name: Destroy + hosts: localhost + connection: local + gather_facts: false + no_log: "{{ not lookup('env', 'MOLECULE_DEBUG') | bool }}" + vars: + molecule_file: "{{ lookup('env', 'MOLECULE_FILE') }}" + molecule_yml: "{{ lookup('file', molecule_file) | molecule_from_yaml }}" + tasks: + - name: Destroy molecule instance(s) + docker_container: + name: "{{ item.name }}" + state: absent + force_kill: "{{ item.force_kill | default(true) }}" + register: server + with_items: "{{ molecule_yml.platforms }}" + async: 7200 + poll: 0 + + - name: Wait for instance(s) deletion to complete + async_status: + jid: "{{ item.ansible_job_id }}" + register: docker_jobs + until: docker_jobs.finished + retries: 300 + with_items: "{{ server.results }}" diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml new file mode 100644 index 0000000..9aff02e --- /dev/null +++ b/molecule/default/molecule.yml @@ -0,0 +1,32 @@ +--- +dependency: + name: galaxy +driver: + name: docker +lint: + name: yamllint +platforms: + - name: debian_stretch_default + image: debian:stretch +# - name: debian_jessie_default +# image: debian:jessie + - name: ubuntu_xenial_default + image: ubuntu:xenial +# - name: ubuntu_trusty_default +# image: ubuntu:trusty +provisioner: + name: ansible + lint: + name: ansible-lint +scenario: + name: default + test_sequence: + - lint + - syntax + - create + - prepare + - converge +verifier: + name: testinfra + lint: + name: flake8 diff --git a/molecule/default/playbook.yml b/molecule/default/playbook.yml new file mode 100644 index 0000000..4ec227d --- /dev/null +++ b/molecule/default/playbook.yml @@ -0,0 +1,51 @@ +--- +- name: Converge + hosts: all + + vars: + i3_desktop_env: + background: "~/wallpaper.jpg" + + i3_packages_extra: + - ranger + + i3_keybindings_extra: + - keybinding: + name: Volume (mute/unmute) + key: $mod+F12 + exec: --no-startup-id amixer sset Master toggle + - keybinding: + name: Volue (default) + key: $mod+Shift+F12 + exec: --no-startup-id amixer sset Master 40% + + i3_monitors: + - monitor: + id: 1 + output: "VGA-1" + mode: "1920x1080" + pos: "0x0" + rotate: "normal" + workspaces: [1, 2, 3, 4, 5, 6] + - monitor: + id: 2 + output: "HDMI-1" + mode: "1920x1080" + pos: "1920x0" + rotate: "normal" + workspaces: [7, 8, 9, 0] + + i3_applications: + - application: + class: "Firefox" + name: "firefox" + workspace: 1 + on_startup: false + - application: + class: "Code" + name: "code" + workspace: 7 + on_startup: true + + roles: + - role: i3 diff --git a/molecule/default/prepare.yml b/molecule/default/prepare.yml new file mode 100644 index 0000000..5358b3b --- /dev/null +++ b/molecule/default/prepare.yml @@ -0,0 +1,5 @@ +--- +- name: Prepare + hosts: all + gather_facts: false + tasks: [] diff --git a/molecule/default/tests/__pycache__/test_default.cpython-27-PYTEST.pyc b/molecule/default/tests/__pycache__/test_default.cpython-27-PYTEST.pyc new file mode 100644 index 0000000..d788875 Binary files /dev/null and b/molecule/default/tests/__pycache__/test_default.cpython-27-PYTEST.pyc differ diff --git a/molecule/default/tests/test_default.py b/molecule/default/tests/test_default.py new file mode 100644 index 0000000..eedd64a --- /dev/null +++ b/molecule/default/tests/test_default.py @@ -0,0 +1,14 @@ +import os + +import testinfra.utils.ansible_runner + +testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( + os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all') + + +def test_hosts_file(host): + f = host.file('/etc/hosts') + + assert f.exists + assert f.user == 'root' + assert f.group == 'root' diff --git a/molecule/default/tests/test_default.pyc b/molecule/default/tests/test_default.pyc new file mode 100644 index 0000000..2bf46a6 Binary files /dev/null and b/molecule/default/tests/test_default.pyc differ diff --git a/molecule/no_vars/Dockerfile.j2 b/molecule/no_vars/Dockerfile.j2 new file mode 100644 index 0000000..f8b4e75 --- /dev/null +++ b/molecule/no_vars/Dockerfile.j2 @@ -0,0 +1,9 @@ +# Molecule managed + +FROM {{ item.image }} + +RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get upgrade -y && apt-get install -y python sudo bash ca-certificates && apt-get clean; \ + elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python2-dnf bash && dnf clean all; \ + elif [ $(command -v yum) ]; then yum makecache fast && yum update -y && yum install -y python sudo yum-plugin-ovl bash && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \ + elif [ $(command -v zypper) ]; then zypper refresh && zypper update -y && zypper install -y python sudo bash python-xml && zypper clean -a; \ + elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; fi diff --git a/molecule/no_vars/INSTALL.rst b/molecule/no_vars/INSTALL.rst new file mode 100644 index 0000000..e26493b --- /dev/null +++ b/molecule/no_vars/INSTALL.rst @@ -0,0 +1,16 @@ +******* +Install +******* + +Requirements +============ + +* Docker Engine +* docker-py + +Install +======= + +.. code-block:: bash + + $ sudo pip install docker-py diff --git a/molecule/no_vars/create.yml b/molecule/no_vars/create.yml new file mode 100644 index 0000000..bfb2149 --- /dev/null +++ b/molecule/no_vars/create.yml @@ -0,0 +1,59 @@ +--- +- name: Create + hosts: localhost + connection: local + gather_facts: false + no_log: "{{ not lookup('env', 'MOLECULE_DEBUG') | bool }}" + vars: + molecule_file: "{{ lookup('env', 'MOLECULE_FILE') }}" + molecule_ephemeral_directory: "{{ lookup('env', 'MOLECULE_EPHEMERAL_DIRECTORY') }}" + molecule_scenario_directory: "{{ lookup('env', 'MOLECULE_SCENARIO_DIRECTORY') }}" + molecule_yml: "{{ lookup('file', molecule_file) | molecule_from_yaml }}" + tasks: + - name: Create Dockerfiles from image names + template: + src: "{{ molecule_scenario_directory }}/Dockerfile.j2" + dest: "{{ molecule_ephemeral_directory }}/Dockerfile_{{ item.image | regex_replace('[^a-zA-Z0-9_]', '_') }}" + with_items: "{{ molecule_yml.platforms }}" + register: platforms + + - name: Discover local Docker images + docker_image_facts: + name: "molecule_local/{{ item.item.name }}" + with_items: "{{ platforms.results }}" + register: docker_images + + - name: Build an Ansible compatible image + docker_image: + path: "{{ molecule_ephemeral_directory }}" + name: "molecule_local/{{ item.item.image }}" + dockerfile: "{{ item.item.dockerfile | default(item.invocation.module_args.dest) }}" + force: "{{ item.item.force | default(true) }}" + with_items: "{{ platforms.results }}" + when: platforms.changed or docker_images.results | map(attribute='images') | select('equalto', []) | list | count >= 0 + + - name: Create molecule instance(s) + docker_container: + name: "{{ item.name }}" + hostname: "{{ item.name }}" + image: "molecule_local/{{ item.image }}" + state: started + recreate: false + log_driver: syslog + command: "{{ item.command | default('bash -c \"while true; do sleep 10000; done\"') }}" + privileged: "{{ item.privileged | default(omit) }}" + volumes: "{{ item.volumes | default(omit) }}" + capabilities: "{{ item.capabilities | default(omit) }}" + ports: "{{ item.exposed_ports | default(omit) }}" + register: server + with_items: "{{ molecule_yml.platforms }}" + async: 7200 + poll: 0 + + - name: Wait for instance(s) creation to complete + async_status: + jid: "{{ item.ansible_job_id }}" + register: docker_jobs + until: docker_jobs.finished + retries: 300 + with_items: "{{ server.results }}" diff --git a/molecule/no_vars/destroy.yml b/molecule/no_vars/destroy.yml new file mode 100644 index 0000000..3ce7478 --- /dev/null +++ b/molecule/no_vars/destroy.yml @@ -0,0 +1,27 @@ +--- +- name: Destroy + hosts: localhost + connection: local + gather_facts: false + no_log: "{{ not lookup('env', 'MOLECULE_DEBUG') | bool }}" + vars: + molecule_file: "{{ lookup('env', 'MOLECULE_FILE') }}" + molecule_yml: "{{ lookup('file', molecule_file) | molecule_from_yaml }}" + tasks: + - name: Destroy molecule instance(s) + docker_container: + name: "{{ item.name }}" + state: absent + force_kill: "{{ item.force_kill | default(true) }}" + register: server + with_items: "{{ molecule_yml.platforms }}" + async: 7200 + poll: 0 + + - name: Wait for instance(s) deletion to complete + async_status: + jid: "{{ item.ansible_job_id }}" + register: docker_jobs + until: docker_jobs.finished + retries: 300 + with_items: "{{ server.results }}" diff --git a/molecule/no_vars/molecule.yml b/molecule/no_vars/molecule.yml new file mode 100644 index 0000000..3d5c500 --- /dev/null +++ b/molecule/no_vars/molecule.yml @@ -0,0 +1,28 @@ +--- +dependency: + name: galaxy +driver: + name: docker +lint: + name: yamllint +platforms: + - name: debian_stretch_empty_vars + image: debian:stretch + - name: ubuntu_xenial_empty_vars + image: ubuntu:xenial +provisioner: + name: ansible + lint: + name: ansible-lint +scenario: + name: no_vars + test_sequence: + - lint + - syntax + - create + - prepare + - converge +verifier: + name: testinfra + lint: + name: flake8 diff --git a/molecule/no_vars/playbook.yml b/molecule/no_vars/playbook.yml new file mode 100644 index 0000000..de57e3c --- /dev/null +++ b/molecule/no_vars/playbook.yml @@ -0,0 +1,6 @@ +--- +- name: Converge + hosts: all + + roles: + - role: i3 diff --git a/molecule/no_vars/prepare.yml b/molecule/no_vars/prepare.yml new file mode 100644 index 0000000..5358b3b --- /dev/null +++ b/molecule/no_vars/prepare.yml @@ -0,0 +1,5 @@ +--- +- name: Prepare + hosts: all + gather_facts: false + tasks: [] diff --git a/molecule/no_vars/tests/__pycache__/test_default.cpython-27-PYTEST.pyc b/molecule/no_vars/tests/__pycache__/test_default.cpython-27-PYTEST.pyc new file mode 100644 index 0000000..7b5422a Binary files /dev/null and b/molecule/no_vars/tests/__pycache__/test_default.cpython-27-PYTEST.pyc differ diff --git a/molecule/no_vars/tests/test_default.py b/molecule/no_vars/tests/test_default.py new file mode 100644 index 0000000..eedd64a --- /dev/null +++ b/molecule/no_vars/tests/test_default.py @@ -0,0 +1,14 @@ +import os + +import testinfra.utils.ansible_runner + +testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( + os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all') + + +def test_hosts_file(host): + f = host.file('/etc/hosts') + + assert f.exists + assert f.user == 'root' + assert f.group == 'root' diff --git a/molecule/no_vars/tests/test_default.pyc b/molecule/no_vars/tests/test_default.pyc new file mode 100644 index 0000000..2bf46a6 Binary files /dev/null and b/molecule/no_vars/tests/test_default.pyc differ diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..699d4aa --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,48 @@ +--- +# register variables +- import_tasks: variables.yml + +# ensure i3 packages are installed. +- include_tasks: setup-Debian.yml + when: ansible_os_family == 'Debian' + +# create i3 config file +- name: create i3 config folder + file: + path: ~/.config/i3/ + state: directory + mode: 0755 + +- name: register i3 config file + action: stat path="~/.config/i3/config" + register: "config_file" + +- name: backup i3 config file + block: + + - name: backup i3 config file if exists + copy: + src: ~/.config/i3/config + dest: ~/.config/i3/config.bak + remote_src: true + when: config_file.stat.exists + - name: create i3 config file + template: + src: config.j2 + dest: ~/.config/i3/config + - name: check i3 config file + command: i3 -C + register: check_config_response + failed_when: check_config_response.stdout.find('ERROR') != -1 + rescue: + + - name: register backup i3 config file + action: stat path="~/.config/i3/config.bak" + register: "config_file_backup" + + - name: restore backup file + copy: + src: ~/.config/i3/config.bak + dest: ~/.config/i3/config + remote_src: true + when: config_file_backup.stat.exists diff --git a/tasks/setup-Debian.yml b/tasks/setup-Debian.yml new file mode 100644 index 0000000..2143ebf --- /dev/null +++ b/tasks/setup-Debian.yml @@ -0,0 +1,7 @@ +--- +- name: ensure i3 packages are installed. + apt: + name: "{{ item }}" + state: "present" + with_items: "{{ i3_packages }}" + become: true diff --git a/tasks/variables.yml b/tasks/variables.yml new file mode 100644 index 0000000..7cfa212 --- /dev/null +++ b/tasks/variables.yml @@ -0,0 +1,32 @@ +--- +# register os-specific variables +- name: register os-specific variables + include_vars: "{{ ansible_os_family }}.yml" + +# i3 packages +- name: define i3_packages + set_fact: + i3_packages: "{{ __i3_packages | list }}" + when: i3_packages is not defined + +- name: define i3_packages_extra + set_fact: + i3_packages: "{{ i3_packages | list + i3_packages_extra | list }}" + when: i3_packages_extra is defined + +# i3 workspaces +- name: define i3_packages + set_fact: + i3_workspaces: "{{ __i3_workspaces | list }}" + when: i3_workspaces is not defined + +# i3 keybindings +- name: define i3_packages + set_fact: + i3_keybindings: "{{ __i3_keybindings | list }}" + when: i3_keybindings is not defined + +- name: define extra i3 keybindings + set_fact: + i3_keybindings: "{{ i3_keybindings | list + i3_keybindings_extra | list }}" + when: i3_keybindings_extra is defined diff --git a/templates/config.j2 b/templates/config.j2 new file mode 100644 index 0000000..d8a8702 --- /dev/null +++ b/templates/config.j2 @@ -0,0 +1,172 @@ +set $mod Mod4 + +set $term urxvt + +# Font for window titles. Will also be used by the bar unless a different font +# is used in the bar {} block below. +font pango:monospace 8 +focus_follows_mouse no + +# Use Mouse+$mod to drag floating windows to their wanted position +floating_modifier $mod + +# start a terminal +bindsym $mod+Return exec $term +bindsym $mod+Shift+Return exec $term -e tmux + +# kill focused window +bindsym $mod+Shift+q kill + +# bindsym $mod+d exec rofi (a program launcher) +bindsym $mod+d exec rofi -show run +bindsym $mod+Shift+d exec rofi -show window +bindsym $mod+Shift+s exec rofi -show ssh + +# change focus +bindsym $mod+j focus left +bindsym $mod+k focus down +bindsym $mod+l focus up +bindsym $mod+odiaeresis focus right + +# alternatively, you can use the cursor keys: +bindsym $mod+Left focus left +bindsym $mod+Down focus down +bindsym $mod+Up focus up +bindsym $mod+Right focus right + +# move focused window +bindsym $mod+Shift+j move left +bindsym $mod+Shift+k move down +bindsym $mod+Shift+l move up +bindsym $mod+Shift+odiaeresis move right + +# alternatively, you can use the cursor keys: +bindsym $mod+Shift+Left move left +bindsym $mod+Shift+Down move down +bindsym $mod+Shift+Up move up +bindsym $mod+Shift+Right move right + +# split in horizontal orientation +bindsym $mod+h split h + +# split in vertical orientation +bindsym $mod+v split v + +# enter fullscreen mode for the focused container +bindsym $mod+f fullscreen toggle + +# change container layout (stacked, tabbed, toggle split) +bindsym $mod+s layout stacking +bindsym $mod+w layout tabbed +bindsym $mod+e layout toggle split + +# toggle tiling / floating +bindsym $mod+Shift+space floating toggle + +# change focus between tiling / floating windows +bindsym $mod+space focus mode_toggle + +# focus the parent container +bindsym $mod+a focus parent + +# focus the child container +#bindsym $mod+d focus child + +# restart i3 inplace (preserves your layout/session, can be used to upgrade i3) +bindsym $mod+Shift+r restart + +# exit i3 (logs you out of your X session) +bindsym $mod+Shift+e exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -b 'Yes, exit i3' 'i3-msg exit'" + +# Custom Bindings +bindsym $mod+Shift+x exec i3lock + +# workspace variables +{% for workspace in i3_workspaces %} +set $workspace{{ workspace.id }} "{{ workspace.name }}" +{% endfor %} + +# switch to workspace +{% for workspace in i3_workspaces %} +bindsym $mod+{{ workspace.id }} workspace $workspace{{ workspace.id }} +{% endfor %} + +# move focused container to workspace +{% for workspace in i3_workspaces %} +bindsym $mod+Shift+{{ workspace.id }} move container to workspace $workspace{{ workspace.id }} +{% endfor %} + +{% for monitor in i3_monitors %} +{% for workspace in monitor.workspaces %} +workspace $workspace{{ workspace }} output {{ monitor.output }} +{% endfor %} +{% endfor %} + +{% for application in i3_applications %} +assign [class="{{ application.class }}"] $workspace{{ application.workspace }} +{% endfor %} + +for_window [instance="dropdown"] floating enable +for_window [instance="dropdown"] resize set 1024 800 +for_window [instance="dropdown"] move position center +for_window [instance="dropdown"] move scratchpad +exec --no-startup-id $term -name dropdown -e tmux +bindsym $mod+t [instance="dropdown"] scratchpad show; move position center + +# reload the configuration file +bindsym $mod+Shift+c reload + +# resize window (you can also use the mouse for that) +mode "resize" { + # These bindings trigger as soon as you enter the resize mode + + # Pressing left will shrink the window’s width. + # Pressing right will grow the window’s width. + # Pressing up will shrink the window’s height. + # Pressing down will grow the window’s height. + bindsym j resize shrink width 10 px or 10 ppt + bindsym k resize grow height 10 px or 10 ppt + bindsym l resize shrink height 10 px or 10 ppt + bindsym odiaeresis resize grow width 10 px or 10 ppt + + # same bindings, but for the arrow keys + bindsym Left resize shrink width 10 px or 10 ppt + bindsym Down resize grow height 10 px or 10 ppt + bindsym Up resize shrink height 10 px or 10 ppt + bindsym Right resize grow width 10 px or 10 ppt + + # back to normal: Enter or Escape + bindsym Return mode "default" + bindsym Escape mode "default" +} + +bindsym $mod+r mode "resize" + +# Start i3bar to display a workspace bar (plus the system information i3status +# finds out, if available) +bar { + status_command i3status +} + +# Background +{% if i3_desktop_env is defined %} +{% if i3_desktop_env.background is defined %} +exec_always feh --bg-scale {{ i3_desktop_env.background}} +{% endif %} +{% endif %} + +# Setup Monitors +exec xrandr {% for monitor in i3_monitors %} --output {{ monitor.output }} --mode {{ monitor.mode }} --pos {{ monitor.pos }} --rotate normal {% endfor %} + +exec compton + +# Start Default Applications +{% for application in i3_applications if application.on_startup %} +exec {{ application.name }} +{% endfor %} + +# Register Keybindings +{% for keybinding in i3_keybindings %} +bindsym {{ keybinding.key }} exec {{ keybinding.exec }} +{% endfor%} + diff --git a/tests/.vagrant/machines/debian/virtualbox/action_provision b/tests/.vagrant/machines/debian/virtualbox/action_provision new file mode 100644 index 0000000..f211d02 --- /dev/null +++ b/tests/.vagrant/machines/debian/virtualbox/action_provision @@ -0,0 +1 @@ +1.5:0f088850-bf54-474c-8c3e-1757635022f1 \ No newline at end of file diff --git a/tests/.vagrant/machines/debian/virtualbox/action_set_name b/tests/.vagrant/machines/debian/virtualbox/action_set_name new file mode 100644 index 0000000..d094860 --- /dev/null +++ b/tests/.vagrant/machines/debian/virtualbox/action_set_name @@ -0,0 +1 @@ +1514602261 \ No newline at end of file diff --git a/tests/.vagrant/machines/debian/virtualbox/creator_uid b/tests/.vagrant/machines/debian/virtualbox/creator_uid new file mode 100644 index 0000000..e37d32a --- /dev/null +++ b/tests/.vagrant/machines/debian/virtualbox/creator_uid @@ -0,0 +1 @@ +1000 \ No newline at end of file diff --git a/tests/.vagrant/machines/debian/virtualbox/id b/tests/.vagrant/machines/debian/virtualbox/id new file mode 100644 index 0000000..086a32e --- /dev/null +++ b/tests/.vagrant/machines/debian/virtualbox/id @@ -0,0 +1 @@ +0f088850-bf54-474c-8c3e-1757635022f1 \ No newline at end of file diff --git a/tests/.vagrant/machines/debian/virtualbox/index_uuid b/tests/.vagrant/machines/debian/virtualbox/index_uuid new file mode 100644 index 0000000..7b1a9b5 --- /dev/null +++ b/tests/.vagrant/machines/debian/virtualbox/index_uuid @@ -0,0 +1 @@ +62683cf08f3445f5b4d94e256a9b1fb6 \ No newline at end of file diff --git a/tests/.vagrant/machines/debian/virtualbox/private_key b/tests/.vagrant/machines/debian/virtualbox/private_key new file mode 100644 index 0000000..7d16f1b --- /dev/null +++ b/tests/.vagrant/machines/debian/virtualbox/private_key @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEowIBAAKCAQEAogF7HrxBOB46/Vif7FTfFP/+UI5jr+rHI5IHV63Dyu4cb/Lj +8w+jxsB8OcssKPv0xMTkmjZEwrU8hEd3ZThUjpkKaPo/AovlYNOEN5tDeRnmwOYI +236gvj8Gt6J+rFqROESPwsUCqcgVgm9CM6Uvz9bSguxw3CFNMaEOIj3V7sp09Cdu +lUbewS35P2120N3gveJTfYbUdv6uJN8mkuPiIFZkSTfrnFq+lSCFMXC7dvRej8QO +toV4w4tPEvhaydclI5+Jzy8+7fxippMyoel3LYeMCumyss6t2ULphwqa2JTU4++M +jx/5c3YydVsclQ4kZHrbFo2Qc3iusqsnN0vgRwIDAQABAoIBAG/lefamrJ1oM/Jc +zkjb7iGBF1TopG4TSWyGJlAnEv8NK9Me/tcZTFOxC5yXem7saAmovQTOyvt5Vs0+ +13awS6caiZgskGzf15TjQ4Vs1lPE0h8WQ7PnaHs+6RLZR4kgHQGySWGL1eUS79hh +pGYriDST+l63lNRWpAzNYwe/kg4V6xAwCx8VMldkQyfsg927h3EdunuCRekrL2PQ +rbV0EtjguMHMYmQodfNgvtSzmsGwyPcFzc12A32GPdVasEzt0Nfg3dTCtna4Ytdh +zT2xqINEXFaTimNXE9zCZ79yOhU4u1OMUlWJJ8N+s6d7AoOIstVwtUxRwm2z4vzu +VVKtKQECgYEAzWaeXwCcCwZM5Hy7/fzePQay1HxSsNtFR0sMCyIBs35Gj8SMpgeQ +CaA5lN+IY2VxI2d/wsRB/mftStZfHAQTMPOdvubAKBt5cLvYiHXXt5ZDCLXU4lBh +FwUMgRDWTwt/nC8ouA4uwwdZXlG26J1K1BqLkbbXuJnlfQU74MifpQcCgYEAyeoz +EV9vsmS1kJ0wJ8uZFo06CkfEqXcAtsSmdFJHBG04PByrhQKAvoEEj5SvTl4c3RL8 +kci7HpVtylmHa9CT+WdRrAUaoom4j6vtZANskus5P+QwDnn4GIshlO/mCdyQHI08 +VwKF4yLn3UzPNQcpW9BYTedbLpLhRPgixEK0WsECgYEAm3fR5ayrb7jMGKHFFWEB +wgVA9I5JdK3zSRwnuIF78iVhOU6W+tB8mJybGPD85ecRdK/RR1WPcgWt2VhbUvRO +pl2vB6DWz0TEbazxH5C6v63PfVdMFCSs6GSc61AYNmpIo6oaUv4BLQNyBG8rV/Q+ +gD67Z4aSz5pE1pVQljqkg58CgYAJg4+EcgrBTR2BAucR+PXtqhniAh+yHHlcI0f0 +kyvleX/81Rz/125Zi5q7aTYZazXQ9OQRunOWrVPPBQjse5d9WPDwOg1XO0YG/wLg +g4jKI2s/J3FcPUMDZQrgCa29KTdhIQaG0web/DkQpF3fEcdRHDAM+6nAOAuFRGve +84WsAQKBgGVDq2zYykg92VrauW1kS7hsQtNQAfQT4a0oVrcaiWUcO/8JHRpv+yAy +68tE8U0bhR1oTzDojCFryCj+YJgSKdzzGd9fUreN29YGudkp7gF1AJ+UbenOcaZe +fTDeEXhYTN3+GeV1yNOS5Y+u3+Iy6WQLgZSLIeiHPd+SxZRCdXWv +-----END RSA PRIVATE KEY----- diff --git a/tests/.vagrant/machines/debian/virtualbox/synced_folders b/tests/.vagrant/machines/debian/virtualbox/synced_folders new file mode 100644 index 0000000..888fa88 --- /dev/null +++ b/tests/.vagrant/machines/debian/virtualbox/synced_folders @@ -0,0 +1 @@ +{"rsync":{"/vagrant":{"type":"rsync","guestpath":"/vagrant","hostpath":"/home/owe/workspace/private/ansible/i3/tests","disabled":false,"__vagrantfile":true,"owner":"vagrant","group":"vagrant"}}} \ No newline at end of file diff --git a/tests/.vagrant/machines/xenial/virtualbox/action_provision b/tests/.vagrant/machines/xenial/virtualbox/action_provision new file mode 100644 index 0000000..fb20766 --- /dev/null +++ b/tests/.vagrant/machines/xenial/virtualbox/action_provision @@ -0,0 +1 @@ +1.5:297c8844-ecdf-472a-beb7-07f31a0fa84b \ No newline at end of file diff --git a/tests/.vagrant/machines/xenial/virtualbox/action_set_name b/tests/.vagrant/machines/xenial/virtualbox/action_set_name new file mode 100644 index 0000000..7fe7e79 --- /dev/null +++ b/tests/.vagrant/machines/xenial/virtualbox/action_set_name @@ -0,0 +1 @@ +1514602561 \ No newline at end of file diff --git a/tests/.vagrant/machines/xenial/virtualbox/creator_uid b/tests/.vagrant/machines/xenial/virtualbox/creator_uid new file mode 100644 index 0000000..e37d32a --- /dev/null +++ b/tests/.vagrant/machines/xenial/virtualbox/creator_uid @@ -0,0 +1 @@ +1000 \ No newline at end of file diff --git a/tests/.vagrant/machines/xenial/virtualbox/id b/tests/.vagrant/machines/xenial/virtualbox/id new file mode 100644 index 0000000..f4c1309 --- /dev/null +++ b/tests/.vagrant/machines/xenial/virtualbox/id @@ -0,0 +1 @@ +297c8844-ecdf-472a-beb7-07f31a0fa84b \ No newline at end of file diff --git a/tests/.vagrant/machines/xenial/virtualbox/index_uuid b/tests/.vagrant/machines/xenial/virtualbox/index_uuid new file mode 100644 index 0000000..efd3dc8 --- /dev/null +++ b/tests/.vagrant/machines/xenial/virtualbox/index_uuid @@ -0,0 +1 @@ +7a8b283b91ff4dbfa3bad0a5c7cde793 \ No newline at end of file diff --git a/tests/.vagrant/machines/xenial/virtualbox/private_key b/tests/.vagrant/machines/xenial/virtualbox/private_key new file mode 100644 index 0000000..974d033 --- /dev/null +++ b/tests/.vagrant/machines/xenial/virtualbox/private_key @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEpAIBAAKCAQEA4hhlpOQsFNNy6VIjD84ov2wUTNriFwKtzpYJvlgIV5JcXDaz +FLGKAK/4pQWFrGqNuYk85GRNUXskonZFgVG13vfp2Tpna7kmUrPJ0JRbDEKVXsiR +uz2qtCkGTZtx2IUaY/eNHluBbfWlYx1bIJ9onHktA/usKwZUyejv0U2LVwmMhUEI +AthSfJiq7VnrFNuhSitjF6P5W7KKQXNvsZbvQF7An+klj1AJWnwXGjVKu5kRFn14 +APlry/3eFfu9IoIgW9Wd0SmZA9XkV1pYV0pm5Sydj2jkZpGRZB26ZyxN///+V6md +1bdi5b7B9YLQ2EDJxRDrBodV06QlTE16n1crowIDAQABAoIBAHjogRrP5n7woOgD +Q7rFDedoPebnuraBeT8b33QKEdP68idiHRx44QsDD933+Qc+KDJLIOQme26SgwHa +a8r/TlpBi63eXMYvyj255bgETjhdNxHsAnr2PF6B/dvsv9IBRB6nmLDeUHXkQqCh +Z0Un2kKrTpZttSGBDkC3r9/nLxfIgvx/563HMAqDXvCQ3NucfrVKS/c0C7vmXZ4d +G49VWFV34er7x08X9DO4kgBKewwANTQ7uLVeHNJn0IknQA3jhna6S2xkPE74dgOn +TIO2eip6reiZZxZY8JnhHkUffNMTGuICKoPs/iqtSIQosJczl4oaf/MPmf33zrH8 +AVnkC9ECgYEA+dCZGGSOo4aontaj5LHmEaFD6IJooIg7grUMiGuNLXPQIhWj9nEm +HSg4ASZQJZOe6pGrV1BYhFRlI4m3r09CYwBMIoAFeVm8rgRc9d8VQ027+Fo97q9Z +pvxdFgO5009xpfx5+Zz+GhNivw6isniaUt264Qkq8HHL6n0A4wM/kjsCgYEA57F1 +GlR0hKmjsLIQaE6R4cc9Ww96vjSMS90cc4YMRa7IUIWgd0l4V2J2amaZ4JmiCPnv +HL6w4o4GJJR2iKJkdOrPDkVNlCtaVsqvmvg39Z4UtzYQYZFwgPlJ+PcaBb2rB7bE +7xHjs2z4UYRHM4VY6iunkjqL52mPRIxTnd7UjbkCgYEAwcroeNvJK2IS/OVVTtwS +tip8G6rOr3n/cG4ywsFsS45EL6zJ/SvZfVTt3TZzhjL2XNGUMa/Kex1dOCxlqkG6 +JkLczQazOGg8zmHkG3hrbkKnRwn6cWbmDXxIWgOZ7Cr85t7tYI5BMMlJGR2paPnV +/eK0Tk5mWRBuOAGw5mpmrnECgYBNEOrZqjPjmKWY9XGdsFy309TlwB1cvQ/ZgB+h +kXnth7ibiAcbBnYf4uFufNg8K/4IrFHLpuYhRYpninZu9k0h0qSyo3yth0oSSnLk +wiGi8kUDt9j1CzJ3w/PF+zNNq4wDEdkpiDLMELf8LVqdmYI8ye6AJjc47xS3gVGi +1mavCQKBgQCjqCAb8pJFeuxea6+02CBKuN4uKRKZYIF/QH4Ep/lhCiYGBrQeDX1g +XZV9gL5n8T/uQdTxfRuR28paz0OwFsELIWTuYdAc0qe8smuF64sqEhSF1mKfX42T +M1n43ssU58AYJNYR8Vl44oQZ0eAI94nnl9jeK8ELzbqsZ/ojGU/B/A== +-----END RSA PRIVATE KEY----- diff --git a/tests/.vagrant/machines/xenial/virtualbox/synced_folders b/tests/.vagrant/machines/xenial/virtualbox/synced_folders new file mode 100644 index 0000000..2a85dfe --- /dev/null +++ b/tests/.vagrant/machines/xenial/virtualbox/synced_folders @@ -0,0 +1 @@ +{"virtualbox":{"/vagrant":{"guestpath":"/vagrant","hostpath":"/home/owe/workspace/private/ansible/i3/tests","disabled":false,"__vagrantfile":true}}} \ No newline at end of file diff --git a/tests/.vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory b/tests/.vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory new file mode 100644 index 0000000..9683fde --- /dev/null +++ b/tests/.vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory @@ -0,0 +1,8 @@ +# Generated by Vagrant + +xenial ansible_ssh_host=127.0.0.1 ansible_ssh_port=2200 ansible_ssh_user='ubuntu' ansible_ssh_private_key_file='/home/owe/workspace/private/ansible/i3/tests/.vagrant/machines/xenial/virtualbox/private_key' +debian ansible_ssh_host=127.0.0.1 ansible_ssh_port=2222 ansible_ssh_user='vagrant' ansible_ssh_private_key_file='/home/owe/workspace/private/ansible/i3/tests/.vagrant/machines/debian/virtualbox/private_key' + +[all] +debian +xenial diff --git a/tests/Vagrantfile b/tests/Vagrantfile new file mode 100644 index 0000000..95bb06e --- /dev/null +++ b/tests/Vagrantfile @@ -0,0 +1,30 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +Vagrant.configure("2") do |config| + + config.vm.define "debian" do |web| + web.vm.box = "debian/stretch64" + + web.vm.provider "virtualbox" do |vb| + vb.memory = "512" + end + end + + config.vm.define "xenial" do |web| + web.vm.box = "ubuntu/xenial64" + + web.vm.provider "virtualbox" do |vb| + vb.memory = "512" + end + end + + config.vm.provision :ansible do |ansible| + ansible.playbook = "playbook.yml" + ansible.groups = { + "all" => ["debian", "xenial"] + } + ansible.raw_arguments = ["-u vagrant"] + end + +end diff --git a/tests/playbook.yml b/tests/playbook.yml new file mode 100644 index 0000000..6c0b7f8 --- /dev/null +++ b/tests/playbook.yml @@ -0,0 +1,52 @@ +--- +- hosts: all + user: vagrant + + vars: + + desktop_env: + background: "~/Bilder/bg/background.jpg" + + i3_packages_extra: + - ranger + + i3_keybindings_extra: + - keybinding: + name: Volume (mute/unmute) + key: $mod+F12 + exec: --no-startup-id amixer sset Master toggle + - keybinding: + name: Volue (default) + key: $mod+Shift+F12 + exec: --no-startup-id amixer sset Master 40% + + i3_monitors: + - monitor: + id: 1 + output: "VGA-1" + mode: "1920x1080" + pos: "0x0" + rotate: "normal" + workspaces: [1, 2, 3, 4, 5, 6] + - monitor: + id: 2 + output: "HDMI-1" + mode: "1920x1080" + pos: "1920x0" + rotate: "normal" + workspaces: [7, 8, 9, 0] + + i3_applications: + - application: + class: "Firefox" + name: "firefox" + workspace: 1 + on_startup: false + - application: + class: "Code" + name: "code" + workspace: 7 + on_startup: true + + roles: + - i3 diff --git a/vars/Debian.yml b/vars/Debian.yml new file mode 100644 index 0000000..beb69f9 --- /dev/null +++ b/vars/Debian.yml @@ -0,0 +1,8 @@ +--- +__i3_packages: + - i3 + - rxvt-unicode + - rofi + - compton + - feh + - tmux diff --git a/vars/main.yml b/vars/main.yml new file mode 100644 index 0000000..123185a --- /dev/null +++ b/vars/main.yml @@ -0,0 +1,46 @@ +--- +__i3_workspaces: + - workspace: + id: 1 + name: "01: " + - workspace: + id: 2 + name: "02: " + - workspace: + id: 3 + name: "03: " + - workspace: + id: 4 + name: "04: " + - workspace: + id: 5 + name: "05: " + - workspace: + id: 6 + name: "06: " + - workspace: + id: 7 + name: "07: " + - workspace: + id: 8 + name: "08: " + - workspace: + id: 9 + name: "09: " + - workspace: + id: 0 + name: "10: " + +__i3_keybindings: + - keybinding: + name: Volume (-5%) + key: XF86AudioLowerVolume + exec: --no-startup-id amixer sset Master 5%- + - keybinding: + name: Volume (+5%) + key: XF86AudioRaiseVolume + exec: --no-startup-id amixer sset Master 5%+ + - keybinding: + name: Volume (mute/unmute) + key: XF86AudioMute + exec: --no-startup-id amixer sset Master toggle