diff --git a/scripts/lfetch/LICENSE b/scripts/lfetch/LICENSE new file mode 100644 index 0000000..a1fe78c --- /dev/null +++ b/scripts/lfetch/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Katelyn Hamer + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/scripts/lfetch/README.md b/scripts/lfetch/README.md new file mode 100644 index 0000000..eb26df1 --- /dev/null +++ b/scripts/lfetch/README.md @@ -0,0 +1,24 @@ +# 'Lil Fetch +A tiny little fetch tool + +This script outputs system information to a terminal and a coloured bar to show off your terminal colours. + +It is designed to work on my system, and thus may produce unexpected results on other platforms. If you encounter any problems, please post them as an issue together with some information about your system so that I can fix the issue. + +![Screenshot](https://gitlab.com/kathamer/lfetch/raw/master/screenshot.png) + +# Usage + +Simply place the `lfetch` file in a location that is in your PATH. Run `lfetch` to start the script. + +# Customization + +All customization can be done by modifying the script. The entries and their colours are defined between line 51 and 63. + +# Known quirks + +- Script doesn't run on SH due to implementing Bash features. +- Getting the distro name via `/etc/os-release` is unreliable. +- Some entries are created by running `gawk` on existing commands, changes to the commands' output can break the script. +- Colour bar is hardcoded. + diff --git a/scripts/lfetch/lfetch b/scripts/lfetch/lfetch new file mode 100755 index 0000000..3b90dd2 --- /dev/null +++ b/scripts/lfetch/lfetch @@ -0,0 +1,88 @@ +#!/bin/bash + +# 'Lil Fetch +# A tiny little fetch tool +# By Kat Hamer + +# Get RAM used +ram_used() { + awk '/^Mem/ {print $3}' <(free -m) +} + +# Get total RAM +ram_total() { + awk '/^Mem/ {print $2}' <(free -m) +} + +# Get WM name (Requires wmctrl to be installed!) +wm_name() { + if [ -x "$(command -v wmctrl)" ] + then + awk '/Name:/ {print $2}' <(wmctrl -m) + else + echo "Unknown (Is wmctrl installed?)" + fi +} + +# Store OS info (DOES NOT WORK ON ALL SYSTEMS!) +os_info() { + source /etc/os-release +} + +# Get shell version +shell_version() { + case $(basename "$SHELL") in + "bash") + echo "Bash $BASH_VERSION" + ;; + "zsh") + zsh --version + ;; + *) + echo "$SHELL" + ;; + esac +} + +# Get uptime +uptime() { + uptime | gawk '{ printf $1 }' +} + +display_bar() { + echo -e "\e[41m \e[42m \e[43m \e[44m \e[45m \e[46m \e[47m \e[0m" +} + +output_color() { + os_info + accent_ansi="\e[0;36m" + reset_ansi="\e[0m" + + echo -e "$accent_ansi$(whoami)$reset_ansi@$accent_ansi$(hostname)$reset_ansi in $accent_ansi$(pwd)$reset_ansi" + echo -e "OS: $accent_ansi$NAME$reset_ansi" + echo -e "RAM: $accent_ansi$(ram_used) MB$reset_ansi/$accent_ansi$(ram_total)$reset_ansi MB" + echo -e "Shell: $accent_ansi$(shell_version)$reset_ansi" + echo -e "WM: $accent_ansi$(wm_name)$reset_ansi" + echo + display_bar +} + + +output_plain() { + os_info + + echo -e "$(whoami)@$(hostname) in $(pwd)$" + echo -e "OS: $NAME" + echo -e "RAM: $(ram_used) MB/$(ram_total) MB" + echo -e "Shell: $(shell_version)" + echo -e "WM: $(wm_name)" +} + +main() { + output_color +} + +# Call main function +export LANG=c # Force locale +main + diff --git a/scripts/lfetch/screenshot.png b/scripts/lfetch/screenshot.png new file mode 100644 index 0000000..c640303 Binary files /dev/null and b/scripts/lfetch/screenshot.png differ