Big update, check the releases page
This commit is contained in:
parent
148ec7a190
commit
4f4e6edd71
52
Readme.md
52
Readme.md
|
@ -1,4 +1,5 @@
|
||||||
# fetch.sh
|
# fetch.sh
|
||||||
|
### Check the releases page
|
||||||
|
|
||||||
https://github.com/dylanaraps/fetch.sh
|
https://github.com/dylanaraps/fetch.sh
|
||||||
|
|
||||||
|
@ -18,24 +19,35 @@ for as many people as possible.
|
||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
|
|
||||||
These are the script's dependencies:
|
These are the script's required dependencies
|
||||||
|
|
||||||
|
- Text formatting, dynamic image size and padding: tput
|
||||||
|
|
||||||
|
These are the script's optional dependencies:
|
||||||
|
|
||||||
- Displaying Images: w3m
|
- Displaying Images: w3m
|
||||||
- Image Cropping: ImageMagick
|
- Image Cropping: ImageMagick
|
||||||
- Display Wallpaper: feh
|
- Display Wallpaper: feh
|
||||||
- Current Song: mpc
|
- Current Song: mpc
|
||||||
|
|
||||||
These are the script's optional dependencies
|
|
||||||
- Window Manager Detection: wmctrl
|
|
||||||
- You can manually set this at launch with:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
scrot.sh --winman string
|
|
||||||
```
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
The whitespace
|
The script now supports dynamic image sizing and padding,
|
||||||
|
<br\> they're enabled by default and there's a variable you
|
||||||
|
<br\> need to set for it to work correctly.
|
||||||
|
|
||||||
|
You can either change the variable $fontwidth inside of the
|
||||||
|
<br\> script or launch it with "--fontwidth num".
|
||||||
|
|
||||||
|
Once you set the var the script will scale the image and padding
|
||||||
|
<br\> to fit your terminal window.
|
||||||
|
|
||||||
|
You can disable this by changing the var "$img_auto" or by launching
|
||||||
|
<br\> the script with "--size px".
|
||||||
|
|
||||||
|
Please report any bugs or issues you're having with this as I can't
|
||||||
|
<br\> test with many configurations.
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -64,24 +76,33 @@ Text Colors:
|
||||||
--coloncol num Change the color of the colons
|
--coloncol num Change the color of the colons
|
||||||
--infocol num Change the color of the info
|
--infocol num Change the color of the info
|
||||||
|
|
||||||
|
Text Formatting:
|
||||||
|
--nowrap Disable line wrapping
|
||||||
|
--nobold Disable bold text
|
||||||
|
|
||||||
Color Blocks:
|
Color Blocks:
|
||||||
--printcols start end Range of colors to print as blocks
|
--printcols start end Range of colors to print as blocks
|
||||||
|
--blockwidth num Width of color blocks"
|
||||||
--nopal Disable the color blocks
|
--nopal Disable the color blocks
|
||||||
|
|
||||||
Image:
|
Image:
|
||||||
--image Image to display with the script
|
--image Image to display with the script
|
||||||
The image gets priority over other
|
The image gets priority over other
|
||||||
images: (wallpaper, \$img)
|
images: (wallpaper, \$img)
|
||||||
|
|
||||||
|
--fontwidth Used to automatically size the image
|
||||||
--size px Change the size of the image
|
--size px Change the size of the image
|
||||||
--cropoffset value Change the crop offset. Possible values:
|
--cropoffset value Change the crop offset. Possible values:
|
||||||
northwest, north, northeast, west, center
|
northwest, north, northeast, west, center
|
||||||
east, southwest, south, southeast
|
east, southwest, south, southeast
|
||||||
--padding How many spaces to pad the text
|
--padding num How many spaces to pad the text
|
||||||
to the right
|
to the right
|
||||||
--xoffset px How close the image will be
|
--xoffset px How close the image will be
|
||||||
to the left edge of the window
|
to the left edge of the window
|
||||||
--yoffset px How close the image will be
|
--yoffset px How close the image will be
|
||||||
to the top edge of the window
|
to the top edge of the window
|
||||||
|
|
||||||
|
--gap num Gap between image and text right side
|
||||||
--noimg Disable all images
|
--noimg Disable all images
|
||||||
--nowall Disable the wallpaper function
|
--nowall Disable the wallpaper function
|
||||||
and fallback to \$img
|
and fallback to \$img
|
||||||
|
@ -97,11 +118,9 @@ Other:
|
||||||
Here's what's on my todo list
|
Here's what's on my todo list
|
||||||
|
|
||||||
- Add an easy way to define info prefixes at launch.
|
- Add an easy way to define info prefixes at launch.
|
||||||
- Find a reliable way to set the text padding dynamically. I can get this to
|
- Finish adding an option to smart crop images with plain color backgrounds.
|
||||||
<br/> work based on font width but there's no reliable way of getting
|
<br/>What this means is that your solid bg waifu wallpaper will be cropped around
|
||||||
<br/> fontwidth for every terminal afaik.
|
<br/>your waifu no matter where she is in the image.
|
||||||
|
|
||||||
If you've got any ideas on how to solve these problems, let me know!
|
|
||||||
|
|
||||||
|
|
||||||
## Customization
|
## Customization
|
||||||
|
@ -113,9 +132,10 @@ fetch () {
|
||||||
fetch.sh \
|
fetch.sh \
|
||||||
--printcols 1 7 \
|
--printcols 1 7 \
|
||||||
--cpu "AMD FX-6300" \
|
--cpu "AMD FX-6300" \
|
||||||
--song "$(mpc current | cut -c 1-30)" \
|
|
||||||
--uptime "$(uptime -p | sed -e 's/minutes/mins/')" \
|
--uptime "$(uptime -p | sed -e 's/minutes/mins/')" \
|
||||||
--title "dylan's pc" \
|
--title "dylan's pc" \
|
||||||
|
--nowrap \
|
||||||
|
--nobold \
|
||||||
$@
|
$@
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
294
fetch.sh
294
fetch.sh
|
@ -1,12 +1,12 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# Fetch info about your system
|
# Fetch info about your system
|
||||||
#
|
#
|
||||||
# Dependencies:
|
# Optional Dependencies: (You'll lose these features without them)
|
||||||
# Displaying Images: w3m
|
# Displaying Images: w3m
|
||||||
# Image Cropping: ImageMagick
|
# Image Cropping: ImageMagick
|
||||||
# Wallpaper Display: feh
|
# Wallpaper Display: feh Window Manager Detection: wmctrl
|
||||||
# Window Manager Detection: wmctrl
|
|
||||||
# Current Song: mpc
|
# Current Song: mpc
|
||||||
|
# Text formatting, dynamic image size and padding: tput
|
||||||
#
|
#
|
||||||
# Created by Dylan Araps
|
# Created by Dylan Araps
|
||||||
# https://github.com/dylanaraps/dotfiles
|
# https://github.com/dylanaraps/dotfiles
|
||||||
|
@ -34,27 +34,34 @@ title_song="Song"
|
||||||
# Text Formatting {{{
|
# Text Formatting {{{
|
||||||
|
|
||||||
|
|
||||||
# Set to "" or comment this line to disable bold text
|
# Line wrap
|
||||||
bold="\033[1m"
|
# Set this to 0 or use the flag "--nowrap" to disable
|
||||||
|
# line wrapping. Really useful for small terminal windows
|
||||||
|
# and long lines.
|
||||||
|
linewrap=1
|
||||||
|
|
||||||
# This is a simple function to make the vars below easier to edit.
|
# Set to "", comment this line or use the flaf "--nobold"
|
||||||
color () {
|
# to disable bold text.
|
||||||
echo "\033[38;5;${1}m"
|
bold=$(tput bold)
|
||||||
}
|
|
||||||
|
|
||||||
# Default colors
|
# Default colors
|
||||||
# Colors can be defined at launch with:
|
# Colors can be defined at launch with:
|
||||||
# "--titlecol 1, --subtitlecol 2, --coloncol 3, --infocol 4"
|
# "--titlecol 1, --subtitlecol 2, --coloncol 3, --infocol 4"
|
||||||
# Or the shorthand "-c/--color 1 2 3 4"
|
# Or the shorthand "-c/--color 1 2 3 4"
|
||||||
# Or by editing them below.
|
# Or by editing them below.
|
||||||
title_color=$(color 7)
|
title_color=$(tput setaf 7)
|
||||||
subtitle_color=$(color 1)
|
subtitle_color=$(tput setaf 1)
|
||||||
colon_color=$(color 7) # Also changes underline color
|
colon_color=$(tput setaf 7) # Also changes underline color
|
||||||
info_color=$(color 7)
|
info_color=$(tput setaf 7)
|
||||||
|
|
||||||
# Reset formatting
|
# Reset formatting
|
||||||
# Removing this line will fuck up the text formatting
|
# Removing this line will fuck up the text formatting
|
||||||
clear="\033[0m"
|
clear=$(tput sgr0)
|
||||||
|
|
||||||
|
# Amount of left padding to use when images are disabled.
|
||||||
|
# The variable takes a count of spaces. So a value of 10
|
||||||
|
# will pad the text to the right 10 spaces.
|
||||||
|
padding=10
|
||||||
|
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
@ -62,6 +69,7 @@ clear="\033[0m"
|
||||||
|
|
||||||
# Custom Image {{{
|
# Custom Image {{{
|
||||||
|
|
||||||
|
|
||||||
# Enable or disable the use of images (Disable images at launch with "--noimg")
|
# Enable or disable the use of images (Disable images at launch with "--noimg")
|
||||||
enableimages=1
|
enableimages=1
|
||||||
|
|
||||||
|
@ -76,9 +84,24 @@ usewall=1
|
||||||
# to set a custom image at launch.
|
# to set a custom image at launch.
|
||||||
img="$HOME/Pictures/avatars/gon.png"
|
img="$HOME/Pictures/avatars/gon.png"
|
||||||
|
|
||||||
|
# Image size is based on terminal size
|
||||||
|
# Using the flag "--size" sets this to 0.
|
||||||
|
img_auto=1
|
||||||
|
|
||||||
|
# Image size to use if img_auto=0
|
||||||
|
# Also configureable at launch with "--size"
|
||||||
|
size=128
|
||||||
|
|
||||||
|
# Font width is needed to properly calulate the image size
|
||||||
|
# If there's a gap on the right try increasing the value by 1
|
||||||
|
# If there's an overlap try decreasing the value by 1
|
||||||
|
fontwidth=5
|
||||||
|
|
||||||
|
# Gap is the amount of space between the image and the text on the right
|
||||||
|
gap=4
|
||||||
|
|
||||||
# Image size/offset
|
# Image size/offset
|
||||||
# (Customizable at launch with these flags: --size 128 --xoffset 0 --yoffset 0")
|
# (Customizable at launch with these flags: --xoffset 0 --yoffset 0")
|
||||||
imgsize=128
|
|
||||||
yoffset=0
|
yoffset=0
|
||||||
xoffset=0
|
xoffset=0
|
||||||
|
|
||||||
|
@ -87,12 +110,6 @@ xoffset=0
|
||||||
# northwest, north, northeast, west, center, east, southwest, south, southeast
|
# northwest, north, northeast, west, center, east, southwest, south, southeast
|
||||||
crop_offset="center"
|
crop_offset="center"
|
||||||
|
|
||||||
# Padding to align text to the right
|
|
||||||
# TODO: Find a reliable way to set this dynamically. I can get
|
|
||||||
# this to work based on font width but there's no reliable way
|
|
||||||
# of getting fontwidth for every terminal.
|
|
||||||
pad=" "
|
|
||||||
|
|
||||||
# Directory to store cropped images
|
# Directory to store cropped images
|
||||||
imgtempdir="$HOME/.fetchimages"
|
imgtempdir="$HOME/.fetchimages"
|
||||||
|
|
||||||
|
@ -152,7 +169,7 @@ shell="$SHELL"
|
||||||
# export the "windowmanager" variable in your shell's configuration file,
|
# export the "windowmanager" variable in your shell's configuration file,
|
||||||
# or run the script with: --windowmanager wmname
|
# or run the script with: --windowmanager wmname
|
||||||
# windowmanager="openbox"
|
# windowmanager="openbox"
|
||||||
if [ -z $windowmanager ]; then
|
getwindowmanager () {
|
||||||
if type -p wmctrl >/dev/null 2>&1; then
|
if type -p wmctrl >/dev/null 2>&1; then
|
||||||
windowmanager=$(wmctrl -m | awk '/Name:/ {printf $2}')
|
windowmanager=$(wmctrl -m | awk '/Name:/ {printf $2}')
|
||||||
elif [ -e ~/.xinitrc ]; then
|
elif [ -e ~/.xinitrc ]; then
|
||||||
|
@ -160,7 +177,7 @@ if [ -z $windowmanager ]; then
|
||||||
else
|
else
|
||||||
windowmanager="Unknown"
|
windowmanager="Unknown"
|
||||||
fi
|
fi
|
||||||
fi
|
}
|
||||||
|
|
||||||
# Processor (Configurable with "-C", "-S" and "--cpu", "--speed" at launch)
|
# Processor (Configurable with "-C", "-S" and "--cpu", "--speed" at launch)
|
||||||
cpu="$(awk 'BEGIN{FS=":"} /model name/ {print $2; exit}' /proc/cpuinfo |\
|
cpu="$(awk 'BEGIN{FS=":"} /model name/ {print $2; exit}' /proc/cpuinfo |\
|
||||||
|
@ -194,23 +211,20 @@ end=7
|
||||||
# Print the color blocks by default.
|
# Print the color blocks by default.
|
||||||
printcols=1
|
printcols=1
|
||||||
|
|
||||||
printcols () {
|
# Widh of the color blocks
|
||||||
echo
|
blockwidth=3
|
||||||
echo
|
|
||||||
|
|
||||||
|
printcols () {
|
||||||
while [ "$start" -le "$end" ]; do
|
while [ "$start" -le "$end" ]; do
|
||||||
echo -n "\033[48;5;${start}m "
|
printf "%s%${blockwidth}s" "$(tput setab $start)"
|
||||||
start=$((start + 1))
|
start=$((start + 1))
|
||||||
|
|
||||||
# Split the blocks at 8 colors
|
# Split the blocks at 8 colors
|
||||||
[ $end -ge 9 ] && [ $start -eq 8 ] && echo -e "\033[0m"
|
[ $end -ge 9 ] && [ $start -eq 8 ] && printf "\n%${pad}s" "$clear$pad"
|
||||||
done
|
done
|
||||||
|
|
||||||
# Vertically center colors if they're one row tall
|
|
||||||
[ $end -le 8 ] && echo
|
|
||||||
|
|
||||||
# Clear formatting
|
# Clear formatting
|
||||||
echo -n "$clear"
|
printf "$clear"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -221,77 +235,80 @@ printcols () {
|
||||||
|
|
||||||
|
|
||||||
usage () {
|
usage () {
|
||||||
echo
|
printf '%s\n'
|
||||||
echo "usage: ${0##*/} [--colors 1 2 4 5] [--kernel \"\$(uname -rs)\"]"
|
printf '%s\n' "usage: ${0##*/} [--colors 1 2 4 5] [--kernel \"\$(uname -rs)\"]"
|
||||||
echo
|
printf '%s\n'
|
||||||
echo " Info:"
|
printf '%s\n' " Info:"
|
||||||
echo " --title string Change the title at the top"
|
printf '%s\n' " --title string Change the title at the top"
|
||||||
echo " --distro string/cmd Manually set the distro"
|
printf '%s\n' " --distro string/cmd Manually set the distro"
|
||||||
echo " --kernel string/cmd Manually set the kernel"
|
printf '%s\n' " --kernel string/cmd Manually set the kernel"
|
||||||
echo " --uptime string/cmd Manually set the uptime"
|
printf '%s\n' " --uptime string/cmd Manually set the uptime"
|
||||||
echo " --packages string/cmd Manually set the package count"
|
printf '%s\n' " --packages string/cmd Manually set the package count"
|
||||||
echo " --shell string/cmd Manually set the shell"
|
printf '%s\n' " --shell string/cmd Manually set the shell"
|
||||||
echo " --winman string/cmd Manually set the window manager"
|
printf '%s\n' " --winman string/cmd Manually set the window manager"
|
||||||
echo " --cpu string/cmd Manually set the cpu name"
|
printf '%s\n' " --cpu string/cmd Manually set the cpu name"
|
||||||
echo " --memory string/cmd Manually set the memory"
|
printf '%s\n' " --memory string/cmd Manually set the memory"
|
||||||
echo " --speed string/cmd Manually set the cpu speed"
|
printf '%s\n' " --speed string/cmd Manually set the cpu speed"
|
||||||
echo " --speed_type Change the type of cpu speed to get"
|
printf '%s\n' " --speed_type Change the type of cpu speed to get"
|
||||||
echo " Possible values: current, min, max"
|
printf '%s\n' " Possible values: current, min, max"
|
||||||
echo " --song string/cmd Manually set the current song"
|
printf '%s\n' " --song string/cmd Manually set the current song"
|
||||||
echo
|
printf '%s\n'
|
||||||
echo " Text Colors:"
|
printf '%s\n' " Text Colors:"
|
||||||
echo " --colors 1 2 3 4 Change the color of text"
|
printf '%s\n' " --colors 1 2 3 4 Change the color of text"
|
||||||
echo " (title, subtitle, colon, info)"
|
printf '%s\n' " (title, subtitle, colon, info)"
|
||||||
echo " --titlecol num Change the color of the title"
|
printf '%s\n' " --titlecol num Change the color of the title"
|
||||||
echo " --subtitlecol num Change the color of the subtitle"
|
printf '%s\n' " --subtitlecol num Change the color of the subtitle"
|
||||||
echo " --coloncol num Change the color of the colons"
|
printf '%s\n' " --coloncol num Change the color of the colons"
|
||||||
echo " --infocol num Change the color of the info"
|
printf '%s\n' " --infocol num Change the color of the info"
|
||||||
echo
|
printf '%s\n'
|
||||||
echo " Color Blocks:"
|
printf '%s\n' " Text Formatting:"
|
||||||
echo " --printcols start end Range of colors to print as blocks"
|
printf '%s\n' " --nowrap Disable line wrapping"
|
||||||
echo " --nopal Disable the color blocks"
|
printf '%s\n' " --nobold Disable bold text"
|
||||||
echo
|
printf '%s\n'
|
||||||
echo " Image:"
|
printf '%s\n' " Color Blocks:"
|
||||||
echo " --image Image to display with the script"
|
printf '%s\n' " --printcols start end Range of colors to print as blocks"
|
||||||
echo " The image gets priority over other"
|
printf '%s\n' " --blockwidth num Width of color blocks"
|
||||||
echo " images: (wallpaper, \$img)"
|
printf '%s\n' " --nopal Disable the color blocks"
|
||||||
echo " --size px Change the size of the image"
|
printf '%s\n'
|
||||||
echo " --cropoffset value Change the crop offset. Possible values:"
|
printf '%s\n' " Image:"
|
||||||
echo " northwest, north, northeast, west, center"
|
printf '%s\n' " --image Image to display with the script"
|
||||||
echo " east, southwest, south, southeast"
|
printf '%s\n' " The image gets priority over other"
|
||||||
echo
|
printf '%s\n' " images: (wallpaper, \$img)"
|
||||||
echo " --padding How many spaces to pad the text"
|
printf '%s\n' " --fontwidth px Used to automatically size the image"
|
||||||
echo " to the right"
|
printf '%s\n' " --size px Change the size of the image"
|
||||||
echo " --xoffset px How close the image will be "
|
printf '%s\n' " --cropoffset value Change the crop offset. Possible values:"
|
||||||
echo " to the left edge of the window"
|
printf '%s\n' " northwest, north, northeast, west, center"
|
||||||
echo " --yoffset px How close the image will be "
|
printf '%s\n' " east, southwest, south, southeast"
|
||||||
echo " to the top edge of the window"
|
printf '%s\n'
|
||||||
echo " --noimg Disable all images"
|
printf '%s\n' " --padding num How many spaces to pad the text"
|
||||||
echo " --nowall Disable the wallpaper function"
|
printf '%s\n' " to the right"
|
||||||
echo " and fallback to \$img"
|
printf '%s\n' " --xoffset px How close the image will be "
|
||||||
echo " --clean Remove all cropped images"
|
printf '%s\n' " to the left edge of the window"
|
||||||
echo
|
printf '%s\n' " --yoffset px How close the image will be "
|
||||||
echo " Other:"
|
printf '%s\n' " --gap num Gap between image and text right side"
|
||||||
echo " --help Print this text and exit"
|
printf '%s\n' " to the top edge of the window"
|
||||||
echo
|
printf '%s\n' " --noimg Disable all images"
|
||||||
|
printf '%s\n' " --nowall Disable the wallpaper function"
|
||||||
|
printf '%s\n' " and fallback to \$img"
|
||||||
|
printf '%s\n' " --clean Remove all cropped images"
|
||||||
|
printf '%s\n'
|
||||||
|
printf '%s\n' " Other:"
|
||||||
|
printf '%s\n' " --help Print this text and exit"
|
||||||
|
printf '%s\n'
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
# Args {{{
|
# Args {{{
|
||||||
|
|
||||||
|
|
||||||
# Loop index
|
|
||||||
index=0
|
|
||||||
|
|
||||||
# Args
|
# Args
|
||||||
args=$@
|
args="$@"
|
||||||
|
|
||||||
for argument in $args; do
|
for argument in $args; do
|
||||||
index=$((index + 1))
|
|
||||||
|
|
||||||
case $1 in
|
case $1 in
|
||||||
# Info
|
# Info
|
||||||
--title) title="$2" ;;
|
--title) title="$2" ;;
|
||||||
|
@ -308,14 +325,18 @@ for argument in $args; do
|
||||||
--song) song="$2" ;;
|
--song) song="$2" ;;
|
||||||
|
|
||||||
# Text Colors
|
# Text Colors
|
||||||
--colors) title_color="\033[38;5;${2}m"; \
|
--colors) title_color="$(tput setaf $2)"; \
|
||||||
[ ! -z $3 ] && subtitle_color="\033[38;5;${3}m"; \
|
[ ! -z $3 ] && subtitle_color="$(tput setaf $3)"; \
|
||||||
[ ! -z $4 ] && colon_color="\033[38;5;${4}m"; \
|
[ ! -z $4 ] && colon_color="$(tput setaf $4)"; \
|
||||||
[ ! -z $5 ] && info_color="\033[38;5;${5}m" ;;
|
[ ! -z $5 ] && info_color="$(tput setaf $5)" ;;
|
||||||
--titlecol) title_color="\033[38;5;${2}m" ;;
|
--titlecol) title_color="$(tput setaf $2)" ;;
|
||||||
--subtitlecol) subtitle_color="\033[38;5;${2}m" ;;
|
--subtitlecol) subtitle_color="$(tput setaf $2)" ;;
|
||||||
--coloncol) colon_color="\033[38;5;${2}m" ;;
|
--coloncol) colon_color="$(tput setaf $2)" ;;
|
||||||
--infocol) info_color="\033[38;5;${2}m" ;;
|
--infocol) info_color="$(tput setaf $2)" ;;
|
||||||
|
|
||||||
|
# Text Formatting
|
||||||
|
--nowrap) linewrap=0 ;;
|
||||||
|
--nobold) bold="" ;;
|
||||||
|
|
||||||
# Color Blocks
|
# Color Blocks
|
||||||
--printcols) start=$2; end=$3 ;;
|
--printcols) start=$2; end=$3 ;;
|
||||||
|
@ -323,11 +344,13 @@ for argument in $args; do
|
||||||
|
|
||||||
# Image
|
# Image
|
||||||
--image) usewall=0; img="$2" ;;
|
--image) usewall=0; img="$2" ;;
|
||||||
--size) imgsize="$2" ;;
|
--fontwidth) fontwidth="$2" ;;
|
||||||
|
--size) img_auto=0 imgsize="$2" ;;
|
||||||
--cropoffset) crop_offset="$2" ;;
|
--cropoffset) crop_offset="$2" ;;
|
||||||
--padding) pad="$2" ;;
|
--padding) padding="$2" ;;
|
||||||
--xoffset) xoffset="$2" ;;
|
--xoffset) xoffset="$2" ;;
|
||||||
--yoffset) yoffset="$2" ;;
|
--yoffset) yoffset="$2" ;;
|
||||||
|
--gap) gap="$2" ;;
|
||||||
--noimg) enableimages=0 ;;
|
--noimg) enableimages=0 ;;
|
||||||
--nowall) usewall=0 ;;
|
--nowall) usewall=0 ;;
|
||||||
--clean) rm -rf "$imgtempdir" || exit ;;
|
--clean) rm -rf "$imgtempdir" || exit ;;
|
||||||
|
@ -344,11 +367,20 @@ done
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
# Image Crop {{{
|
# Image {{{
|
||||||
|
|
||||||
|
|
||||||
# If the script was called with --noimg, disable images and padding
|
# If the script was called with --noimg, disable images and padding
|
||||||
if [ $enableimages -eq 1 ]; then
|
if [ $enableimages -eq 1 ]; then
|
||||||
|
# Check to see if auto=1
|
||||||
|
if [ $img_auto -eq 1 ]; then
|
||||||
|
# Image size is half of the terminal
|
||||||
|
imgsize=$(($(tput cols) * fontwidth / 2))
|
||||||
|
|
||||||
|
# Padding is half the terminal width + gap
|
||||||
|
padding=$(($(tput cols) / 2 + gap))
|
||||||
|
fi
|
||||||
|
|
||||||
# If usewall=1, Get image to display from current wallpaper.
|
# If usewall=1, Get image to display from current wallpaper.
|
||||||
# (only works with feh)
|
# (only works with feh)
|
||||||
[ $usewall -eq 1 ] && \
|
[ $usewall -eq 1 ] && \
|
||||||
|
@ -396,7 +428,6 @@ if [ $enableimages -eq 1 ]; then
|
||||||
img="$imgtempdir/$imgname"
|
img="$imgtempdir/$imgname"
|
||||||
else
|
else
|
||||||
img=""
|
img=""
|
||||||
pad=""
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
@ -405,6 +436,7 @@ fi
|
||||||
|
|
||||||
# Print Info {{{
|
# Print Info {{{
|
||||||
|
|
||||||
|
|
||||||
# Get cpu speed
|
# Get cpu speed
|
||||||
cpuspeed
|
cpuspeed
|
||||||
|
|
||||||
|
@ -414,43 +446,57 @@ cpuspeed
|
||||||
# Get window manager
|
# Get window manager
|
||||||
[ -z $windowmanager ] && getwindowmanager
|
[ -z $windowmanager ] && getwindowmanager
|
||||||
|
|
||||||
|
# Padding
|
||||||
|
pad=$(printf "%${padding}s")
|
||||||
|
|
||||||
clear
|
clear
|
||||||
|
|
||||||
# Underline title with length of title
|
# Underline title with length of title
|
||||||
underline=$(printf %"${#title}"s |tr " " "-")
|
underline=$(printf %"${#title}"s |tr " " "-")
|
||||||
|
|
||||||
# Hide the terminal cursor while we print the info
|
# Hide the terminal cursor while we print the info
|
||||||
echo -n -e "\033[?25l"
|
tput civis
|
||||||
|
|
||||||
# Print the title and underline
|
# Print the title and underline
|
||||||
echo -e "$pad$bold$title_color$title$clear"
|
printf "$pad$bold$title_color$title$clear \n"
|
||||||
echo -e "$pad$colon_color$underline$clear"
|
printf "$pad$colon_color$underline$clear \n"
|
||||||
|
|
||||||
# Custom echo function to make it easier to edit the info lines.
|
# Custom printf function to make it easier to edit the info lines.
|
||||||
echoinfo () {
|
printinfo () {
|
||||||
echo -n -e "$pad$bold$subtitle_color$1$clear"
|
printf "$pad$bold$subtitle_color$1$clear"
|
||||||
echo -n -e "$colon_color:$clear "
|
printf "$colon_color:$clear "
|
||||||
echo -e "$info_color$2$clear"
|
printf "$info_color$2$clear \n"
|
||||||
}
|
}
|
||||||
|
|
||||||
echoinfo "$title_os" "$os"
|
# Disable line wrap
|
||||||
echoinfo "$title_kernel" "$kernel"
|
[ $linewrap -eq 0 ] && tput rmam
|
||||||
echoinfo "$title_uptime" "$uptime"
|
|
||||||
echoinfo "$title_packages" "$packages"
|
printinfo "$title_os" "$os"
|
||||||
echoinfo "$title_shell" "$shell"
|
printinfo "$title_kernel" "$kernel"
|
||||||
echoinfo "$title_windowmanager" "$windowmanager"
|
printinfo "$title_uptime" "$uptime"
|
||||||
echoinfo "$title_cpu" "$cpu @ ${speed}GHz"
|
printinfo "$title_packages" "$packages"
|
||||||
echoinfo "$title_memory" "$memory"
|
printinfo "$title_shell" "$shell"
|
||||||
echoinfo "$title_song" "$song"
|
printinfo "$title_windowmanager" "$windowmanager"
|
||||||
|
printinfo "$title_cpu" "$cpu @ ${speed}GHz"
|
||||||
|
printinfo "$title_memory" "$memory"
|
||||||
|
printinfo "$title_song" "$song"
|
||||||
|
|
||||||
# Display the color blocks
|
# Display the color blocks
|
||||||
[ $printcols -eq 1 ] && echo -e "$(printcols)"
|
printf "\n"
|
||||||
|
[ $printcols -eq 1 ] && printf "$pad$(printcols)"
|
||||||
|
|
||||||
|
# Enable line wrap again
|
||||||
|
[ $linewrap -eq 0 ] && tput smam
|
||||||
|
|
||||||
# Display the image
|
# Display the image
|
||||||
echo -e "0;1;$xoffset;$yoffset;$imgsize;$imgsize;;;;;$img\n4;\n3;" |\
|
printf "0;1;$xoffset;$yoffset;$imgsize;$imgsize;;;;;$img\n4;\n3;" |\
|
||||||
/usr/lib/w3m/w3mimgdisplay
|
/usr/lib/w3m/w3mimgdisplay
|
||||||
|
|
||||||
# Show the cursor again
|
# Show the cursor again
|
||||||
echo -n -e "\033[?25h"
|
tput cnorm
|
||||||
|
|
||||||
|
# Move the cursor to the bottom of the terminal
|
||||||
|
tput cup $(tput lines)
|
||||||
|
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
|
Reference in New Issue