Add 'scripts/lfetch/' from commit '31f8eeb5a61f61803ae3704f4e07bbc7ee747402'

git-subtree-dir: scripts/lfetch
git-subtree-mainline: 887e2d02d050b2eb2e6aac1a08d3aa5d9937e4c3
git-subtree-split: 31f8eeb5a6
master
trémeur 5 years ago
commit 52befcbee2

@ -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.

@ -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.

@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Loading…
Cancel
Save