This repository has been archived on 2019-02-28. You can view files and clone it, but cannot push or open issues or pull requests.
simple-i3blocks/install.sh
2018-06-28 16:50:31 +02:00

104 lines
2.3 KiB
Bash

#!/bin/bash
# print helper functions for safe output
say () { printf %s\\n "$*" ; }
sayn () { printf %s "$*" ; }
# colors, use ANSI escape codes
normal () { printf '\033[0m'; }
red () { printf '\033[0;31m'; }
green () { printf '\033[0;32m'; }
orange () { printf '\033[0;33m'; }
# check function
check () {
orange
say "::: Check if, $1 is installed"
whereis $1 >/dev/null 2>/dev/null
if [[ $? -ne 0 ]]; then
red
say "::: Error, $1 is not installed. Please install it and restart the setup."
normal
exit 1
else
green
say "::: $1 is installed, moving on"
normal
fi
}
##### MAIN BEGINN
green
say "::: Installing i3blocks"
##### check if neccessary dependencies are installed
check i3
check i3blocks
check git
exit 0
##### 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