├── .gitignore ├── COPYING ├── Makefile ├── README.md ├── TODO ├── contrib ├── aura ├── bigger ├── cetch ├── cmfetch ├── mitchweaver ├── nice ├── simple └── simple-colored ├── etc └── manifest.txt ├── man ├── disk.1.scd ├── editor.1.scd ├── fetchutils.1.scd ├── mem.1.scd ├── os.1.scd ├── pkgs.1.scd ├── res.1.scd ├── temp.1.scd ├── template.1.scd ├── upt.1.scd └── wm.1.scd ├── scrots └── contrib-scrots.png ├── src ├── disk.sh ├── editor.sh ├── mem.sh ├── os.sh ├── pkgs.sh ├── res.sh ├── temp.sh ├── upt.sh └── wm.sh └── tests ├── lib.sh └── main.sh /.gitignore: -------------------------------------------------------------------------------- 1 | *.1 2 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | MIT License 2 | =========== 3 | 4 | - Copyright © 2020 Kiëd Llaentenn 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights to 9 | (mis)use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is furnished 11 | to do so, subject to the following conditions: 12 | 13 | - The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # fetchutils: some fetch utilities 3 | # 4 | # (c) Kiëd Llaentenn and contributors 5 | # See the COPYING file for copyright information. 6 | # 7 | 8 | DESTDIR = 9 | PREFIX = /usr/local/ 10 | 11 | CMD = @ 12 | SRC = disk.sh editor.sh \ 13 | mem.sh os.sh pkgs.sh res.sh \ 14 | temp.sh upt.sh wm.sh 15 | SCD = man/fetchutils.1.scd \ 16 | $(patsubst %.sh,man/%.1.scd,$(SRC)) 17 | MAN = $(SCD:.scd=) 18 | 19 | all: $(MAN) 20 | 21 | %.1: %.1.scd 22 | @printf " %-8s %s\n" "SCDOC" "$@" 23 | $(CMD)scdoc < $< > $(<:.scd=) 24 | clean: 25 | @printf " %-8s man/*.1\n" "CLEAN" 26 | $(CMD)rm -f man/*.1 27 | 28 | install: $(MAN) 29 | $(CMD)cat etc/manifest.txt | \ 30 | while read -r src dest mode; \ 31 | do \ 32 | printf " %-8s %s\n" "INSTALL" \ 33 | $(DESTDIR)$(PREFIX)$$dest; \ 34 | install -Dm$$mode $$src \ 35 | $(DESTDIR)$(PREFIX)$$dest; \ 36 | done 37 | 38 | uninstall: 39 | $(CMD)cat etc/manifest.txt | \ 40 | while read -r _ dest _; \ 41 | do \ 42 | printf " %-8s %s\n" "CLEAN" \ 43 | $(DESTDIR)$(PREFIX)$$dest; \ 44 | rm -f $(DESTDIR)$(PREFIX)$$dest; \ 45 | done 46 | 47 | chk: 48 | $(CMD)tests/main.sh 49 | 50 | .PHONY: all clean install uninstall chk 51 | 52 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # fetchutils 2 | 3 | This is a collection of small (< ~100 LOC) POSIX shell scripts to retrieve 4 | system information, such as uptime, memory, resolution, etc. They all 5 | output information in *plain text*, enabling them to be used for multiple 6 | purposes: 7 | 8 | - used to get info for a status bar (e.g. `lemonbar`) 9 | - used to create a super fast, highly customizable fetch script 10 | - used standalone (*what's my resolution again?*) 11 | 12 | ## goals 13 | 14 | - `fetchutils` scripts should be as readable as possible under the 15 | constraints of the glorious POSIX shell, 16 | - as highly customizable as possible, 17 | - and should support most major Linux distros, OpenBSD, and FreeBSD. 18 | 19 | ## non-goals 20 | 21 | - duplicating existing functionality, `uname`, `hostname`, `$SHELL`, etc. 22 | - replacing Neofetch, Screenfetch, ufetch, etc. 23 | - supporting every Linux distro under the sun. 24 | - supporting DragonflyBSD or NetBSD (not right now, anyway. sorry). 25 | - implementing a colorblocks script. 26 | - such a script would require so much flexibility it's just better 27 | that users write their own. 28 | 29 | ## status 30 | 31 | Alpha. Expect tools to be incomplete, buggy, and to have many missing 32 | features. Many tools haven't even been written yet. 33 | 34 | Many distros/os's aren't supported yet, and documentation is 35 | sub-optimal. 36 | 37 | (see the [TODO](TODO) file to see what's planned.) 38 | 39 | ## installation 40 | 41 | Ensure that: 42 | - GNU Make is installed. 43 | - BSD Make isn't supported. (This is planned.) 44 | - You are using a supported OS. 45 | - FreeBSD support is only partial. 46 | - OpenBSD support is planned. 47 | - Linux should work out of the box. 48 | - [`scdoc`](https://git.sr.ht/~sircmpwn/scdoc) is installed. 49 | - Optional, but required to generate manpages. 50 | 51 | Download: 52 | - either the latest source tarball from the GitHub releases, or 53 | - the git repository, on the main branch. 54 | 55 | NOTE: you **will need `dc` installed** if you choose the 56 | latter option. 57 | 58 | Execute: 59 | 60 | ``` 61 | $ make 62 | # make PREFIX= install 63 | ``` 64 | 65 | ## usage 66 | 67 | Each tool accepts a *format* string as its argument. Most tools already 68 | have a default format string: 69 | 70 | ``` 71 | $ mem 72 | 3005M / 8053M 73 | ``` 74 | 75 | In this case, `mem`'s default format string is 76 | `${mb_used}M / ${mb_total}M`, where each `${}` is a format specifier. 77 | 78 | Changing it gives the result: 79 | 80 | ``` 81 | $ mem '${gb_used}GB used out of ${gb_total}GB' 82 | 3GB used out of 8GB 83 | ``` 84 | 85 | Each tool has a man page (in `man/`) giving details such as the available 86 | specifiers and some nice examples. 87 | 88 | See the man page (`fetchutils(1)`) for more information on format strings. 89 | 90 | ## building a fetch script 91 | 92 | Because these tools output info in plain text, with no ASCII art or 93 | terminal styling, it's really easy to build your own fetch script using 94 | them. 95 | 96 | Here's a really simple one (from `contrib/simple`): 97 | ``` 98 | #!/bin/sh 99 | 100 | echo " 101 | ___ ${USER}@$(hostname) 102 | (.. | os: $(../src/os) 103 | (<> | shell: ${SHELL} 104 | / __ \ pkgs: $(../src/pkgs '$pkgs_total') 105 | ( / \ /| uptime: $(../src/upt) 106 | _/\ __)/_) memory: $(../src/mem) 107 | \/_____\/ kernel: $(uname -r) 108 | " 2>/dev/null 109 | ``` 110 | 111 | Which, on my system, gives the following output: 112 | 113 | ``` 114 | ___ kiedtl@foobar 115 | (.. | os: FreeBSD 116 | (<> | shell: mksh 117 | / __ \ pkgs: 270 (pkg) 118 | ( / \ /| uptime: 187d 22h 29m 119 | _/\ __)/_) memory: 2209M / 4053M 120 | \/_____\/ kernel: 12.1-RELEASE-p1 121 | ``` 122 | 123 | As you can see, it just wraps the output of the various `fetchutils` 124 | utilities, and displays it with some ASCII art. 125 | 126 | Take a look at the various script in `contrib/` if you want to see 127 | more examples of how fetchutils can be used to create a fetch script. 128 | 129 | ## why? 130 | 131 | "Normal" fetch scripts (such as ufetch or Neofetch) are good enough for 132 | most people. 133 | 134 | However, I've noticed a significant amount of people just end up writing 135 | their own fetch script, mostly because they wanted to try a new layout or 136 | look that other fetch tools don't support (e.g. the `contrib/nice` script). 137 | 138 | Instead of giving you a full-blown fetch tool, fetchutils offers you the 139 | tools needed to write your own. 140 | 141 | ## contributing 142 | 143 | As you may have noticed, I'm terrible at explaining anything, so if you 144 | understood anything at all and feel you can improve this README, feel 145 | free to submit a patch via the GitHub pull requests. 146 | 147 | Oh, and if you want to help improve the actual scripts, then that would be 148 | great too :^) 149 | 150 | ## license 151 | 152 | These lame little utilities are licensed under the MIT license. 153 | 154 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | # TODO 2 | 3 | - `-`: todo 4 | - `*`: in progress 5 | - `+`: done 6 | 7 | ## to write 8 | - (0.3.0) cpu (clock, make, etc) 9 | - (0.3.0) gpu (clock, make, etc) 10 | - (0.2.0) network (interface, up/down speed) 11 | - (0.2.0) host (machine type) 12 | - (0.2.0) terminal (xterm, urxvt, etc) 13 | - (0.2.0) shell ('/bin/bash' 'bash' 'Bourne Again Shell' 'v1.1.1) 14 | + (0.1.0) editor ('nvim' => 'NeoVim') 15 | + (0.1.0) disk 16 | + (0.1.0) tests to lint with shellcheck 17 | 18 | ## to fix 19 | - (0.3.0) res: support Wayland 20 | - (0.3.0) wm: support Wayland 21 | - (0.2.0) res: ${dpi} format 22 | - (0.2.0) precision specifiers for all utilities 23 | - (0.2.0) wm: support wm's that don't set _NET_WM_NAME 24 | - (0.2.0) temp: support °F, °K 25 | - (0.2.0) temp: support freebsd 26 | - (0.2.0) upt: addfmt specifiers for year, month, week 27 | + (0.1.0) temp: throw error if cpu temp file not found 28 | 29 | ## docs 30 | + (0.1.0) comments in scripts 31 | + (0.1.0) man page for each script, with examples 32 | + (0.1.0) readme.md 33 | + (0.1.0) Makefile 34 | + (0.1.0) write fetchutils(1) 35 | 36 | ## pkg manager support 37 | + (0.1.0) FreeBSD support 38 | + (0.1.0) Debian/Ubuntu support 39 | + (0.1.0) Arch support 40 | + (0.1.0) Void support 41 | + (0.1.0) KISS support 42 | - (0.2.0) Gentoo support 43 | - (0.2.0) CRUX support 44 | - (0.2.0) Slackware support 45 | - (0.2.0) Bedrock support 46 | + (0.2.0) Alpine support 47 | - (0.2.0) NixOS support 48 | - (0.3.0) Fedora/CentOS support 49 | - (0.3.0) Solus support 50 | - (0.3.0) OpenSUSE support 51 | - (0.3.0) Flatpak support 52 | - (0.3.0) OpenBSD support 53 | 54 | ## misc 55 | + (0.1.0) one final round of testing before release of v0.1.0 56 | + (0.1.0) adverti^H^H^H^H^H^H^Hshare on r/unixporn 57 | - (0.2.0) share on r/commandline and r/bash 58 | -------------------------------------------------------------------------------- /contrib/aura: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # aura - an imitation of aurafetch 4 | # (c) Kiëd Llaentenn 5 | # See the COPYING file for copyright. 6 | 7 | echo 8 | 9 | # TODO: use fetchutils to get kernel 10 | kernel=$(uname -r) 11 | kernel=${kernel%-*} 12 | 13 | blocks=$(printf '\033[0m\033[31m ▲\033[32m ▼\033[33m ▲\033[34m ▼\033[35m ▲\033[36m ▼\033[37m ▲\033[0m') 14 | 15 | reset=$(printf '\033[0m') 16 | color1=$(printf '\033[1;31m') 17 | 18 | format_info() { 19 | printf '%s%-10s %s%10s\n' "$color1" "$1:" \ 20 | "$reset" "$2" 21 | } 22 | 23 | format_info user "${USER}" 24 | format_info os "$(../src/os.sh '$id')" 25 | format_info kern "${kernel}" 26 | format_info ed "${EDITOR:-$VISUAL}" 27 | format_info sh "${SHELL##*/}" 28 | format_info pkgs "$(../src/pkgs.sh)" 29 | 30 | # TODO: use fetchutils for temrminal 31 | format_info term "${TERM%%-*}" 32 | 33 | echo 34 | echo " $blocks" 35 | 36 | echo 37 | -------------------------------------------------------------------------------- /contrib/bigger: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # bigger - bigger demo for fetchutils 4 | # (c) Kiëd Llaentenn 5 | # refer to COPYING for license details 6 | 7 | # --- colors --- 8 | image=$(printf "\033[0m") 9 | label=$(printf "\033[31m") 10 | reset=$(printf "\033[0m") 11 | 12 | # --- display --- 13 | 14 | ascii=" 15 | ${image}┌──────────────────────┐ 16 | ${image}│ │ 17 | ${image}│ ___ │ 18 | ${image}│ (.· | │ 19 | ${image}│ (<> | │ 20 | ${image}│ / __ \ │ 21 | ${image}│ ( / \ /| │ 22 | ${image}│ _/\ __)/_) │ 23 | ${image}│ \/_____\/ │ 24 | ${image}│ │ 25 | ${image}│ │ 26 | ${image}└──────────────────────┘ 27 | " 28 | 29 | echo "$ascii" 30 | 31 | print_info() { 32 | [ -z "$2" ] && return 33 | 34 | printf '%s%-8s%s%16s\n' "${label}" "$1" \ 35 | "${reset}" "$2" 36 | } 37 | 38 | print_info "USER" "${USER}" 39 | print_info "OS" "$(../src/os.sh)" 40 | print_info "UPTIME" "$(../src/upt.sh)" 41 | print_info "TEMP" "$(../src/temp.sh)" 42 | print_info "EDITOR" "neovim" 43 | print_info "SHELL" "${SHELL##*/}" 44 | print_info "PKGS" "$(../src/pkgs.sh)" 45 | print_info "KERNEL" "$(uname -r)" 46 | -------------------------------------------------------------------------------- /contrib/cetch: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # cetch - simple fetch script 4 | # (c) Kiëd Llaentenn 5 | # See the COPYING file for copyright. 6 | # 7 | # (partly) inspired by: 8 | # u/__trvv 9 | # https://github.com/trvv/cetch 10 | # 11 | # ascii art by: 12 | # u/__trvv 13 | # 14 | 15 | uptime=$(../src/upt.sh '${d} ${h}') 16 | pkgs=$(../src/pkgs.sh) 17 | os=$(../src/os.sh) 18 | colorblk1=$(printf '\033[0m\033[41m \033[42m \033[43m \033[44m \033[0m') 19 | colorblk2=$(printf '\033[0m\033[45m \033[46m \033[47m \033[48m \033[0m') 20 | 21 | reset=$(printf '\033[0m') 22 | color1=$(printf '\033[31m') 23 | 24 | format_info() { 25 | printf '%s%-8s %s%8s' "$color1" "$1" "$reset" "$2" 26 | } 27 | 28 | echo " 29 | ${color1} .---. 30 | ${color1} / \ ${USER}${reset}@${color1}$(hostname) 31 | ${color1} \\.@-@./ $(format_info uptime "$uptime") 32 | ${color1} /\`\\-/\`\\ $(format_info pkgs "$pkgs") 33 | ${color1} // - \\\\\ $(format_info os "$os") 34 | ${color1} | \\ )|_ $(format_info shell "${SHELL##*/}") 35 | ${color1}/\`\\-\`> <-/ \\ ${color1}colors $colorblk1 36 | ${color1}\\__/'---'\\__/ $colorblk1 37 | " 38 | -------------------------------------------------------------------------------- /contrib/cmfetch: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # cmfetch - cleaned up version of mfetch that uses 4 | # fetchutils to fetch information 5 | # (c) Kiëd Llaentenn 6 | # See the COPYING file for copyright information. 7 | # 8 | # Credits: 9 | # This is actually just a cleaned up version 10 | # of https://gitlab.com/rpolve/mfetch 11 | 12 | echo 13 | 14 | # TODO: uptime: write info in years, weeks too 15 | LINE[0]=$(../src/upt.sh) 16 | 17 | LINE[1]=$(../src/mem.sh '${gb_used}G / ${gb_total}G') 18 | 19 | LINE[2]=$(../src/disk.sh '${gb_used}G / ${gb_total}G' '/$') 20 | LINE[3]=$(../src/disk.sh '${gb_used}G / ${gb_total}G' '/home.?$') 21 | 22 | HOST="$(hostname)" 23 | HOSTLEN=${#HOST} 24 | 25 | if [ "$HOSTLEN" -gt 15 ] 26 | then 27 | HOST="$(printf "%.15s" "$HOST")" 28 | HOSTLEN=${#HOST} 29 | fi 30 | 31 | NAME=("Uptime" "Memory" "Root" "Home") 32 | 33 | while [ "$HOSTLEN" -gt 7 ]; do 34 | HOSTLEN=$(( HOSTLEN - 7 )) 35 | done 36 | 37 | F="\033[0;$(( HOSTLEN + 30 ))m" 38 | A=("\033[1;36m" "\033[0;37m") 39 | B=("\033[1;40;32m" "\033[0;40;37m") 40 | R="\033[0m" 41 | 42 | [ -n "$1" ] && case "$1" in 43 | "plain") 44 | F="$R";; 45 | "border") 46 | A=() B=();; 47 | "mono") 48 | A=() B=() F="$R";; 49 | "mono2") 50 | unset A B F R 51 | esac 52 | 53 | for ((i = 0; i < ${#LINE[@]}; i++)); do 54 | [ ${#LINE[$i]} -ge "${MAX:-0}" ] && \ 55 | MAX=${#LINE[$i]} 56 | done 57 | 58 | BASELEN=$(( 12 + MAX )) 59 | 60 | printf "${F}%s%${BASELEN}s%s${R}\n" " ╔" \ 61 | "[${HOST}]" "╗" | \ 62 | sed 's/ /═/g; s/═/ /' 63 | 64 | for ((i = 0; i < ${#LINE[@]}; i++)); do 65 | if [ -n "${LINE[$i]}" ]; then 66 | C=(${A[@]}) A=(${B[@]}) B=(${C[@]}) 67 | printf " ${F}%s${C[0]} %-6s" \ 68 | "║" "${NAME[$i]}" 69 | printf "${C[1]}%$(( BASELEN - 8 ))s ${F}%s${R}\n" \ 70 | "${LINE[$i]}" "║" 71 | fi 72 | done 73 | 74 | printf "${F}%s%${BASELEN}s%s${R}\n\n" " ╚" \ 75 | " " "╝" | sed 's/ /═/g; s/═/ /' 76 | 77 | command -v tmux >/dev/null && \ 78 | tmux ls 2>/dev/null | \ 79 | grep -cv "attached" | awk '{ 80 | if ($0 == 1) 81 | print "There is 1 detached tmux session." 82 | else if ($0 > 1) 83 | print "There are " $0 " detached tmux sessions." 84 | }' 85 | -------------------------------------------------------------------------------- /contrib/mitchweaver: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # http://github.com/mitchweaver 4 | # 5 | # mitchweaver's fetch script, ported to 6 | # fetchutils ;) 7 | # 8 | 9 | # TODO: use fetchutils to get model 10 | model() { 11 | if [ -f /sys/firmware/devicetree/base/model ] ; then 12 | read -r m < /sys/firmware/devicetree/base/model 13 | elif [ -f /sys/devices/virtual/dmi/id/product_name ] ; then 14 | read -r m 5 | # See the COPYING file for copyright information. 6 | 7 | echo 8 | 9 | # color escapes 10 | BLK="$(printf "\033[30m")" 11 | RED="$(printf "\033[31m")" 12 | GRN="$(printf "\033[32m")" 13 | YLW="$(printf "\033[33m")" 14 | BLU="$(printf "\033[34m")" 15 | PUR="$(printf "\033[35m")" 16 | CYN="$(printf "\033[36m")" 17 | WHT="$(printf "\033[37m")" 18 | RST="$(printf "\033[0m")" 19 | 20 | # build the color bars 21 | BAR="━━━━━" 22 | LEN=6 23 | OUTT="$RED$BAR$GRN$BAR$YLW$BAR$BLU$BAR$PUR$BAR$CYN$BAR$RST" 24 | 25 | format_info() { 26 | printf '%s%-8s %s%21s\n' "$BLU" "$1" \ 27 | "$RST" "$2" 28 | } 29 | 30 | # TODO: display full name of shell (e.g. zsh => Z Shell) 31 | 32 | echo "${OUTT}" 33 | format_info os "$(../src/os.sh '$pretty_name')" 34 | format_info editor "$(../src/editor.sh)" 35 | format_info packages "$(../src/pkgs.sh '$pkgs_tiny_total')" 36 | format_info shell "${SHELL##*/}" 37 | format_info uptime "$(../src/upt.sh)" 38 | echo "${OUTT}" 39 | 40 | echo 41 | -------------------------------------------------------------------------------- /contrib/simple: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # simple - simple fetch script built on fetchutils 4 | # (c) Kiëd Llaentenn 5 | # See the COPYING file for copyright information. 6 | 7 | echo " 8 | ___ ${USER}@$(hostname) 9 | (.. | os: $(../src/os.sh) 10 | (<> | shell: ${SHELL##*/} 11 | / __ \ pkgs: $(../src/pkgs.sh '$pkgs_total') 12 | ( / \ /| uptime: $(../src/upt.sh) 13 | _/\ __)/_) memory: $(../src/mem.sh) 14 | \/_____\/ kernel: $(uname -r) 15 | " 2>/dev/null 16 | -------------------------------------------------------------------------------- /contrib/simple-colored: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # simple-colored - simple, colored. 4 | # (c) Kiëd Llaentenn 5 | # See the COPYING file for copyright information. 6 | 7 | bold="$(printf '\033[1m')" 8 | reset="$(printf '\033[0m')" 9 | 10 | echo " 11 | ${bold} ___ ${USER}@$(hostname) 12 | ${bold} (.. | os ${reset}$(../src/os.sh) 13 | ${bold} (<> | shell ${reset}${SHELL##*/} 14 | ${bold} / __ \ pkgs ${reset}$(../src/pkgs.sh '$pkgs_total') 15 | ${bold} ( / \ /| uptime ${reset}$(../src/upt.sh) 16 | ${bold}_/\ __)/_) memory ${reset}$(../src/mem.sh) 17 | ${bold}\/_____\/ kernel ${reset}$(uname -r) 18 | " 2>/dev/null 19 | -------------------------------------------------------------------------------- /etc/manifest.txt: -------------------------------------------------------------------------------- 1 | src/disk.sh bin/disk 755 2 | src/editor.sh bin/editor 755 3 | src/mem.sh bin/mem 755 4 | src/os.sh bin/os 755 5 | src/pkgs.sh bin/pkgs 755 6 | src/res.sh bin/res 755 7 | src/temp.sh bin/temp 755 8 | src/upt.sh bin/upt 755 9 | src/wm.sh bin/wm 755 10 | man/fetchutils.1 share/man/man1/fetchutils.1 644 11 | man/disk.1 share/man/man1/disk.1 644 12 | man/editor.1 share/man/man1/editor.1 644 13 | man/mem.1 share/man/man1/mem.1 644 14 | man/os.1 share/man/man1/os.1 644 15 | man/pkgs.1 share/man/man1/pkgs.1 644 16 | man/res.1 share/man/man1/res.1 644 17 | man/temp.1 share/man/man1/temp.1 644 18 | man/upt.1 share/man/man1/upt.1 644 19 | man/wm.1 share/man/man1/wm.1 644 20 | -------------------------------------------------------------------------------- /man/disk.1.scd: -------------------------------------------------------------------------------- 1 | disk(1) 2 | 3 | # NAME 4 | 5 | disk - get disk usage information 6 | 7 | # SYNOPSIS 8 | 9 | *disk* [format] [pattern] 10 | 11 | # DESCRIPTION 12 | 13 | disk retrieves the disk usage information for all devices that match PATTERN 14 | and displays it in the format specified by FORMAT. 15 | 16 | ## FORMAT SPECIFIERS 17 | 18 | [[ *name* 19 | :< description 20 | | ${fs} 21 | : Filesystem name (e.g. '/dev/sda5') 22 | | ${mnt} 23 | : Filesystem mount point (e.g. '/home') 24 | | ${b_used} 25 | : used space in bytes. 26 | | ${b_free} 27 | : available space in bytes. 28 | | ${b_total} 29 | : total space in bytes. 30 | | ${kb_used} 31 | : used space in KiB. 32 | | ${kb_free} 33 | : available space in KiB. 34 | | ${kb_total} 35 | : total space in KiB. 36 | | ${mb_used} 37 | : used space in MiB. 38 | | ${mb_free} 39 | : available space in MiB. 40 | | ${mb_total} 41 | : total space in MiB. 42 | | ${gb_used} 43 | : used space in GiB. 44 | | ${gb_free} 45 | : available space in GiB. 46 | | ${gb_total} 47 | : total space in GiB. 48 | 49 | # EXAMPLES 50 | 51 | Executing disk with no format, like so: 52 | 53 | disk 54 | 55 | runs disk with the default format, '${gb_used}G / ${gb_total}G'.++ 56 | sample result: '89G / 981G' 57 | 58 | A custom format can be used, e.g.: 59 | 60 | ``` 61 | disk '${fs} \(${mnt}\): ${gb_used}GiB / ${gb_total}GiB \\ 62 | \($(((gb_used*100)/gb_total))%\)' '/$' 63 | ``` 64 | 65 | sample result: '/dev/sda2 (/): 150GiB / 983GiB (15%)' 66 | 67 | Note how the pattern must be specified if a custom format is used. 68 | 69 | Also note that parenthesis must be escaped in the format string; this 70 | is mainly due to the format string being an actual sh expression that 71 | is evaluated to expand it. See fetchutils(1) for more info. 72 | 73 | # REPORTING BUGS 74 | 75 | Please report any bugs to _https://github.com/lptstr/fetchutils/issues_ or 76 | to _kiedtl@tilde.team_. 77 | 78 | # SEE ALSO 79 | 80 | *fetchutils*(1) 81 | 82 | The full documentation for *disk* is not maintained as a Texinfo manual. 83 | If the *info* and *disk* programs are properly installed on your system, 84 | the command 85 | 86 | *info disk* 87 | 88 | should not give you access to the complete manual. 89 | 90 | # LICENSE 91 | 92 | Copyright © 2020 Kiëd Llaentenn and contributors 93 | 94 | This utility is licensed under the MIT license. 95 | -------------------------------------------------------------------------------- /man/editor.1.scd: -------------------------------------------------------------------------------- 1 | EDITOR(1) 2 | 3 | # NAME 4 | 5 | editor - get editor 6 | 7 | # SYNOPSIS 8 | 9 | *editor* [format] 10 | 11 | # DESCRIPTION 12 | 13 | editor retrieves the default editor set in $EDITOR or $VISUAL and tries 14 | to get it's name and version. For example, given that $EDITOR is set to 15 | 'emacs', the output would be 'GNU Emacs 25.2.2' 16 | 17 | ## FORMAT SPECIFIERS 18 | 19 | [[ *name* 20 | :< description 21 | | ${name} 22 | : the unmodified value of $EDITOR or $VISUAL, e.g. "emacs" 23 | | ${full_name} 24 | : the full name of the editor, e.g. "gnu emacs" 25 | | ${pretty_name} 26 | : like the full_name, but with capitalization. e.g. "GNU Emacs" 27 | | ${version} 28 | : the version of the editor. 29 | 30 | # EXAMPLES 31 | 32 | Executing editor with no format, like so: 33 | 34 | editor 35 | 36 | runs editor with the default format, '$pretty_name'.++ 37 | sample result: 'GNU Emacs' 38 | 39 | A custom format can be used, e.g.: 40 | 41 | editor '$name v$version' 42 | 43 | sample result: 'emacs v25.2.2' 44 | 45 | 46 | # REPORTING BUGS 47 | 48 | Please report any bugs to _https://github.com/lptstr/fetchutils/issues_ or 49 | to _kiedtl@tilde.team_. 50 | 51 | # SEE ALSO 52 | 53 | *fetchutils*(1) 54 | 55 | The full documentation for *editor* is not maintained as a Texinfo manual. 56 | If the *info* and *editor* programs are properly installed on your system, 57 | the command 58 | 59 | *info editor* 60 | 61 | should not give you access to the complete manual. 62 | 63 | # LICENSE 64 | 65 | Copyright © 2020 Kiëd Llaentenn and contributors 66 | 67 | This utility is licensed under the MIT license. 68 | -------------------------------------------------------------------------------- /man/fetchutils.1.scd: -------------------------------------------------------------------------------- 1 | FETCHUTILS(1) 2 | 3 | # NAME 4 | 5 | fetchutils - a collection of small utilities to get system info 6 | 7 | # SYNOPSIS 8 | 9 | ** [args] 10 | 11 | # DESCRIPTION 12 | 13 | fetchutils is a collection of small shell scrip to quickly get system 14 | information. 15 | 16 | (Almost) every tool accepts a format specifier as an argument, an 17 | occasionally a few other arguments. The format specifier is simply a 18 | shell expression, e.g. "${format1} ${format2}". In the previous example, 19 | '${format1}' and '${format2}' are both format specifiers, similar to 20 | /bin/printf's format specifiers (like %s and %d). 21 | 22 | Example: assume a tool foo.sh, which has the available formats 'value1' 23 | and 'value2', where the format specifiers '$fmt1' maps to 'value1' and 24 | '$fmt2' maps to 'value2'. If the tool is given the format 25 | 26 | ``` 27 | "1st value: $fmt1, 2nd value: $fmt2" 28 | ``` 29 | 30 | The final result will be 31 | 32 | ``` 33 | "1st value: value1, 2nd value: value2" 34 | ``` 35 | 36 | As you can see, both '$fmt1' and '$fmt2' were expanded to their respective 37 | values, regardless of the text next to it. 38 | 39 | Because each format string is simply a shell expression, it's also possible 40 | to use shell command in the format string: 41 | 42 | ``` 43 | "1st value: $fmt1, modified 2nd value: ${fmt%2}" 44 | ``` 45 | 46 | The above example yields the result: 47 | 48 | ``` 49 | "1st value: value1, modified 2nd value: value" 50 | ``` 51 | 52 | Where the '2' in 'value2' is removed because of the shell expression 53 | '${fmt%2}', which removed the last character from the string. 54 | 55 | This simple feature allows fetchutils to output information in *any* format, 56 | unlike traditional fetch tools. This enables fetchutils to be used in 57 | a variety of areas, such as lemonbar scripts, in addition to custom fetch 58 | scripts. 59 | 60 | # APPLETS 61 | 62 | [[ *name* 63 | :< description 64 | | disk 65 | : Get disk usage info. 66 | | editor 67 | : Get editor and find it's pretty name. 68 | | mem 69 | : Get memory usage info. 70 | | os 71 | : Get the Linux distro name (on Linux) or the OS (on other systems). 72 | | pkgs 73 | : Get installed package count. 74 | | res 75 | : Get screen resolution. 76 | | temp 77 | : Get CPU temperature. 78 | | upt 79 | : Get system uptime. 80 | | wm 81 | : Get window manager name. 82 | 83 | See the *SEE ALSO* section below for links to each applet's manpage. 84 | 85 | # EXAMPLES 86 | 87 | See each tool's manpage for examples. 88 | 89 | # REPORTING BUGS 90 | 91 | Please report any bugs to _https://github.com/lptstr/fetchutils/issues_ or 92 | to _kiedtl@tilde.team_. 93 | 94 | Any attempts at improving this lousy manpage would be greatly appreciated. 95 | 96 | # SEE ALSO 97 | 98 | *disk*(1), *editor*(1), *mem*(1), *os*(1), *pkgs*(1), *res*(1), *temp*(1), 99 | *upt*(1), *wm*(1) 100 | 101 | The full documentation for *fetchutils* is not maintained as a Texinfo 102 | manual. 103 | If the *info* and *fetchutils* programs are properly installed on your 104 | system, the command 105 | 106 | *info fetchutils* 107 | 108 | should not give you access to the complete manual. 109 | 110 | # LICENSE 111 | 112 | Copyright © 2020 Kiëd Llaentenn and contributors 113 | 114 | This utility is licensed under the MIT license. 115 | -------------------------------------------------------------------------------- /man/mem.1.scd: -------------------------------------------------------------------------------- 1 | MEM(1) 2 | 3 | # NAME 4 | 5 | mem - get memory usage 6 | 7 | # SYNOPSIS 8 | 9 | *mem* [format] 10 | 11 | # DESCRIPTION 12 | 13 | mem retrieves the amount of memory used, the amount of free memory, and the total amount of memory in bytes, KiB, MiB, and GiB. 14 | 15 | ## FORMAT SPECIFIERS 16 | 17 | [[ *name* 18 | :< description 19 | | ${b_used} 20 | : bytes of used memory 21 | | ${b_free} 22 | : bytes of free memory 23 | | ${b_total} 24 | : bytes of total memory 25 | | ${kb_used} 26 | : KiB of used memory 27 | | ${kb_free} 28 | : KiB of free memory 29 | | ${kb_total} 30 | : KiB of total memory 31 | | ${mb_used} 32 | : MiB of used memory 33 | | ${mb_free} 34 | : MiB of free memory 35 | | ${mb_total} 36 | : MiB of total memory 37 | | ${gb_used} 38 | : GiB of used memory 39 | | ${gb_free} 40 | : GiB of free memory 41 | | ${gb_total} 42 | : GiB of total memory 43 | 44 | # EXAMPLES 45 | 46 | Executing mem with no arguments, like so: 47 | 48 | mem 49 | 50 | runs mem with the default format, '${mb_used}M / ${mb_total}M'.++ 51 | sample result: 2726M / 4053M 52 | 53 | A custom format may be used, e.g.: 54 | 55 | mem '${gb_used}G used out of ${gb_total}' 56 | 57 | This will run mem with the format 'G used out of G'.++ 58 | sample result: 3G used out of 4G 59 | 60 | A more complex (and extremely messy) example: 61 | 62 | ``` 63 | mem '${b_used} ${b_total}' | \ 64 | awk '{ 65 | p=($1*10)/$2 66 | printf "[%0*s%*s]\n", p, "", 10 - p, "" 67 | }' | \ 68 | sed 's/0/#/g' 69 | ``` 70 | 71 | Here, the raw output of mem in bytes is piped to awk and used to create a 72 | bar showing the memory consumption.++ 73 | sample result: [####### ] 74 | 75 | # REPORTING BUGS 76 | 77 | Please report any bugs to _https://github.com/lptstr/fetchutils/issues_ or 78 | to _kiedtl@tilde.team_. 79 | 80 | # SEE ALSO 81 | 82 | *fetchutils*(1) 83 | 84 | The full documentation for *mem* is not maintained as a Texinfo manual. 85 | If the *info* and *mem* programs are properly installed on your system, 86 | the command 87 | 88 | *info mem* 89 | 90 | should not give you access to the complete manual. 91 | 92 | # LICENSE 93 | 94 | Copyright © 2020 Kiëd Llaentenn 95 | 96 | This utility is licensed under the MIT license. 97 | -------------------------------------------------------------------------------- /man/os.1.scd: -------------------------------------------------------------------------------- 1 | OS(1) 2 | 3 | # NAME 4 | 5 | os - get operating system or Linux distro name 6 | 7 | # SYNOPSIS 8 | 9 | *os* [format] 10 | 11 | # DESCRIPTION 12 | 13 | os retrieves the name and id of the current distro (in the case of Linux), 14 | or the operating system name in the case of another system (such as BSD). 15 | 16 | ## FORMAT SPECIFIERS 17 | 18 | [[ *name* 19 | :< description 20 | | ${name} 21 | : NAME from /etc/os-release on Linux, or lowercase output of `uname -s` on other os's. 22 | | ${id} 23 | : ID from /etc/os-release on Linux, or output of `uname -s` on other os's. 24 | | ${pretty_name} 25 | : PRETTY_NAME from /etc/os-release on Linux, or output of `uname -s` on other os's. 26 | 27 | # EXAMPLES 28 | 29 | Executing os with no format, like so: 30 | 31 | os 32 | 33 | runs os with the default format, '${name}'.++ 34 | sample result on Linux: 'Ubuntu'++ 35 | sample result on FreeBSD: 'FreeBSD' 36 | 37 | A custom format can be used, e.g.: 38 | 39 | os '${name},${id},${pretty_name}' 40 | 41 | sample result on Linux: 'Ubuntu,debian,Ubuntu 18.04.4 LTS'++ 42 | sample result on FreeBSD: 'FreeBSD,freebsd,FreeBSD' 43 | 44 | # REPORTING BUGS 45 | 46 | Please report any bugs to _https://github.com/lptstr/fetchutils/issues_ or 47 | to _kiedtl@tilde.team_. 48 | 49 | # SEE ALSO 50 | 51 | *fetchutils*(1) 52 | 53 | The full documentation for *os* is not maintained as a Texinfo manual. 54 | If the *info* and *os* programs are properly installed on your system, 55 | the command 56 | 57 | *info os* 58 | 59 | should not give you access to the complete manual. 60 | 61 | # LICENSE 62 | 63 | Copyright © 2020 Kiëd Llaentenn and contributors 64 | 65 | This utility is licensed under the MIT license. 66 | -------------------------------------------------------------------------------- /man/pkgs.1.scd: -------------------------------------------------------------------------------- 1 | PKGS(1) 2 | 3 | # NAME 4 | 5 | pkgs - count installed packages 6 | 7 | # SYNOPSIS 8 | 9 | *pkgs* [format] 10 | 11 | # DESCRIPTION 12 | 13 | pkgs counts all packages installed with installed package managers. 14 | 15 | ## FORMAT SPECIFIERS 16 | 17 | [[ *name* 18 | :< description 19 | | ${total} 20 | : Total amount of installed packages. 21 | | ${pkgs_total} 22 | : Like ${total}, but lists package managers. (See EXAMPLES) 23 | | ${pkgs_tiny_total} 24 | : Like ${pkgs_total}, but lists package managers in the tiny format. (See EXAMPLES) 25 | 26 | # EXAMPLES 27 | 28 | Executing pkgs with no format, like so: 29 | 30 | pkgs 31 | 32 | runs pkgs with the default format, '${total}'.++ 33 | sample result: '1024' 34 | 35 | Here's a comparison of '${total}', '${pkgs_total}', and '${pkgs_tiny_total}'.++ 36 | The following commands executed on the author's system: 37 | 38 | pkgs '${total}'++ 39 | pkgs '${pkgs_total}'++ 40 | pkgs '${pkgs_tiny_total}' 41 | 42 | yields the output: 43 | 44 | 2941++ 45 | 2936 (apt) 5 (snap)++ 46 | 2941 (apt, snap) 47 | 48 | As you can see, both '${pkgs_total}' and '${pkgs_tiny_total}' list 49 | package managers, but '${pkgs_tiny_total}' does so in a more concise way. 50 | 51 | # REPORTING BUGS 52 | 53 | Please report any bugs to _https://github.com/lptstr/fetchutils/issues_ or 54 | to _kiedtl@tilde.team_. 55 | 56 | # SEE ALSO 57 | 58 | *fetchutils*(1) 59 | 60 | The full documentation for *pkgs* is not maintained as a Texinfo manual. 61 | If the *info* and *pkgs* programs are properly installed on your system, 62 | the command 63 | 64 | *info pkgs* 65 | 66 | should not give you access to the complete manual. 67 | 68 | # LICENSE 69 | 70 | Copyright © 2020 Kiëd Llaentenn and contributors 71 | 72 | This utility is licensed under the MIT license. 73 | -------------------------------------------------------------------------------- /man/res.1.scd: -------------------------------------------------------------------------------- 1 | RES(1) 2 | 3 | # NAME 4 | 5 | res - get screen resolution 6 | 7 | # SYNOPSIS 8 | 9 | *res* [format] 10 | 11 | # DESCRIPTION 12 | 13 | res retrieves the screen resolution in an X11 session. 14 | 15 | ## FORMAT SPECIFIERS 16 | 17 | [[ *name* 18 | :< description 19 | | ${height} 20 | : height of screen in pixels. 21 | | ${width} 22 | : width of screen in pixels. 23 | 24 | # EXAMPLES 25 | 26 | Executing res with no format, like so: 27 | 28 | res 29 | 30 | runs res with the default format, '${height}x${width}'.++ 31 | sample result: '1920x1080' 32 | 33 | A custom format can be used, e.g.: 34 | 35 | res '${height}px high, ${width}px wide' 36 | 37 | sample result: '1920px high, 1080px wide' 38 | 39 | # KNOWN ISSUES 40 | 41 | - res does not work on Wayland. 42 | 43 | # REPORTING BUGS 44 | 45 | Please report any bugs to _https://github.com/lptstr/fetchutils/issues_ or 46 | to _kiedtl@tilde.team_. 47 | 48 | # SEE ALSO 49 | 50 | *fetchutils*(1) 51 | 52 | The full documentation for *res* is not maintained as a Texinfo manual. 53 | If the *info* and *res* programs are properly installed on your system, 54 | the command 55 | 56 | *info res* 57 | 58 | should not give you access to the complete manual. 59 | 60 | # LICENSE 61 | 62 | Copyright © 2020 Kiëd Llaentenn and contributors 63 | 64 | This utility is licensed under the MIT license. 65 | -------------------------------------------------------------------------------- /man/temp.1.scd: -------------------------------------------------------------------------------- 1 | TEMP(1) 2 | 3 | # NAME 4 | 5 | temp - get CPU temperature 6 | 7 | # SYNOPSIS 8 | 9 | *temp* [format] 10 | 11 | # DESCRIPTION 12 | 13 | temp retrieves the CPU temperature. 14 | 15 | ## FORMAT SPECIFIERS 16 | 17 | [[ *name* 18 | :< description 19 | | ${c} 20 | : Temperature in degrees Celsius 21 | 22 | 23 | # EXAMPLES 24 | 25 | Executing temp with no format, like so: 26 | 27 | temp 28 | 29 | runs temp with the default format, '${c}°C'.++ 30 | sample result: '48°C' 31 | 32 | A custom format can be used, e.g.: 33 | 34 | temp '${c} degrees Celsius' 35 | 36 | sample result: '49 degrees Celsius' 37 | 38 | # KNOWN ISSUES 39 | 40 | - temp does not have a format specifier for the temperature in Fahrenheit. 41 | - temp does not have a format specifier for the temperature in Kelvin. 42 | 43 | # REPORTING BUGS 44 | 45 | Please report any bugs to _https://github.com/lptstr/fetchutils/issues_ or 46 | to _kiedtl@tilde.team_. 47 | 48 | # SEE ALSO 49 | 50 | *fetchutils*(1) 51 | 52 | The full documentation for *temp* is not maintained as a Texinfo manual. 53 | If the *info* and *temp* programs are properly installed on your system, 54 | the command 55 | 56 | *info temp* 57 | 58 | should not give you access to the complete manual. 59 | 60 | # LICENSE 61 | 62 | Copyright © 2020 Kiëd Llaentenn and contributors 63 | 64 | This utility is licensed under the MIT license. 65 | -------------------------------------------------------------------------------- /man/template.1.scd: -------------------------------------------------------------------------------- 1 | COMMAND(1) 2 | 3 | # NAME 4 | 5 | COMMAND - SHORT DESCRIPTION 6 | 7 | # SYNOPSIS 8 | 9 | *COMMAND* [format] 10 | 11 | # DESCRIPTION 12 | 13 | LONG DESCRIPTION 14 | 15 | ## FORMAT SPECIFIERS 16 | 17 | [[ *name* 18 | :< description 19 | | FOO 20 | : BAR 21 | 22 | # EXAMPLES 23 | 24 | Executing COMMAND with no format, like so: 25 | 26 | COMMAND 27 | 28 | runs COMMAND with the default format, 'FORMAT'.++ 29 | sample result: 'XXX' 30 | 31 | A custom format can be used, e.g.: 32 | 33 | COMMAND 'FORMAT' 34 | 35 | sample result: 'XXX' 36 | 37 | 38 | # REPORTING BUGS 39 | 40 | Please report any bugs to _https://github.com/lptstr/fetchutils/issues_ or 41 | to _kiedtl@tilde.team_. 42 | 43 | # SEE ALSO 44 | 45 | The full documentation for *COMMAND* is not maintained as a Texinfo manual. 46 | If the *info* and *COMMAND* programs are properly installed on your system, 47 | the command 48 | 49 | *info COMMAND* 50 | 51 | should not give you access to the complete manual. 52 | 53 | # LICENSE 54 | 55 | Copyright © 2020 Kiëd Llaentenn and contributors 56 | 57 | This utility is licensed under the MIT license. 58 | -------------------------------------------------------------------------------- /man/upt.1.scd: -------------------------------------------------------------------------------- 1 | UPT(1) 2 | 3 | # NAME 4 | 5 | upt - get uptime 6 | 7 | # SYNOPSIS 8 | 9 | *upt* [format] 10 | 11 | # DESCRIPTION 12 | 13 | upt retrieves the system uptime and formats it according to the provided 14 | format string. 15 | 16 | ## FORMAT SPECIFIERS 17 | 18 | [[ *name* 19 | :< description 20 | | ${d} 21 | : days of uptime. 22 | | ${h} 23 | : hours of uptime (does not include days). 24 | | ${m} 25 | : minutes of uptime (does not include hours). 26 | | ${s} 27 | : total amount of seconds elapsed since boot. 28 | 29 | ## ENVIRONMENT VARIABLES 30 | 31 | In addition to the usual format specifiers, upt uses environment variables 32 | to specify the suffixes used for the day, hours, minutes, etc values. 33 | 34 | [[ *environment variable* 35 | :< description 36 | | $UPT_DAY_SUFFIX 37 | : days suffix. default: 'd' 38 | | $UPT_HOUR_SUFFIX 39 | : hours suffix. default: 'h' 40 | | $UPT_MIN_SUFFIX 41 | : minutes suffix. default: 'm' 42 | | $UPT_SEC_SUFFIX 43 | : seconds suffix. default: 's' 44 | 45 | # EXAMPLES 46 | 47 | Executing upt with no format, like so: 48 | 49 | upt 50 | 51 | runs upt with the default format, '${d} ${h} ${m}'.++ 52 | sample result: '187d 21h 8m' 53 | 54 | Custom format and suffixes can be used, e.g.: 55 | 56 | UPT_DAY_SUFFIX=' days' \\++ 57 | UPT_HOUR_SUFFIX=' hours' \\++ 58 | UPT_MIN_SUFFIX=' minutes' \\++ 59 | upt '${d}, ${h}, and ${m}' 60 | 61 | sample result: '114 days, 22 hours, and 25 minutes' 62 | 63 | 64 | # REPORTING BUGS 65 | 66 | Please report any bugs to _https://github.com/lptstr/fetchutils/issues_ or 67 | to _kiedtl@tilde.team_. 68 | 69 | # SEE ALSO 70 | 71 | *fetchutils*(1) 72 | 73 | The full documentation for *upt* is not maintained as a Texinfo manual. 74 | If the *info* and *upt* programs are properly installed on your system, 75 | the command 76 | 77 | *info upt* 78 | 79 | should not give you access to the complete manual. 80 | 81 | # LICENSE 82 | 83 | Copyright © 2020 Kiëd Llaentenn and contributors 84 | 85 | This utility is licensed under the MIT license. 86 | -------------------------------------------------------------------------------- /man/wm.1.scd: -------------------------------------------------------------------------------- 1 | WM(1) 2 | 3 | # NAME 4 | 5 | wm - get the current window manager 6 | 7 | # SYNOPSIS 8 | 9 | *wm* 10 | 11 | # DESCRIPTION 12 | 13 | wm retrieves the name of the currently running X11 window manager. 14 | 15 | As there is only one thing to display, wm does not (currently) accept a 16 | format specifier. 17 | 18 | # EXAMPLES 19 | 20 | Executing wm with no format, like so: 21 | 22 | wm 23 | 24 | yields the output (on the author's system): '2bwm' 25 | 26 | # REPORTING BUGS 27 | 28 | Please report any bugs to _https://github.com/lptstr/fetchutils/issues_ or 29 | to _kiedtl@tilde.team_. 30 | 31 | # SEE ALSO 32 | 33 | *fetchutils*(1) 34 | 35 | The full documentation for *wm* is not maintained as a Texinfo manual. 36 | If the *info* and *wm* programs are properly installed on your system, 37 | the command 38 | 39 | *info wm* 40 | 41 | should not give you access to the complete manual. 42 | 43 | # LICENSE 44 | 45 | Copyright © 2020 Kiëd Llaentenn and contributors 46 | 47 | This utility is licensed under the MIT license. 48 | -------------------------------------------------------------------------------- /scrots/contrib-scrots.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kiedtl/fetchutils/882781a297e86f4ad4eaf143e0777fb3e7c69526/scrots/contrib-scrots.png -------------------------------------------------------------------------------- /src/disk.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # disk [fmt] [drive] - get disk usage 4 | # (c) Kiëd Llaentenn 5 | # See the COPYING file for copyright information. 6 | 7 | # TODO: 8 | # - precision control (use dc instead of builtin) 9 | # - differenciate between GiB and GB, etc 10 | 11 | : ${FU_SCALE=0} 12 | [ -z "$1" ] && set -- '${gb_used}G / ${gb_total}G' '/$' 13 | 14 | df | sed '1d' | grep "$2" | \ 15 | while read -r fs kb_total kb_used kb_free _ mnt 16 | do 17 | b_free=$(dc -e "${FU_SCALE}k $kb_free 1024 * p") 18 | b_used=$(dc -e "${FU_SCALE}k $kb_used 1024 * p") 19 | b_total=$(dc -e "${FU_SCALE}k $kb_total 1024 * p") 20 | 21 | mb_free=$(dc -e "${FU_SCALE}k $kb_free 1024 / p") 22 | mb_used=$(dc -e "${FU_SCALE}k $kb_used 1024 / p") 23 | mb_total=$(dc -e "${FU_SCALE}k $kb_total 1024 / p") 24 | 25 | gb_free=$(dc -e "${FU_SCALE}k $mb_free 1024 / p") 26 | gb_used=$(dc -e "${FU_SCALE}k $mb_used 1024 / p") 27 | gb_total=$(dc -e "${FU_SCALE}k $mb_total 1024 / p") 28 | 29 | eval echo "$1" 30 | done 31 | -------------------------------------------------------------------------------- /src/editor.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # editor - get editor name 4 | # (c) Kiëd Llaentenn 5 | # See the COPYING file for copyright information. 6 | 7 | [ -z "$1" ] && set -- '$pretty_name' 8 | 9 | name='' full_name='' pretty_name='' version='' 10 | 11 | name="${EDITOR:-${VISUAL:-vi}}" 12 | case "$name" in 13 | *code*) 14 | full_name='vs code' 15 | pretty_name='VS Code' 16 | version='?' # HELP WANTED! 17 | ;; 18 | 19 | *emacs*) 20 | full_name='gnu emacs' 21 | pretty_name='GNU Emacs' 22 | version="$(emacs --version | \ 23 | head -n1 | awk '{ print $NF }')" 24 | ;; 25 | 26 | *nvim*) 27 | full_name='neovim' 28 | pretty_name='Neovim' 29 | version="$(nvim --version | \ 30 | head -n1 | awk '{ print $NF }')" 31 | ;; 32 | 33 | *vim*) 34 | full_name='vim' 35 | pretty_name='Vim' 36 | version="$(vim --version | head -n1)" 37 | version="${version##*proved }" 38 | version="${version%%\ \(*}" 39 | ;; 40 | 41 | *nano*) 42 | full_name='nano' 43 | pretty_name='Nano' 44 | version="$(nano --version | \ 45 | head -n1 | awk '{ print $NF }')" 46 | ;; 47 | 48 | *) 49 | full_name=$name pretty_name=$name 50 | version="?" 51 | esac 52 | 53 | eval echo "$1" 54 | -------------------------------------------------------------------------------- /src/mem.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # mem - get memory usage information 4 | # (c) Kiëd Llaentenn 5 | # See the COPYING file for copyright information. 6 | 7 | # TODO: 8 | # - cleanup! 9 | # - percentage_used variables 10 | # - precision control (use dc instead of builtin) 11 | # - differenciate between GiB and GB, etc 12 | 13 | [ -z "$1" ] && set -- '${mb_used}M / ${mb_total}M' 14 | 15 | get_mem_linux() { 16 | while IFS=: read -r set data; do 17 | data="${data%%kB}" 18 | 19 | case "$set" in 20 | MemTotal) 21 | kb_used=$((kb_used+=data)) 22 | kb_total=$((kb_total=data)) 23 | ;; 24 | 25 | Shmem) 26 | kb_used=$((kb_used+=data)) 27 | ;; 28 | 29 | MemFree|Buffers|Cached|SReclaimable) 30 | kb_used=$((kb_used-=data)) 31 | ;; 32 | esac 33 | done < /proc/meminfo 34 | 35 | b_used=$((kb_used*1024)) 36 | b_total=$((kb_total*1024)) 37 | mb_used=$((kb_used/1024)) 38 | mb_total=$((kb_total/1024)) 39 | gb_used=$((mb_used/1024)) 40 | gb_total=$((mb_total/1024)) 41 | 42 | b_free=$((b_total-b_used)) 43 | kb_free=$((kb_total-kb_used)) 44 | mb_free=$((mb_total-mb_used)) 45 | gb_free=$((gb_total-gb_used)) 46 | } 47 | 48 | get_mem_freebsd() { 49 | b_total=$(sysctl -n hw.physmem) 50 | 51 | # thanks, neofetch! :P 52 | pagesize="$(sysctl -n hw.pagesize)" 53 | inactive="$(($(sysctl -n vm.stats.vm.v_inactive_count) * pagesize))" 54 | unused="$(($(sysctl -n vm.stats.vm.v_free_count) * pagesize))" 55 | cache="$(($(sysctl -n vm.stats.vm.v_cache_count) * pagesize))" 56 | 57 | b_free="$((inactive + unused + cache))" 58 | b_used=$((b_total - b_free)) 59 | kb_used=$((b_used/1024)) 60 | kb_total=$((b_total/1024)) 61 | mb_used=$((kb_used/1024)) 62 | mb_total=$((kb_total/1024)) 63 | gb_used=$((mb_used/1024)) 64 | gb_total=$((mb_total/1024)) 65 | 66 | kb_free=$((b_free/1024)) 67 | mb_free=$((kb_free/1024)) 68 | gb_free=$((mb_free/1024)) 69 | } 70 | 71 | case "$(uname -s)" in 72 | Linux*) get_mem_linux ;; 73 | FreeBSD*) get_mem_freebsd ;; 74 | 75 | *) 76 | echo "unsupported os: $(uname -s)"; 77 | exit 1 78 | ;; 79 | esac 80 | 81 | eval echo "$1" 82 | -------------------------------------------------------------------------------- /src/os.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # os - get operating system 4 | # (c) Kiëd Llaentenn 5 | # See the COPYING file for copyright information. 6 | 7 | [ -z "$1" ] && set -- '$name' 8 | 9 | get_os_linux() { 10 | while IFS='=' read -r key val 11 | do 12 | val=${val%\"} 13 | val=${val#\"} 14 | 15 | case "$key" in 16 | ID*) id="$val" ;; 17 | PRETTY_NAME*) pretty_name="$val" ;; 18 | NAME*) name="$val" ;; 19 | esac 20 | done < /etc/os-release 21 | } 22 | 23 | get_os_other() { 24 | # cache output of uname 25 | uname=$(uname -s) 26 | 27 | id=$(echo "$uname" | tr '[:upper:]' '[:lower:]') 28 | pretty_name=$uname 29 | name=$uname 30 | } 31 | 32 | case $(uname -s) in 33 | Linux*) get_os_linux ;; 34 | *) get_os_other ;; 35 | esac 36 | 37 | eval echo "$1" 38 | -------------------------------------------------------------------------------- /src/pkgs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # pkgs - get number of pkgs 4 | # (c) Kiëd Llaentenn 5 | # See the COPYING file for copyright information. 6 | 7 | # total amount of packages 8 | total= 9 | 10 | # total with package manager 11 | # e.g. "456 (xbps) 12 (snap) 1 (flatpack)" 12 | pkgs_total= 13 | 14 | # total with package manager, tiny version 15 | # e.g. "469 (xbps, snap, flatpack)" 16 | pkgs_tiny_total= 17 | 18 | # a list of package managers used. 19 | # used to construct $pkgs_total at the end 20 | pkg_managers= 21 | 22 | fmt="${1:-\$total}" 23 | 24 | getpkgs() { 25 | total="$((total+$2))" 26 | pkgs_total="$pkgs_total $2 ($1)" 27 | pkg_managers="$pkg_managers $1" 28 | } 29 | 30 | command -v apk 2>/dev/null >&2 && \ 31 | getpkgs apk "$(apk list -I | wc -l)" 32 | 33 | command -v dpkg 2>/dev/null >&2 && \ 34 | getpkgs apt "$(dpkg --get-selections | \ 35 | grep -cv deinstall)" 36 | 37 | command -v kiss 2>/dev/null >&2 && \ 38 | getpkgs kiss "$(kiss list | wc -l)" 39 | 40 | command -v snap 2>/dev/null >&2 && \ 41 | getpkgs snap "$(snap list | wc -l)" 42 | 43 | command -v pacman 2>/dev/null >&2 && \ 44 | getpkgs pacman "$(pacman -Qq | wc -l)" 45 | 46 | command -v pkg 2>/dev/null >&2 && \ 47 | getpkgs pkg \ 48 | "$(pkg stats | awk '/Installed packages:/ { print $3 }')" 49 | 50 | command -v xbps-query 2>/dev/null >&2 && \ 51 | getpkgs xbps "$(xbps-query -l | wc -l)" 52 | 53 | # generate $pkgs_tiny_total 54 | pkgs_tiny_total="$total (" 55 | 56 | # shellcheck disable=2086 57 | set -- $pkg_managers 58 | 59 | while [ $# -gt 0 ]; do 60 | pkgs_tiny_total="${pkgs_tiny_total}$1, " 61 | shift 62 | done 63 | 64 | pkgs_tiny_total="${pkgs_tiny_total%,\ }" 65 | pkgs_tiny_total="${pkgs_tiny_total})" 66 | 67 | eval echo "$fmt" 68 | -------------------------------------------------------------------------------- /src/res.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # original version sto^H^H^Hborrowed from 4 | # http://github.com/mitchweaver/bin 5 | # 6 | # res: get screen dimensions 7 | # 8 | 9 | [ -z "$1" ] && set -- '${height}x$width' 10 | [ -z "$DISPLAY" ] && { 11 | echo "could not find display" >&2 12 | exit 1 13 | } 14 | 15 | res=$(xrandr --nograb --current | awk '/\*/ {print $1}' | tail -n 1) 16 | res=${res% *} 17 | 18 | width=${res%x*} 19 | width=${width%.*} 20 | 21 | height=${res#*x} 22 | height=${height%.*} 23 | 24 | eval echo "$1" 25 | -------------------------------------------------------------------------------- /src/temp.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # http://github.com/mitchweaver/bin 4 | # 5 | # get CPU temperature 6 | # 7 | 8 | [ -z "$1" ] && set -- '${c}°C' 9 | 10 | c= 11 | 12 | case $(uname -s) in 13 | OpenBSD*) 14 | c=$(sysctl -n hw.sensors.cpu0.temp0) 15 | c="${c%.*}" 16 | ;; 17 | Linux*) 18 | path=/sys/class/thermal/thermal_zone0/temp 19 | if [ -f $path ] 20 | then 21 | read -r c < $path 22 | else 23 | echo "could not get temperature" >&2 24 | exit 1 25 | fi 26 | 27 | c="${c%???}" 28 | ;; 29 | *) 30 | echo "unsupported os: $(uname -s)" >&2 31 | exit 1 32 | ;; 33 | esac 34 | 35 | eval echo "$1" 36 | -------------------------------------------------------------------------------- /src/upt.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # upt - get uptime on hosts 4 | # (c) Kiëd Llaentenn 5 | # See the COPYING file for copyright information. 6 | 7 | [ -z "$1" ] && set -- '${d} ${h} ${m}' 8 | 9 | case $(uname -s) in 10 | Linux*) 11 | secs=$(cat /proc/uptime) 12 | secs=${secs%%.*} 13 | ;; 14 | 15 | *BSD*) 16 | boottime=$(sysctl -n kern.boottime | \ 17 | sed 's/{ sec = //g; s/,.*//g') 18 | now=$(date +%s) 19 | 20 | secs=$((now - boottime)) 21 | ;; 22 | 23 | *) 24 | echo "unsupported os: $(uname -s)" >&2 25 | exit 1 26 | ;; 27 | esac 28 | 29 | days=$((secs/86400)) 30 | hours=$((secs/3600%24)) 31 | mins=$((secs/60%60)) 32 | 33 | [ $days = 0 ] || d="${days}${UPT_DAY_SUFFIX:-d}" 34 | [ $hours = 0 ] || h="${hours}${UPT_HOUR_SUFFIX:-h}" 35 | [ $mins = 0 ] || m="${mins}${UPT_MIN_SUFFIX:-m}" 36 | [ $secs = 0 ] || s="${secs}${UPT_SEC_SUFFIX:-s}" 37 | 38 | eval echo "$1" 39 | -------------------------------------------------------------------------------- /src/wm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # wm - get window manager 4 | # (c) Kiëd Llaentenn 5 | # See the COPYING file for copyright information. 6 | 7 | [ -z "$DISPLAY" ] && { 8 | echo "could not find display" >&2 9 | exit 1 10 | } 11 | 12 | wm="$(xprop -root -notype _NET_WM_NAME)" 13 | wm="${wm##*= \"}" 14 | wm="${wm%%\"*}" 15 | 16 | printf '%s\n' "$wm" 17 | -------------------------------------------------------------------------------- /tests/lib.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # (c) Kiëd Llaentenn 4 | # See the COPYING file for copyright information. 5 | 6 | PASSED=0 7 | FAILED=0 8 | 9 | header() { 10 | printf '\n== %s\n' "$1" 11 | } 12 | 13 | # usage: test_command 14 | test_command() { 15 | # shellcheck disable=2086 16 | if eval $1 >/dev/null 17 | then 18 | printf '✔ | %s\n' "$2" 19 | PASSED=$((PASSED+1)) 20 | else 21 | printf '✖ | %s\n' "$2" 22 | FAILED=$((FAILED+1)) 23 | fi 24 | } 25 | 26 | # utility function to run shellcheck 27 | # and test for trailing whitespace 28 | test_shchk() { 29 | test_command "shellcheck $SHCHK_FLAGS $1" \ 30 | "passed shellcheck: '$1'" 31 | test_command "[ \$(grep '\s$' $1 | wc -l) -eq 0 ]" \ 32 | "no trailing whitespace: '$1'" 33 | } 34 | 35 | end() { 36 | printf '\n' 37 | printf '== completed %s tests. %s passed, %s failed.\n' \ 38 | "$((PASSED+FAILED))" "$PASSED" "$FAILED" 39 | } 40 | -------------------------------------------------------------------------------- /tests/main.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # (c) Kiëd Llaentenn 4 | # See the COPYING file for copyright information. 5 | 6 | SHCHK_FLAGS="-x -e2016 -e2034" 7 | 8 | . tests/lib.sh 9 | 10 | header "testing for needed programs" 11 | test_command "command -v scdoc 2>/dev/null >&2" \ 12 | "scdoc installed" 13 | test_command "command -v shellcheck 2>/dev/null >&2" \ 14 | "shellcheck installed" 15 | 16 | header "linting source files" 17 | for file in src/* 18 | do 19 | test_shchk "$file" 20 | done 21 | 22 | header "linting example scripts" 23 | for file in contrib/* 24 | do 25 | test_shchk "$file" 26 | done 27 | 28 | header "linting tests files" 29 | test_shchk "tests/main.sh" 30 | test_shchk "tests/lib.sh" 31 | 32 | header "checking manpages compile with scdoc" 33 | for file in man/*.1.scd 34 | do 35 | test_command "cat $file | scdoc" \ 36 | "passed scdoc: '$file'" 37 | done 38 | 39 | end 40 | --------------------------------------------------------------------------------