18 Commits
Author SHA1 Message Date
GaugeK 8b3af10779 Shorten CPU name and remove dir from wm 2020-08-25 04:28:07 +10:00
gk 4a7caeabe5 Merge pull request #20 from elkowar/readme_add_nix
Add nixpkgs package to readme
2020-08-25 02:12:09 +10:00
elkowar dc190ac7ac Add nixpkgs package to readme 2020-08-24 15:25:41 +02:00
GaugeK 71afae542c Fix inaccurated arch package count (Solves #19) 2020-08-24 02:46:19 +10:00
gk 33d1029e8b Merge pull request #18 from MatthiasCoppens/repology
Add Gentoo package
2020-08-22 18:43:48 +10:00
GaugeK 402217d114 don't check if DE variables exist before setting them, fix location of terminal comment 2020-08-22 15:34:37 +10:00
GaugeK 293b388623 Sane function name for [ a = b ] with globbing clone 2020-08-22 14:50:06 +10:00
Matthias Coppens 473ed6f54f Add Gentoo package
I added the Gentoo package to the README. I've already
written a report to Repology that the projects [fet.sh, fet-sh and fetsh](https://repology.org/project/fet.sh/related) should be merged.
When these are merged, you can use this Repology badge:
[![Packaging status](https://repology.org/badge/vertical-allrepos/fet.sh.svg)](https://repology.org/project/fet.sh/versions)
2020-08-21 21:33:12 +02:00
GaugeK 5dd087585c Check for os-release in /etc and /usr/lib 2020-08-22 04:58:22 +10:00
GaugeK 0ac1b7d216 Detect 'i3' as wm without any globbing 2020-08-22 04:54:12 +10:00
GaugeK b7fbb8784f Merge branch 'MatthiasCoppens-master' into master 2020-08-22 04:52:36 +10:00
GaugeK 6374278cac Fix file conflicts between '6gk:master' and 'MatthiasCoppens:master' 2020-08-22 04:48:51 +10:00
gk ce60c65e85 Merge pull request #16 from mfs/fix-xmonad
Detect xmonad.
2020-08-22 04:40:24 +10:00
gk 5b0c166444 Merge branch 'master' into fix-xmonad 2020-08-22 04:40:01 +10:00
GaugeK f139798f16 Remove faulty tmux support
Tmux's PPid is the 1, so skipping that makes the term your init
2020-08-22 04:14:55 +10:00
Mike Sampson 55931b3bdf Detect xmonad.
When using a user config the executable is located in the users
home directory and is called $HOME/.xmonad/xmonad-x86_64-linux
2020-08-21 19:22:17 +10:00
Matthias Coppens 8f4d1cd8da Added detection of sway 2020-08-21 10:30:28 +02:00
GaugeK e377e92ee2 Don't report terminal as tmux 2020-08-21 14:01:36 +10:00
2 changed files with 26 additions and 15 deletions

No files matched your search

+2
View File
@@ -7,6 +7,8 @@ fetch written in POSIX shell with no external commands
### Installing
**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)
**Other Distros:** copy `fet.sh` to somewhere in $PATH
### Customization
+24 -15
View File
@@ -7,33 +7,39 @@
# supress errors
exec 2>/dev/null
set --
_() { # [ a = b ] with globbing
eq() { # equals | [ a = b ] with globbing
case $1 in
# if the second argument matches the first, exit normally
$2) return
# if it doesn't match, reverse the output of `:`, which makes an error
esac;! :
}
## Terminal
[ "$XDG_CURRENT_DESKTOP" ] && wm="$XDG_CURRENT_DESKTOP"
[ "$DESKTOP_SESSION" ] && wm="$DESKTOP_SESSION"
## DE
wm="$XDG_CURRENT_DESKTOP"
wm="$DESKTOP_SESSION"
## Distro
o=/etc/os-release
[ -f $o ] && . $o # a common file that has variables about the distro
# freedesktop.org/software/systemd/man/os-release.html
# 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
## Terminal
while [ ! "$term" ]; do
# loop over lines in /proc/pid/status until it reaches PPid
# then save that to a variable and exit the file
while read -r line; do
_ "$line" "PPid*" && ppid=${line##*:?} && break
eq "$line" "PPid*" && ppid=${line##*:?} && break
done < "/proc/${ppid:-$PPID}/status"
# get name of binary
read -r name < "/proc/$ppid/comm"
case $name in
*sh|"${0##*/}"|tmux*) ;; # skip shells
*sh|"${0##*/}") ;; # skip shells
*[Ll]ogin*|*init*) break;; # exit when the top is reached
*) term="$name" # anything else can be assumed to be the terminal
esac
@@ -47,7 +53,7 @@ if [ -e /proc/$$/comm ]; then
for i in /proc/*/comm; do
read -r c < "$i"
case $c in
awesome|xmonad|qtile|i3*|box*|*wm*) wm="$c"; break;;
awesome|xmonad*|qtile|sway|i3|*box*|*wm*) wm="${c%%-*}"; break;;
esac
done
@@ -55,7 +61,7 @@ if [ -e /proc/$$/comm ]; then
# loop over lines in /proc/meminfo until it reaches MemTotal,
# then convert the amount (second word) from KB to MB
while read -r line; do
_ "$line" "MemTotal*" && set -- $line && break
eq "$line" "MemTotal*" && set -- $line && break
done < /proc/meminfo
mem="$(( $2 / 1000 ))MB"
@@ -77,7 +83,7 @@ if [ -e /proc/$$/comm ]; then
## Kernel
read -r _ _ version _ < /proc/version
kernel="${version%%-*}"
_ "$version" "*Microsoft*" && ID="fake $ID"
eq "$version" "*Microsoft*" && ID="fake $ID"
## Motherboard // laptop
read -r model < /sys/devices/virtual/dmi/id/product_name
@@ -87,7 +93,7 @@ if [ -e /proc/$$/comm ]; then
# then save the argument count to $pkgs
set --
[ -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/db/xbps ] && set -- /var/db/xbps/.*
[ -d /var/db/pkg ] && set -- /var/db/pkg/*/* # gentoo
pkgs=${###0}
@@ -190,9 +196,11 @@ elif v=/System/Library/CoreServices/SystemVersion.plist; [ -f "$v" ]; then
done < "$v"
fi
eq "$0" "*fetish" && printf 'Step on me daddy\n' && exit
## GTK
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"
# Shorten $cpu and $vendor
@@ -205,6 +213,7 @@ cpu="${cpu%% CPU}"
cpu="${cpu##CPU }"
cpu="${cpu##*AMD }"
cpu="${cpu%% with*}"
cpu="${cpu% *-Core*}"
col() {
printf ' '
@@ -227,7 +236,7 @@ for i in $info; do
n) echo;;
os) print os "$ID";;
sh) print sh "${SHELL##*/}";;
wm) print wm "$wm";;
wm) print wm "${wm##*/}";;
up) print up "$up";;
gtk) print gtk "${gtk# }";;
cpu) print cpu "$vendor$cpu";;