Compare commits

..

4 Commits

Author SHA1 Message Date
dylan araps
bd0f396305 general: cleanup 2017-12-14 10:32:18 +11:00
dylan araps
3c03c47f50 config: Update comment 2017-12-14 10:25:47 +11:00
dylan araps
b628ec0f4d image: Simplify crop 2017-12-14 10:22:23 +11:00
dylan araps
6c238a03b2 image: Simplify image handling. 2017-12-14 10:06:16 +11:00
4 changed files with 67 additions and 238 deletions

View File

@@ -14,62 +14,25 @@
- Fixed detection bug with TrueOS. [**@dawidd6**](https://github.com/dawidd6)
- Added support for macOS High Sierra. [**@yslgirl**](https://github.com/yslgirl)
- Added support for Container Linux by CoreOS. [**@chrisweeksnz**](https://github.com/chrisweeksnz)
- Added support for 2017 iOS devices. [**@iandrewt**](https://github.com/iandrewt)
- Added support for 2017 iOS devices [**@iandrewt**](https://github.com/iandrewt)
- Added support for LEDE. [**@dawidd6**](https://github.com/dawidd6)
- Added support for Pop!\_OS. [**@jliles**](https://github.com/jliles)
- Added support for Lunar Linux.
## General
- Added more info to verbose mode for debugging.
- Fixed bug in prompt location calculation.
## Ascii
- Added color updates for Kubuntu logo. **Maulik Mistry**
## Images
- [MacOS/iTerm2] Fixed thumbnail not appearing. [**@StarryTony**](https://github.com/StarryTony)
- Fixed bug with getting wallpaper from feh.
- Added `pixterm` backend.
- [MacOS/iTerm2] Fixed thumbnail not appearing (replaced by placeholder) [**@StarryTony**](https://github.com/StarryTony)
## Info
**Desktop Environment**
- Added GNOME version.
**Window Manager**
- Added support for most (*if not all*) current Wayland compositors/window manager's.
- [macOS] Fixed `chunkwm` being detected as `Kwm`. [**@iandrewt**](https://github.com/iandrewt)
**Window Manager Theme**
- Fixed `sawfish` detection.
- [macOS] Fixed chunkwm being detected as Kwm. [**@iandrewt**](https://github.com/iandrewt)
**Install Date**
- [macOS] Fixed Install Date. [**@iandrewt**](https://github.com/iandrewt)
**Theme**
- Fixed KDE font issue. [**@mstraube**](https://github.com/mstraube)
**CPU**
- [linux] Detect the correct temperature file to use.
- [windows] Removed `$temp` usage as it's an envar.
**GPU**
- [linux] Added driver version to NVIDIA output.
- [macOS] Added NVIDIA support. [**@iandrewt**](https://github.com/iandrewt)
**Package Manager**
- Added detection for Sabotage Linux's `butch` [**@MitchWeaver**](https://github.com/MitchWeaver)
@@ -77,15 +40,3 @@
**Resolution**
- [macOS] Fixed errors on non-retina screens. [**@iandrewt**](https://github.com/iandrewt)
**Song**
- Added support for Elisa. [**@mstraube**](https://github.com/mstraube)
**Model**
- Remove more unneeded outputs. [**@konimex**](https://github.com/konimex)
**Disk**
- Update Haiku's detection. [**@dawidd6**](https://github.com/dawidd6)

View File

@@ -543,7 +543,7 @@ disk_display="off"
# Image backend.
#
# Default: 'ascii'
# Values: 'ascii', 'caca', 'catimg', 'jp2a', 'iterm2', 'off', 'termpix', 'pixterm', 'tycat', 'w3m'
# Values: 'ascii', 'caca', 'catimg', 'jp2a', 'iterm2', 'off', 'tycat', 'w3m'
# Flag: --backend
image_backend="ascii"
@@ -617,18 +617,8 @@ image_loop="off"
# Values: 'dir'
thumbnail_dir="${XDG_CACHE_HOME:-${HOME}/.cache}/thumbnails/neofetch"
# Crop mode
#
# Default: 'normal'
# Values: 'normal', 'fit', 'fill'
# Flag: --crop_mode
#
# See this wiki page to learn about the fit and fill options.
# https://github.com/dylanaraps/neofetch/wiki/What-is-Waifu-Crop%3F
crop_mode="normal"
# Crop offset
# Note: Only affects 'normal' crop mode.
# Note: Only affects 'square' image size.
#
# Default: 'center'
# Values: 'northwest', 'north', 'northeast', 'west', 'center'
@@ -637,20 +627,21 @@ crop_mode="normal"
crop_offset="center"
# Image size
# The image is half the terminal width by default.
# NOTE: 'square' is the OLD behavior.
# NOTE: 'auto' keeps image aspect ratio and size where possible.
#
# Default: 'auto'
# Values: 'auto', '00px', '00%', 'none'
# Values: 'auto', 'square'
# Flags: --image_size
# --size
image_size="auto"
# Ggap between image and text
# Gap between image and text
#
# Default: '3'
# Default: '4'
# Values: 'num', '-num'
# Flag: --gap
gap=3
gap=4
# Image offsets
# Only works with the w3m backend.

189
neofetch
View File

@@ -114,8 +114,7 @@ get_distro() {
elif type -p tazpkg >/dev/null; then
distro="SliTaz $(< /etc/slitaz-release)"
elif type -p kpt >/dev/null && \
type -p kpm >/dev/null; then
elif type -p kpm > /dev/null; then
distro="KSLinux"
elif [[ -d "/system/app/" && -d "/system/priv-app" ]]; then
@@ -488,6 +487,9 @@ get_packages() {
type -p dpkg >/dev/null && \
packages="$((packages+=$(dpkg --get-selections | grep -cv deinstall$)))"
type -p kpm >/dev/null && \
packages="$((packages+=$(kpm --get-selections | grep -cv deinstall$)))"
type -p pkgtool >/dev/null && \
packages="$((packages+=$(ls -1 /var/log/packages | wc -l)))"
@@ -545,10 +547,6 @@ get_packages() {
type -p alps >/dev/null && \
packages="$((packages+=$(alps showinstalled | wc -l)))"
type -p kpt >/dev/null && \
type -p kpm >/dev/null && \
packages="$((packages+=$(kpm --get-selections | grep -cv deinstall$)))"
if type -p cave >/dev/null; then
package_dir=(/var/db/paludis/repositories/{cross-installed,installed}/*/data/*)
packages="$((packages+=$(ls -d -1 "${package_dir[@]}" | wc -l)))"
@@ -668,9 +666,6 @@ get_de() {
elif [[ "$MATE_DESKTOP_SESSION_ID" ]]; then
de="MATE"
elif [[ "$TDE_FULL_SESSION" ]]; then
de="Trinity"
fi
# When a window manager is started from a display manager
@@ -682,12 +677,13 @@ get_de() {
esac
# Fallback to using xprop.
[[ "$DISPLAY" && -z "$de" ]] && \
[[ -n "$DISPLAY" && -z "$de" ]] && \
de="$(xprop -root | awk '/KDE_SESSION_VERSION|^_MUFFIN|xfce4|xfce5/')"
# Format strings.
case "$de" in
"KDE_SESSION_VERSION"*) de="KDE${de/* = }" ;;
*"TDE_FULL_SESSION"*) de="Trinity" ;;
*"MUFFIN"* | "Cinnamon") de="$(cinnamon --version)"; de="${de:-Cinnamon}" ;;
*"xfce4"*) de="Xfce4" ;;
*"xfce5"*) de="Xfce5" ;;
@@ -707,37 +703,21 @@ get_wm() {
# If function was run, stop here.
((wm_run == 1)) && return
if [[ "$WAYLAND_DISPLAY" ]]; then
wm="$(ps -e | grep -m 1 -o -F \
-e "asc" \
-e "fireplace" \
-e "grefsen" \
-e "mazecompositor" \
-e "maynard" \
-e "motorcar" \
-e "orbment" \
-e "orbital" \
-e "perceptia" \
-e "rustland" \
-e "sway" \
-e "velox" \
-e "wavy" \
-e "wayhouse" \
-e "way-cooler" \
-e "westford" \
-e "weston")"
elif [[ "$DISPLAY" && "$os" != "Mac OS X" ]]; then
if [[ -n "$DISPLAY" && "$os" != "Mac OS X" ]]; then
id="$(xprop -root -notype _NET_SUPPORTING_WM_CHECK)"
id="${id##* }"
wm="$(xprop -id "$id" -notype -len 100 -f _NET_WM_NAME 8t)"
wm="${wm/*WM_NAME = }"
wm="${wm/*_NET_WM_NAME = }"
wm="${wm/\"}"
wm="${wm/\"*}"
# Window Maker does not set _NET_WM_NAME
[[ "$wm" =~ "WINDOWMAKER" ]] && wm="wmaker"
# Fallback for Wayland wms.
[[ "$wm" == "xwlc" ]] && \
wm="$(ps -e | grep -m 1 -o -F -e "sway" -e "orbment" -e "velox" -e "orbital")"
else
case "$os" in
"Mac OS X")
@@ -753,13 +733,11 @@ get_wm() {
;;
"Windows")
wm="$(tasklist | grep -m 1 -o -F \
-e "bugn" \
wm="$(tasklist | grep -m 1 -o -F -e "bugn" \
-e "Windawesome" \
-e "blackbox" \
-e "emerge" \
-e "litestep")"
[[ "$wm" == "blackbox" ]] && wm="bbLean (Blackbox)"
wm="${wm:+$wm, }Explorer"
;;
@@ -1212,7 +1190,7 @@ get_gpu() {
# Read GPUs into array.
IFS=$'\n'
gpus=($(lspci -mm | awk -F '\\"|\\" \\"|\\(' \
'/"Display|"3D|"VGA/ {a[$0] = $1 $3 " " $4} END{for(i in a)
'/"Display|"3D|"VGA/ {a[$0] = $3 " " $4} END{for(i in a)
{if(!seen[a[i]]++) print a[i]}}'))
IFS="$old_ifs"
@@ -1244,16 +1222,9 @@ get_gpu() {
;;
*"intel"*)
# (sorry)
freq="$(< /sys/devices/pci0000:00/0000:\
"${gpu/ *}"/drm/card0/gt_cur_freq_mhz)"
type -p glxinfo >/dev/null && \
gpu="$(glxinfo | grep "Device:.*Intel")"
gpu="${gpu/*Intel/Intel}"
gpu="${gpu/'(R)'}"
gpu="${gpu/'Corporation'}"
gpu="${gpu/ \(*}"
[[ -z "$(trim "$gpu")" ]] && gpu="Intel Integrated Graphics"
@@ -1270,8 +1241,7 @@ get_gpu() {
gpu="${gpu/Intel }"
fi
prin "${subtitle:+${subtitle}${gpu_name}}" "$gpu ${freq:+@ ${freq}Mhz}"
prin "${subtitle:+${subtitle}${gpu_name}}" "$gpu"
((++gpu_num))
done
@@ -1661,7 +1631,7 @@ get_style() {
# Fix weird output when the function is run multiple times.
unset gtk2_theme gtk3_theme theme path
if [[ "$DISPLAY" && "$os" != "Mac OS X" ]]; then
if [[ -n "$DISPLAY" && "$os" != "Mac OS X" ]]; then
# Get DE if user has disabled the function.
((de_run != 1)) && get_de
@@ -2404,8 +2374,7 @@ image_backend() {
"ascii") get_ascii ;;
"off") image_backend="off" ;;
"caca" | "catimg" | "jp2a" | "iterm2" | "termpix" |\
"tycat" | "w3m" | "sixel" | "pixterm")
"caca" | "catimg" | "jp2a" | "iterm2" | "termpix" | "tycat" | "w3m" | "sixel")
get_image_source
if [[ ! -f "$image" ]]; then
@@ -2431,7 +2400,7 @@ image_backend() {
*)
err "Image: Unknown image backend specified '$image_backend'."
err "Image: Valid backends are: 'ascii', 'caca', 'catimg', 'jp2a', 'iterm2',
'off', 'sixel', 'pixterm', 'termpix', 'tycat', 'w3m')"
'off', 'sixel', 'termpix', 'tycat', 'w3m')"
err "Image: Falling back to ascii mode."
get_ascii
;;
@@ -2698,50 +2667,32 @@ get_image_size() {
font_width="$((term_width / columns))"
font_height="$((term_height / lines))"
case "$image_size" in
"auto")
image_size="$((columns * font_width / 2))"
term_height="$((term_height - term_height / 4))"
((term_height < image_size)) && \
image_size="$term_height"
;;
*"%")
percent="${image_size/\%}"
image_size="$((percent * term_width / 100))"
(((percent * term_height / 50) < image_size)) && \
image_size="$((percent * term_height / 100))"
;;
"none")
# Get image size so that we can do a better crop.
# Get image size.
size="$(identify -format "%w %h" "$image")"
width="${size%% *}"
height="${size##* }"
crop_mode="none"
while (( "$width" >= ("$term_width" / 2) ||
"$height" >= "$term_height" )); do
width="$((width / 2))"
height="$((height / 2))"
done
case "$image_size" in
"square")
width="$((columns * font_width / 2))"
height="$width"
;;
*) image_size="${image_size/px}" ;;
*)
while (( width >= (term_width / 2) ||
height >= (term_height / 2) )); do
width="$((width * 10 / 15))"
height="$((height * 10 / 15))"
done
;;
esac
width="${width:-$image_size}"
height="${height:-$image_size}"
text_padding="$((width / font_width + gap + xoffset/font_width))"
}
make_thumbnail() {
# Name the thumbnail using variables so we can
# use it later.
image_name="$crop_mode-$crop_offset-$width-$height-${image##*/}"
# Name the thumbnail using variables so we can use it later.
image_name="$image_size-$crop_offset-$width-$height-${image##*/}"
# Handle file extensions.
case "${image##*.}" in
@@ -2753,62 +2704,17 @@ make_thumbnail() {
# Create the thumbnail dir if it doesn't exist.
mkdir -p "$thumbnail_dir"
# Check to see if the thumbnail exists before we do any cropping.
if [[ ! -f "$thumbnail_dir/$image_name" ]]; then
# Get image size so that we can do a better crop.
if [[ -z "$size" ]]; then
size="$(identify -format "%w %h" "$image")"
og_width="${size%% *}"
og_height="${size##* }"
# This checks to see if height is greater than width
# so we can do a better crop of portrait images.
size="$og_height"
((og_height > og_width)) && size="$og_width"
fi
case "$crop_mode" in
"fit")
c="$(convert "$image" \
-colorspace srgb \
-format "%[pixel:p{0,0}]" info:)"
[[ ! -f "$thumbnail_dir/$image_name" ]] && \
convert \
-background none \
"$image" \
-trim +repage \
-gravity south \
-background "$c" \
-extent "$size"x"$size" \
-scale "$width"x"$height" \
"$thumbnail_dir/$image_name"
;;
"fill")
convert \
-strip \
-quality 50 \
-gravity "$crop_offset" \
-background none \
"$image" \
-trim +repage \
-scale "$width"x"$height"^ \
-sample "$width"x"$height"^ \
-extent "$width"x"$height" \
"$thumbnail_dir/$image_name"
;;
"none") cp "$image" "$thumbnail_dir/$image_name" ;;
*)
convert \
-background none \
"$image" \
-gravity "$crop_offset" \
-crop "$size"x"$size"+0+0 \
-quality 95 \
-scale "$width"x"$height" \
"$thumbnail_dir/$image_name"
;;
esac
fi
# The final image.
image="$thumbnail_dir/$image_name"
}
@@ -2831,16 +2737,8 @@ display_image() {
to_off "Image: jp2a failed to display the image."
;;
"pixterm")
pixterm -tc "$((width / font_width))" \
-tr "$((height / font_height))" \
"$image" ||\
to_off "Image: pixterm failed to display the image."
;;
"sixel")
img2sixel -w "$width" "$image" ||\
to_off "Image: libsixel failed to display the image."
img2sixel -w "$width" "$image" || to_off "Image: libsixel failed to display the image."
;;
"termpix")
@@ -4469,7 +4367,6 @@ IMAGE BACKEND:
--catimg source Shortcut to use 'catimg' backend.
--iterm2 source Shortcut to use 'iterm2' backend.
--jp2a source Shortcut to use 'jp2a' backend.
--pixterm source Shortcut to use 'pixterm' backend.
--sixel source Shortcut to use 'sixel' backend.
--termpix source Shortcut to use 'termpix' backend.
--tycat source Shortcut to use 'tycat' backend.
@@ -4505,11 +4402,9 @@ ASCII:
IMAGE:
--loop Redraw the image constantly until Ctrl+C is used. This fixes issues
in some terminals emulators when using image mode.
--size 00px | --size 00% How to size the image.
--size auto | --size square How to size the image.
Possible values: auto, 00px, 00%, none
--crop_mode mode Which crop mode to use
Takes the values: normal, fit, fill
--crop_offset value Change the crop offset for normal mode.
--crop_offset value Change the crop offset for square mode.
Possible values: northwest, north, northeast,
west, center, east, southwest, south, southeast
@@ -4685,8 +4580,8 @@ get_args() {
# Image backend
"--backend") image_backend="$2" ;;
"--source") image_source="$2" ;;
"--ascii" | "--caca" | "--catimg" | "--jp2a" | "--iterm2" | "--off" | "--pixterm" |\
"--sixel" | "--termpix" | "--tycat" | "--w3m")
"--ascii" | "--caca" | "--catimg" | "--jp2a" | "--iterm2" | "--off" | "--sixel" |\
"--termpix" | "--tycat" | "--w3m")
image_backend="${1/--}"
case "$2" in
"-"* | "") ;;

View File

@@ -207,9 +207,6 @@ Shortcut to use 'iterm2' backend.
\fB\-\-jp2a\fR source
Shortcut to use 'jp2a' backend.
.TP
\fB\-\-pixterm\fR source
Shortcut to use 'pixterm' backend.
.TP
\fB\-\-sixel\fR source
Shortcut to use 'sixel' backend.
.TP
@@ -262,16 +259,11 @@ Possible values: bar, infobar, barinfo, off
Redraw the image constantly until Ctrl+C is used. This fixes issues
in some terminals emulators when using image mode.
.TP
\fB\-\-size\fR 00px | \fB\-\-size\fR 00%
How to size the image.
\fB\-\-size\fR auto | \fB\-\-size\fR square How to size the image.
Possible values: auto, 00px, 00%, none
.TP
\fB\-\-crop_mode\fR mode
Which crop mode to use
Takes the values: normal, fit, fill
.TP
\fB\-\-crop_offset\fR value
Change the crop offset for normal mode.
Change the crop offset for square mode.
Possible values: northwest, north, northeast,
west, center, east, southwest, south, southeast
.TP