mirror of
https://github.com/eepykate/fet.sh.git
synced 2026-11-07 16:01:03 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
43152b2837 | ||
|
|
0d8ab196c4 | ||
|
|
ea9abc7ffb | ||
|
|
accf87f751 | ||
|
|
7d2097cf00 | ||
|
|
1a4ecf462b | ||
|
|
81d4666525 | ||
|
|
8b3af10779 | ||
|
|
4a7caeabe5 | ||
|
|
dc190ac7ac | ||
|
|
71afae542c | ||
|
|
33d1029e8b | ||
|
|
402217d114 | ||
|
|
293b388623 | ||
|
|
473ed6f54f | ||
|
|
5dd087585c | ||
|
|
0ac1b7d216 | ||
|
|
b7fbb8784f | ||
|
|
6374278cac | ||
|
|
ce60c65e85 | ||
|
|
5b0c166444 | ||
|
|
f139798f16 | ||
|
|
55931b3bdf | ||
|
|
8f4d1cd8da | ||
|
|
e377e92ee2 |
No files matched your search
@@ -7,6 +7,9 @@ fetch written in POSIX shell with no external commands
|
|||||||
|
|
||||||
### Installing
|
### Installing
|
||||||
**Arch:** [fet.sh-git](https://aur.archlinux.org/packages/fet.sh-git/) (AUR)
|
**Arch:** [fet.sh-git](https://aur.archlinux.org/packages/fet.sh-git/) (AUR)
|
||||||
|
**Nix:** [fet-sh](https://search.nixos.org/packages?show=fet-sh&query=fet-sh&channel=unstable) (nixpkgs-unstable)
|
||||||
|
**Gentoo:** [app-misc/fetsh](https://gpo.zugaina.org/Overlays/guru/app-misc/fetsh) (GURU overlay)
|
||||||
|
**KISS:** [fetsh](https://github.com/kisslinux/community/tree/master/community/fetsh) (Community)
|
||||||
**Other Distros:** copy `fet.sh` to somewhere in $PATH
|
**Other Distros:** copy `fet.sh` to somewhere in $PATH
|
||||||
|
|
||||||
### Customization
|
### Customization
|
||||||
|
|||||||
@@ -7,47 +7,56 @@
|
|||||||
# supress errors
|
# supress errors
|
||||||
exec 2>/dev/null
|
exec 2>/dev/null
|
||||||
set --
|
set --
|
||||||
_() { # [ a = b ] with globbing
|
eq() { # equals | [ a = b ] with globbing
|
||||||
case $1 in
|
case $1 in
|
||||||
|
# if the second argument matches the first, exit normally
|
||||||
$2) return
|
$2) return
|
||||||
|
# if it doesn't match, reverse the output of `:`, which makes an error
|
||||||
esac;! :
|
esac;! :
|
||||||
}
|
}
|
||||||
|
|
||||||
## Terminal
|
## DE
|
||||||
|
wm="$XDG_CURRENT_DESKTOP"
|
||||||
[ "$XDG_CURRENT_DESKTOP" ] && wm="$XDG_CURRENT_DESKTOP"
|
[ "$wm" ] || wm="$DESKTOP_SESSION"
|
||||||
[ "$DESKTOP_SESSION" ] && wm="$DESKTOP_SESSION"
|
|
||||||
|
|
||||||
## Distro
|
## Distro
|
||||||
o=/etc/os-release
|
# freedesktop.org/software/systemd/man/os-release.html
|
||||||
[ -f $o ] && . $o # a common file that has variables about the distro
|
# a common file that has variables about the distro
|
||||||
|
for os in /etc/os-release /usr/lib/os-release; do
|
||||||
|
# some POSIX shells exit when trying to source a file that doesn't exist
|
||||||
|
[ -f $os ] && . $os && break
|
||||||
|
done
|
||||||
|
|
||||||
if [ -e /proc/$$/comm ]; then
|
if [ -e /proc/$$/comm ]; then
|
||||||
|
## Terminal
|
||||||
while [ ! "$term" ]; do
|
while [ ! "$term" ]; do
|
||||||
# loop over lines in /proc/pid/status until it reaches PPid
|
# loop over lines in /proc/pid/status until it reaches PPid
|
||||||
# then save that to a variable and exit the file
|
# then save that to a variable and exit the file
|
||||||
while read -r line; do
|
while read -r line; do
|
||||||
_ "$line" "PPid*" && ppid=${line##*:?} && break
|
eq "$line" "PPid*" && ppid=${line##*:?} && break
|
||||||
done < "/proc/${ppid:-$PPID}/status"
|
done < "/proc/${ppid:-$PPID}/status"
|
||||||
|
|
||||||
|
# Make sure not to do an infinite loop
|
||||||
|
[ "$pppid" = "$ppid" ] && break
|
||||||
|
pppid="$ppid"
|
||||||
|
|
||||||
# get name of binary
|
# get name of binary
|
||||||
read -r name < "/proc/$ppid/comm"
|
read -r name < "/proc/$ppid/comm"
|
||||||
|
|
||||||
case $name in
|
case $name in
|
||||||
*sh|"${0##*/}"|tmux*) ;; # skip shells
|
*sh|"${0##*/}") ;; # skip shells
|
||||||
*[Ll]ogin*|*init*) break;; # exit when the top is reached
|
*[Ll]ogin*|*init*) break;; # exit when the top is reached
|
||||||
*) term="$name" # anything else can be assumed to be the terminal
|
*) term="$name" # anything else can be assumed to be the terminal
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
## WM/DE
|
## WM/DE
|
||||||
# standard variables, mostly used for DEs
|
[ ! "$wm" ] &&
|
||||||
[ "$DISPLAY" ] && [ ! "$wm" ] &&
|
|
||||||
# non-standard WMs
|
|
||||||
# loop over all processes and check the binary name
|
# loop over all processes and check the binary name
|
||||||
for i in /proc/*/comm; do
|
for i in /proc/*/comm; do
|
||||||
read -r c < "$i"
|
read -r c < "$i"
|
||||||
case $c in
|
case $c in
|
||||||
awesome|xmonad|qtile|i3*|box*|*wm*) wm="$c"; break;;
|
awesome|xmonad*|qtile|sway|i3|[bfo]*box|*wm*) wm="${c%%-*}"; break;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
@@ -55,7 +64,7 @@ if [ -e /proc/$$/comm ]; then
|
|||||||
# loop over lines in /proc/meminfo until it reaches MemTotal,
|
# loop over lines in /proc/meminfo until it reaches MemTotal,
|
||||||
# then convert the amount (second word) from KB to MB
|
# then convert the amount (second word) from KB to MB
|
||||||
while read -r line; do
|
while read -r line; do
|
||||||
_ "$line" "MemTotal*" && set -- $line && break
|
eq "$line" "MemTotal*" && set -- $line && break
|
||||||
done < /proc/meminfo
|
done < /proc/meminfo
|
||||||
mem="$(( $2 / 1000 ))MB"
|
mem="$(( $2 / 1000 ))MB"
|
||||||
|
|
||||||
@@ -77,7 +86,7 @@ if [ -e /proc/$$/comm ]; then
|
|||||||
## Kernel
|
## Kernel
|
||||||
read -r _ _ version _ < /proc/version
|
read -r _ _ version _ < /proc/version
|
||||||
kernel="${version%%-*}"
|
kernel="${version%%-*}"
|
||||||
_ "$version" "*Microsoft*" && ID="fake $ID"
|
eq "$version" "*Microsoft*" && ID="fake $ID"
|
||||||
|
|
||||||
## Motherboard // laptop
|
## Motherboard // laptop
|
||||||
read -r model < /sys/devices/virtual/dmi/id/product_name
|
read -r model < /sys/devices/virtual/dmi/id/product_name
|
||||||
@@ -87,7 +96,8 @@ if [ -e /proc/$$/comm ]; then
|
|||||||
# then save the argument count to $pkgs
|
# then save the argument count to $pkgs
|
||||||
set --
|
set --
|
||||||
[ -d /var/db/kiss/installed ] && set -- /var/db/kiss/installed/*
|
[ -d /var/db/kiss/installed ] && set -- /var/db/kiss/installed/*
|
||||||
[ -d /var/lib/pacman/local ] && set -- /var/lib/pacman/local/*
|
[ -d /var/lib/pacman/local ] && set -- /var/lib/pacman/local/[0-9a-z]*
|
||||||
|
[ -d /var/lib/dpkg/info ] && set -- /var/lib/dpkg/info/*.list
|
||||||
[ -d /var/db/xbps ] && set -- /var/db/xbps/.*
|
[ -d /var/db/xbps ] && set -- /var/db/xbps/.*
|
||||||
[ -d /var/db/pkg ] && set -- /var/db/pkg/*/* # gentoo
|
[ -d /var/db/pkg ] && set -- /var/db/pkg/*/* # gentoo
|
||||||
pkgs=${###0}
|
pkgs=${###0}
|
||||||
@@ -190,9 +200,14 @@ elif v=/System/Library/CoreServices/SystemVersion.plist; [ -f "$v" ]; then
|
|||||||
done < "$v"
|
done < "$v"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
eq "$0" "*fetish" && printf 'Step on me daddy\n' && exit
|
||||||
|
|
||||||
|
# help i dont know if it's a capital consistently
|
||||||
|
eq "$wm" "*[Gg][Nn][Oo][Mm][Ee]*" && wm="foot DE"
|
||||||
|
|
||||||
## GTK
|
## GTK
|
||||||
while read -r line; do
|
while read -r line; do
|
||||||
_ "$line" "gtk-theme*" && gtk="${line##*=}" && break
|
eq "$line" "gtk-theme*" && gtk="${line##*=}" && break
|
||||||
done < "${XDG_CONFIG_HOME:=$HOME/.config}/gtk-3.0/settings.ini"
|
done < "${XDG_CONFIG_HOME:=$HOME/.config}/gtk-3.0/settings.ini"
|
||||||
|
|
||||||
# Shorten $cpu and $vendor
|
# Shorten $cpu and $vendor
|
||||||
@@ -205,6 +220,7 @@ cpu="${cpu%% CPU}"
|
|||||||
cpu="${cpu##CPU }"
|
cpu="${cpu##CPU }"
|
||||||
cpu="${cpu##*AMD }"
|
cpu="${cpu##*AMD }"
|
||||||
cpu="${cpu%% with*}"
|
cpu="${cpu%% with*}"
|
||||||
|
cpu="${cpu% *-Core*}"
|
||||||
|
|
||||||
col() {
|
col() {
|
||||||
printf ' '
|
printf ' '
|
||||||
@@ -227,7 +243,7 @@ for i in $info; do
|
|||||||
n) echo;;
|
n) echo;;
|
||||||
os) print os "$ID";;
|
os) print os "$ID";;
|
||||||
sh) print sh "${SHELL##*/}";;
|
sh) print sh "${SHELL##*/}";;
|
||||||
wm) print wm "$wm";;
|
wm) print wm "${wm##*/}";;
|
||||||
up) print up "$up";;
|
up) print up "$up";;
|
||||||
gtk) print gtk "${gtk# }";;
|
gtk) print gtk "${gtk# }";;
|
||||||
cpu) print cpu "$vendor$cpu";;
|
cpu) print cpu "$vendor$cpu";;
|
||||||
|
|||||||
Reference in new issue
Block a user