Skip to content

Commit

Permalink
Merge pull request #17 from andresgongora/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
andresgongora authored Apr 17, 2020
2 parents 39eaf2a + 35b5576 commit d32361d
Show file tree
Hide file tree
Showing 12 changed files with 832 additions and 770 deletions.
59 changes: 26 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
![synth-shell](doc/synth-shell-status.jpg)


**synth-shell-status** shows a summary of your system's current health.
**synth-shell-greeter** shows a summary of your system's current health.
- Automatically printed in new terminal sessions (local, SSH, ...).
- Monitor your servers, RaspberryPis, and workstations. All system info you
need at a glance (e.g. external IP address, CPU temperature, etc.).
Expand All @@ -18,36 +18,33 @@
# Setup
<!--------------------------------------+-------------------------------------->

### Automatic setup

### Arch Linux

You may install `synth-shell-greeter` from AUR:
https://aur.archlinux.org/packages/synth-shell-greeter-git/



### Manual setup

The included [setup script](setup.sh) will guide you step by step through the
process and let you choose what features to install. During this setup, you can
choose to install synth-shell for your user only (recommended) or system-wide
(superuser privileges required). To proceed,
[open and play this link in a separate tab](https://www.youtube.com/embed/MpN91wHAr1k)
and enter the following into your terminal:
installatioj process. Just clone this repository and run it:
```
git clone --recursive https://github.com/andresgongora/synth-shell.git
chmod +x synth-shell/setup.sh
synth-shell/setup.sh
git clone --recursive https://github.com/andresgongora/synth-shell-greeter.git
synth-shell-greeter/setup.sh
```

Note that for `fancy-bash-prompt.sh` you might also need
[power-line fonts](https://github.com/powerline/fonts). You can instal it
as follows (the exact name of the package varies from distro to distro):

* ArchLinux: `sudo pacman -S powerline-fonts`
* Debian/Ubuntu: `sudo apt install fonts-powerline`
You can then test your script by running it from wherever you installed it.
Usually this is to your user's `.config` folder, so you should run:
```
~/.config/synth-shell/synth-shell-greeter.sh
```

Finally, open up a new terminal and test that everything works. Sometimes,
despite power-line fonts being properly installed, the triangle separator
for `fancy-bash-prompt.sh` (if installed) might still not show. In this case,
make sure that your `locale` is set to UTF-8 by editing `/etc/locale.conf` file
(select your language but in UTF-8 format) and running `sudo locale-gen`.
[More info on locale](https://wiki.archlinux.org/index.php/locale).
Alternatively, try a different font in your terminal emulator. Some fonts
do not support special characters. We get the best results with
[hack-ttf](https://sourcefoundry.org/hack/).
If you want it to appear everytime you open a new terminal, run
```
echo "~/.config/synth-shell/synth-shell-greeter.sh" >> ~/.bashrc
```



Expand All @@ -61,11 +58,6 @@ folders depending on how you installed **synth-shell**:



### Uninstallation
Run the setup script again (like during the installation), but choose
`uninstall` when prompted.



<br/><br/>

Expand All @@ -83,9 +75,10 @@ prints a user-configurable ASCII logo to impress your crush from the library
with how awesome you are.

Feel free to customize your status report through the many available options
in `~/.config/synth-shell/status.config` (user-only install) or
`/etc/synth-shell/status.config` (system-wide install),or by replacing their
content with the examples files you can find under the same directory.
in `~/.config/synth-shell/synth-shell-greeter.config` (user-only install) or
`/etc/synth-shell/synth-shell-greeter.config` (system-wide install), or by
replacing their content with the examples files you can find under the same
directory.

![status configuration options](doc/status_config_preview.png)

Expand Down
2 changes: 1 addition & 1 deletion bash-tools
8 changes: 4 additions & 4 deletions config/examples/synth-shell-greeter.org.uma.scbi.config
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ print_info="
##==============================================================================
## STATUS BARS
##==============================================================================
memory_units="GB"
swap_units="GB"
hdd_units="GB"
home_units="TB"
bar_memory_units="GB"
bar_swap_units="GB"
bar_hdd_units="GB"
bar_home_units="TB"

28 changes: 14 additions & 14 deletions config/os/synth-shell-greeter.archlinux.config
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@
## - https://wiki.archlinux.org/index.php/ASCII_art
## - https://bbs.archlinux.org/viewtopic.php?id=24208&p=6

logo=" .
logo="\e[0;94m .
\e[0;94m #
\e[0;94m ###
\e[0;94m #####
\e[0;94m ######
\e[0;94m ; #####;
\e[0;94m +##.#####
\e[0;94m +##########
\e[0;94m '######
\e[0;94m .. #####:
\e[0;94m ###.#####
\e[0;94m ###########
\e[0;94m ######\e[0;34m#####\e[0;94m##;
\e[0;94m ###\e[0;34m############\e[0;94m+
\e[0;94m ###\e[0;34m############\e[0;94m
\e[0;94m #\e[0;34m###### #######
\e[0;34m .######; ;###;\`\".
\e[0;34m .#######; ;#####.
\e[0;34m #########. .########\`
\e[0;34m ######\' \'######
\e[0;34m ;#### ####;
\e[0;34m ##\' \'##
\e[0;34m #\' \`#
\e[0;34m ' \` "
\e[0;34m ######: :###.\`\".
\e[0;34m #######: :####:.
\e[0;34m :########. .########
\e[0;34m :#####' '#####:
\e[0;34m :#### ####:
\e[0;34m ##' '##
\e[0;34m #' '#
\e[0;34m ' ' "



Expand Down
36 changes: 22 additions & 14 deletions config/synth-shell-greeter.config.default
Original file line number Diff line number Diff line change
Expand Up @@ -117,31 +117,38 @@ format_logo=" -c blue -e bold"
##==============================================================================
## STATUS BARS
##
## This option controls the behaviour of the visual status bars that are plotted
## for CPU, Memory, Swap and HDD usage. You can set the percentage that
## These option controls the behaviour of the visual status bars that are
## plotted for CPU, Memory, Swap and HDD usage. You can set the percentage that
## determines when the current usage is deemed critical. If said percentage
## is surpassed, the color of the bars will change and extra information
## might be plotted in addition (e.g. if the CPU usage is too high, the most
## demanding processes are printed to terminal).
##==============================================================================

crit_cpu_percent=40
print_cpu_hogs_num=3 # Num processes to show if CPU usage is high
crit_ram_percent=75
print_memory_hogs=3 # Num processes to show if memory usage is high
crit_swap_percent=25
crit_hdd_percent=85
crit_home_percent=85
bar_cpu_crit_percent=40
bar_ram_crit_percent=75
bar_swap_crit_percent=25
bar_hdd_crit_percent=85
bar_home_crit_percent=85

memory_units="MB"
swap_units="MB"
hdd_units="GB"
home_units="GB"
bar_ram_units="MB"
bar_swap_units="MB"
bar_hdd_units="GB"
bar_home_units="GB"

cpu_crit_print=true
cpu_crit_print_num=3
ram_crit_print=true
ram_crit_print_num=3

bar_length=9 # Number of characters that comprise a bar
bar_num_digits=5 # Control num digits next to bar
bar_padding_after=0 # Extra spaces after bar
info_label_width=16 # Desired length of the info labels

bar_bracket_char_left='['
bar_bracket_char_right=']'
bar_fill_char='|'
bar_background_char=' '


##==============================================================================
Expand All @@ -158,3 +165,4 @@ print_extra_new_line_top=true # Extra line before logo and info
print_extra_new_line_bot=true # Extra line after logo and info



138 changes: 52 additions & 86 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,63 +28,41 @@

##==============================================================================
##
setup()
{
include() { source "$( cd $( dirname "${BASH_SOURCE[0]}" ) >/dev/null 2>&1 && pwd )/$1" ; }
include 'bash-tools/bash-tools/user_io.sh'
include 'bash-tools/bash-tools/hook_script.sh'
include 'bash-tools/bash-tools/assemble_script.sh'


## SWITCH BETWEEN AUTOMATIC AND USER INSTALLATION
if [ "$#" -eq 0 ]; then
local output_script="$HOME/.config/synth-shell/synth-shell-greeter.sh"
local output_config_dir="$HOME/.config/synth-shell"
cp "$output_config_dir/synth-shell-greeter.config" "$output_config_dir/synth-shell-greeter.config.backup"
printInfo "Installing script as $output_script"
local action=$(promptUser "Add hook your .bashrc file or equivalent?\n\tRequired for autostart on new terminals" "[Y]/[n]?" "yYnN" "y")
case "$action" in
""|y|Y ) hookScript $output_script ;;
n|N ) ;;
*) printError "Invalid option"; exit 1
esac
include(){ { [ -z "$_IR" ]&&_IR="$PWD"&&cd "$(dirname "$PWD/$0")"&&include "$1"&&cd "$_IR"&&unset _IR;}||{ local d=$PWD&&cd "$(dirname "$PWD/$1")"&&. "$(basename "$1")"&&cd "$d";}||{ echo "Include failed $PWD->$1"&&exit 1;};}

include 'bash-tools/bash-tools/user_io.sh'
include 'bash-tools/bash-tools/hook_script.sh'
include 'bash-tools/bash-tools/assemble_script.sh'


## SWITCH BETWEEN AUTOMATIC AND USER INSTALLATION
if [ "$#" -eq 0 ]; then
OUTPUT_SCRIPT="$HOME/.config/synth-shell/synth-shell-greeter.sh"
OUTPUT_CONFIG_DIR="$HOME/.config/synth-shell"
cp "$OUTPUT_CONFIG_DIR/synth-shell-greeter.config" \
"$OUTPUT_CONFIG_DIR/synth-shell-greeter.config.backup"
printInfo "Installing script as $OUTPUT_SCRIPT"
USER_CHOICE=$(promptUser "Add hook your .bashrc file or equivalent?\n\tRequired for autostart on new terminals" "[Y]/[n]?" "yYnN" "y")
case "$USER_CHOICE" in
""|y|Y ) hookScript $OUTPUT_SCRIPT ;;
n|N ) ;;
*) printError "Invalid option"; exit 1
esac

else
local output_script="$1"
local output_config_dir="$2"
fi


## DEFINE LOCAL VARIABLES
local dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )
local input_script="$dir/synth-shell-greeter/synth-shell-greeter.sh"
local input_config_dir="$dir/config/"


## HEADER TO BE ADDED AT THE TOP OF THE ASSEMBLED SCRIPT
local output_script_header=$(printf '%s'\
"##!/bin/bash\n"\
"\n"\
"## +-----------------------------------+-----------------------------------+\n"\
"## | |\n"\
"## | Copyright (c) 2014-2020, Andres Gongora <mail@andresgongora.com> |\n"\
"## | https://github.com/andresgongora/synth-shell-greeter |\n"\
"## | Visit the above URL for details of license and authorship. |\n"\
"## | |\n"\
"## | This program is free software: you can redistribute it and/or modify |\n"\
"## | it under the terms of the GNU General Public License as published by |\n"\
"## | the Free Software Foundation, either version 3 of the License, or |\n"\
"## | (at your option) any later version. |\n"\
"## | |\n"\
"## | This program is distributed in the hope that it will be useful, |\n"\
"## | but WITHOUT ANY WARRANTY; without even the implied warranty of |\n"\
"## | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |\n"\
"## | GNU General Public License for more details. |\n"\
"## | |\n"\
"## | You should have received a copy of the GNU General Public License |\n"\
"## | along with this program. If not, see <http://www.gnu.org/licenses/>. |\n"\
"## | |\n"\
"## +-----------------------------------------------------------------------+\n"\
else
OUTPUT_SCRIPT="$1"
OUTPUT_CONFIG_DIR="$2"
fi


## DEFINE LOCAL VARIABLES
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )
INPUT_SCRIPT="$DIR/synth-shell-greeter/synth-shell-greeter.sh"
INPUT_CONFIG_DIR="$DIR/config/"


## HEADER TO BE ADDED AT THE TOP OF THE ASSEMBLED SCRIPT
OUTPUT_SCRIPT_HEADER=$(printf '%s'\
"##\n"\
"##\n"\
"## =======================\n"\
Expand All @@ -93,43 +71,31 @@ setup()
"## =======================\n"\
"##\n"\
"## This file was generated by an installation script.\n"\
"## If you edit this file, it might be overwritten without warning\n"\
"## and you might lose all your changes.\n"\
"## It might be overwritten without warning at any time\n"\
"## and you will lose all your changes.\n"\
"##\n"\
"## Visit for instructions and more information:\n"\
"## https://github.com/andresgongora/synth-shell/\n"\
"##\n"\
"##\n\n\n")


## SETUP SCRIPT
assembleScript "$input_script" "$output_script" "$output_script_header"


## SETUP CONFIGURATION FILES
[ -d "$output_config_dir" ] || mkdir -p "$output_config_dir"
cp -r "$input_config_dir/." "$output_config_dir/"

## SETUP SCRIPT
assembleScript "$INPUT_SCRIPT" "$OUTPUT_SCRIPT" "$OUTPUT_SCRIPT_HEADER"

## SETUP DEFAULT SYNTH-SHELL-GREETER CONFIG FILE
local config_file="$output_config_dir/synth-shell-greeter.config"
if [ ! -f "$config_file" ]; then
local distro=$(cat /etc/os-release | grep "ID=" | sed 's/ID=//g' | head -n 1)
case "$distro" in
'arch' ) cp "$output_config_dir/os/synth-shell-greeter.archlinux.config" "$config_file" ;;
'manjaro' ) cp "$output_config_dir/os/synth-shell-greeter.manjaro.config" "$config_file" ;;
*) cp "$output_config_dir/synth-shell-greeter.config.default" "$config_file" ;;
esac
fi
}

## SETUP CONFIGURATION FILES
[ -d "$OUTPUT_CONFIG_DIR" ] || mkdir -p "$OUTPUT_CONFIG_DIR"
cp -r "$INPUT_CONFIG_DIR/." "$OUTPUT_CONFIG_DIR/"





##==============================================================================
## SCRIPT
##==============================================================================

setup $@

## SETUP DEFAULT SYNTH-SHELL-GREETER CONFIG FILE
CONFIG_FILE="$OUTPUT_CONFIG_DIR/synth-shell-greeter.config"
if [ ! -f "$CONFIG_FILE" ]; then
DISTRO=$(cat /etc/os-release | grep "ID=" | sed 's/ID=//g' | head -n 1)
case "$DISTRO" in
'arch' ) cp "$OUTPUT_CONFIG_DIR/os/synth-shell-greeter.archlinux.config" "$CONFIG_FILE" ;;
'manjaro' ) cp "$OUTPUT_CONFIG_DIR/os/synth-shell-greeter.manjaro.config" "$CONFIG_FILE" ;;
*) cp "$OUTPUT_CONFIG_DIR/synth-shell-greeter.config.default" "$CONFIG_FILE" ;;
esac
fi
Loading

0 comments on commit d32361d

Please sign in to comment.