11 Commits
0.4.0 ... disk

Author SHA1 Message Date
Dylan Araps
af166966b9 pfetch: revert unrelated commit. 2019-10-14 19:11:26 +03:00
Dylan Araps
219d8f2117 pfetch: revert unrelated commit. 2019-10-14 19:10:42 +03:00
Dylan Araps
0834d53b2a pfetch: revert unrelated commit. 2019-10-14 19:06:31 +03:00
Dylan Araps
0f1d6845db pfetch: revert unrelated commit. 2019-10-14 19:05:36 +03:00
Dylan Araps
3895dd003d pfetch: disk support 2019-10-14 19:04:10 +03:00
Dylan Araps
6c3d5c3a87 pfetch: Fix android sed 2019-10-14 09:53:12 +03:00
Dylan Araps
616e1b0c3b pfetch: fix android issues 2019-10-14 09:04:15 +03:00
Dylan Araps
44dca45301 Merge branch 'master' of github.com:dylanaraps/pfetch 2019-10-14 08:45:25 +03:00
Dylan Araps
256c1678d6 pfetch: fix package count. 2019-10-14 08:45:07 +03:00
dylan
a3bdc11167 Merge pull request #26 from turquoise-hexagon/master
pfetch: crux pkgs count support
2019-10-06 12:56:26 +03:00
turquoise-hexagon
2bc0fd87a5 add support for crux pkgs count 2019-10-06 11:21:59 +02:00

75
pfetch
View File

@@ -438,6 +438,7 @@ get_pkgs() {
Linux*) Linux*)
# Commands which print packages one per line. # Commands which print packages one per line.
has bonsai && bonsai list has bonsai && bonsai list
has crux && pkginfo -i
has pacman-key && pacman -Qq has pacman-key && pacman -Qq
has dpkg && dpkg-query -f '.\n' -W has dpkg && dpkg-query -f '.\n' -W
has rpm && rpm -qa has rpm && rpm -qa
@@ -508,7 +509,7 @@ get_pkgs() {
esac | wc -l esac | wc -l
` `
log pkgs "${packages:-?}" >&6 [ "$packages" -gt 1 ] && log pkgs "$packages" >&6
} }
get_memory() { get_memory() {
@@ -693,6 +694,67 @@ get_memory() {
log memory "${mem_used:-?}M / ${mem_full:-?}M" >&6 log memory "${mem_used:-?}M / ${mem_full:-?}M" >&6
} }
get_disk() {
# Store the version of the 'df' command as the available
# flags, options and implementation differs between operating
# systems and we need to handle these edge-cases.
df_version=$(df --version 2>&1)
case $df_version in
# The 'df' command is from AIX.
*IMitv*)
set -- -P -g
;;
# The 'df' command is from IRIX.
*befhikm*)
set -- -P -k
;;
# The 'df' command is from OpenBSD.
*hiklnP*)
set -- -h
;;
# The 'df' command is from Haiku and is wildly
# different and provides no workable output,
# end here.
*Tracker*) # Haiku
return
;;
# From testing it is saffe to assume that
# any other 'df' version provides these flags.
*)
set -- -P -h
;;
esac
# Read the output of 'df' line by line. The first line
# contains header information for the "table" so it is
# skipped.
#
# The next lines are then split to grab the relevant
# information and thankfully the output remains the
# same between all but one 'df' implementation.
#
# TODO: Configure disks to send to 'df'. Do we need to
# do this? I'd love to _not_ do it.
df "$@" / | while read -r name full used _ perc _; do
[ "$header" ] || { header=1; continue; }
case $df_version in
# The 'df' command is from IRIX.
*befhikm*)
used=$((used/1024/1024))G
full=$((full/1024/1024))G
;;
esac
log disk "$name [$used / $full ($perc)]" >&6
done
}
get_wm() { get_wm() {
case $os in case $os in
# Don't display window manager on macOS. # Don't display window manager on macOS.
@@ -1301,8 +1363,12 @@ get_ascii() {
# output without the use of a pipe ('|'). # output without the use of a pipe ('|').
# This ensures that any variables defined in the while loop # This ensures that any variables defined in the while loop
# are still accessible in the script. # are still accessible in the script.
#
# The 'awk' command below used to be a simple 'sed', however
# some versions of Android shipped with a totally broken 'sed'
# command from 'toybox' and so we're forced to avoid 'sed'.
done <<-EOF done <<-EOF
$(printf %s "$ascii" | sed 's/\[3.m//g') $(printf %s "$ascii" | awk '{gsub("\\[3.m","");print}')
EOF EOF
# Add a gap between the ascii art and the information. # Add a gap between the ascii art and the information.
@@ -1325,6 +1391,11 @@ main() {
# This gives full control over what it displayed on the screen. # This gives full control over what it displayed on the screen.
exec 6>&1 >/dev/null exec 6>&1 >/dev/null
# Ensure that the 'TMPDIR' is writable as heredocs use it and
# fail without the write permission. This was found to be the
# case on Android where the temporary directory requires root.
[ -w "${TMPDIR:-/tmp}" ] || export TMPDIR=~
# Generic color list. # Generic color list.
# Disable warning about unused variables. # Disable warning about unused variables.
# shellcheck disable=2034 # shellcheck disable=2034