#!/bin/bash # print helper functions for safe output say () { printf %s\\n "$*" ; } sayn () { printf %s "$*" ; } ## colors # use ANSI escape codes normal () { printf '\033[0m' ; } black () { printf '\033[0;30m' ; } red () { printf '\033[0;31m' ; } green () { printf '\033[0;32m' ; } brown () { printf '\033[0;33m' ; } orange () { printf '\033[0;33m' ; } blue () { printf '\033[0;34m' ; } purple () { printf '\033[0;35m' ; } cyan () { printf '\033[0;36m' ; } gray () { printf '\033[0;37m' ; } grey () { printf '\033[1;30m' ; } lred () { printf '\033[1;31m' ; } lgreen () { printf '\033[1;32m' ; } yellow () { printf '\033[1;33m' ; } lblue () { printf '\033[1;34m' ; } lpurple (){ printf '\033[1;35m' ; } lcyan () { printf '\033[1;36m' ; } white () { printf '\033[1;37m' ; } GRE='\033[0;32m' RED='\033[0;31m' NOR='\033[0m' green say "::: Installing i3blocks:" ##### check if i3 is installed orange say "::: Check if 'i3' is installed" i3 -v >/dev/null 2>/dev/null if [[ $? -ne 0 ]]; then red say "::: Nope, please install 'i3' and restart this setup." normal exit 1 else green say "::: Yes, moving on." fi ##### check if i3blocks is installed orange say "::: Check if 'i3blocks' is installed" i3blocks -V >/dev/null 2>/dev/null if [[ $? -ne 0 ]]; then red say "::: Nope, please install 'i3blocks' and restart this setup." normal exit 1 else green say "::: Yes, moving on." fi ##### check if git is installed orange say "::: Check if 'git' is installed" git --version >/dev/null 2>/dev/null if [[ $? -ne 0 ]]; then red say "::: Nope, please install 'git' and restart this setup." normal exit 1 else green say "::: Yes, moving on." fi ##### check if ~/.config/i3blocks already exists is empty orange say "::: Check if ~/.config/i3blocks exists" if [[ -d "$HOME/.config/i3blocks" ]]; then say "::: Yes, moving to ~/.config/i3blocks.bak" mv "$HOME/.config/i3blocks"{,.bak} >/dev/null 2>/dev/null if [[ $? -ne 0 ]]; then red say "::: Error during moving. Please move it manually and restart this setup." normal exit 1 else green say "::: Done" fi fi #### download simple-i3blocks orange say "::: Downloading simple-i3blocks to ~/.config/i3blocks" git clone https://will.kein.hk/git/koksnuss/simple-i3blocks.git ~/.config/i3blocks &> /dev/null if [[ $? -ne 0 ]]; then red say "::: Error during cloning." normal exit 1 else green say "::: Yes, moving on." fi #### masking blocks as executable say "::: Mask i3-blocks executable" cd "$HOME/.config/i3blocks/modules" if [[ $? -ne 0 ]]; then red say "::: Error, could not move to $HOME/.config/i3blocks/modules ." normal exit 1 else green say "::: Yes, moving on." fi chmod u+x audio backlight battery cpu datetime ip ram storage if [[ $? -ne 0 ]]; then red say "::: Error, could not mask the blocks executable." normal exit 1 else green say "::: Yes, moving on." fi ##### finish say "::: Succesfully finished. Please put 'status_command i3blocks' inside the 'bar{ ... }' statement in '.config/i3/config' and reload i3. Normally you can relade 'i3' with the shortcut MOD+SHIFT+R" normal exit 0