commit 459179b
chld
·
2026-09-15 01:25:37 +0000 UTC
parent 29dff4e
update
A
bin/aws
+12,
-0
1@@ -0,0 +1,12 @@
2+#!/bin/sh
3+set -x
4+a=awww
5+
6+killall $a-daemon 2>/dev/null || :;
7+$a-daemon &
8+sleep 1
9+while :
10+do
11+ $a img `setwall`
12+ sleep 120
13+done
M
bin/fehs
+1,
-1
1@@ -1,2 +1,2 @@
2 #!/bin/sh -eu
3-curl $1 -o -| mpv -
4+curl $1 -o -| swayimg -
+0,
-23
1@@ -1,23 +0,0 @@
2-#!/bin/sh
3-
4-ffmpeg -i "$1" -filter_complex "
5-color=c=#282828:s=1x1:d=1[p0];
6-color=c=#3c3836:s=1x1:d=1[p1];
7-color=c=#504945:s=1x1:d=1[p2];
8-color=c=#665c54:s=1x1:d=1[p3];
9-color=c=#fbf1c7:s=1x1:d=1[p4];
10-color=c=#ebdbb2:s=1x1:d=1[p5];
11-color=c=#d5c4a1:s=1x1:d=1[p6];
12-color=c=#bdae93:s=1x1:d=1[p7];
13-color=c=#cc241d:s=1x1:d=1[p8];
14-color=c=#98971a:s=1x1:d=1[p9];
15-color=c=#d79921:s=1x1:d=1[p10];
16-color=c=#458588:s=1x1:d=1[p11];
17-color=c=#b16286:s=1x1:d=1[p12];
18-color=c=#689d6a:s=1x1:d=1[p13];
19-color=c=#d65d0e:s=1x1:d=1[p14];
20-color=c=#928374:s=1x1:d=1[p15];
21-[p0][p1][p2][p3][p4][p5][p6][p7][p8][p9][p10][p11][p12][p13][p14][p15]
22-hstack=inputs=16[palette];
23-[0:v][palette]paletteuse=dither=sierra2_4a
24-" $2
+10,
-8
1@@ -1,18 +1,19 @@
2 #!/bin/sh -e
3 set -x
4
5-#python3 - <<'PY'
6-echo '
7-colors = [
8-colors.ok
9-]
10+python3 - "$HOME/t/gruvbox.ppm" <<'PY'
11+import sys
12+import subprocess
13
14-with open("home.ok/t/gruvbox.ppm", "wb") as f:
15+colors = eval(
16+ "[" + subprocess.check_output(["termgruv"], text=True) + "]"
17+)
18+
19+with open(sys.argv[1], "wb") as f:
20 f.write(b"P6\n16 16\n255\n")
21 for color in colors:
22 f.write(bytes(color) * 16)
23-' | sed "s/colors.ok/`termgruv`/" | sed "s#home.ok#$HOME#"| python3 -
24-
25+PY
26
27 ffmpeg -y -i "$1" \
28 "$1.new.png"
29@@ -23,3 +24,4 @@ ffmpeg -y \
30 -i "$HOME/t/gruvbox.ppm" \
31 -filter_complex "[0:v][1:v]paletteuse=dither=sierra2_4a" \
32 "$2" && rm "$1.new.png"
33+
+0,
-1
1@@ -1 +0,0 @@
2-librewolf $@
+3,
-5
1@@ -1,10 +1,8 @@
2 #!/bin/sh -eu
3-
4-out="${out:-$HOME/s}"
5-
6-[ -z $1 ] && exit 1
7+set -x
8+out="${out:-$HOME/shot}"
9 mkdir -p $out
10
11 grim \
12 -g "$(slurp)" \
13- "${out}/$1.png"
14+ "${out}/`$HOME/bin/scrot shot`.png"
M
bin/hrgb
+1,
-1
1@@ -1,4 +1,4 @@
2-#!/bin/guile
3+#!/usr/bin/env guile
4 !#
5 (use-modules (ice-9 format))
6
+1,
-1
1@@ -1,4 +1,4 @@
2-#!/bin/guile
3+#!/usr/bin/env guile
4 !#
5 (let a (
6 (n 0)
+1305,
-0
1@@ -0,0 +1,1305 @@
2+#!/bin/sh
3+#
4+# pfetch - Simple POSIX sh fetch script.
5+
6+# Wrapper around all escape sequences used by pfetch to allow for
7+# greater control over which sequences are used (if any at all).
8+esc() {
9+ case $1 in
10+ CUU) e="${esc_c}[${2}A" ;; # cursor up
11+ CUD) e="${esc_c}[${2}B" ;; # cursor down
12+ CUF) e="${esc_c}[${2}C" ;; # cursor right
13+ CUB) e="${esc_c}[${2}D" ;; # cursor left
14+
15+ # text formatting
16+ SGR)
17+ case ${PF_COLOR:=1} in
18+ (1)
19+ e="${esc_c}[${2}m"
20+ ;;
21+
22+ (0)
23+ # colors disabled
24+ e=
25+ ;;
26+ esac
27+ ;;
28+
29+ # line wrap
30+ DECAWM)
31+ case $TERM in
32+ (dumb | minix | cons25)
33+ # not supported
34+ e=
35+ ;;
36+
37+ (*)
38+ e="${esc_c}[?7${2}"
39+ ;;
40+ esac
41+ ;;
42+ esac
43+}
44+
45+# Print a sequence to the terminal.
46+esc_p() {
47+ esc "$@"
48+ printf '%s' "$e"
49+}
50+
51+# This is just a simple wrapper around 'command -v' to avoid
52+# spamming '>/dev/null' throughout this function. This also guards
53+# against aliases and functions.
54+has() {
55+ _cmd=$(command -v "$1") 2>/dev/null || return 1
56+ [ -x "$_cmd" ] || return 1
57+}
58+
59+log() {
60+ # The 'log()' function handles the printing of information.
61+ # In 'pfetch' (and 'neofetch'!) the printing of the ascii art and info
62+ # happen independently of each other.
63+ #
64+ # The size of the ascii art is stored and the ascii is printed first.
65+ # Once the ascii is printed, the cursor is located right below the art
66+ # (See marker $[1]).
67+ #
68+ # Using the stored ascii size, the cursor is then moved to marker $[2].
69+ # This is simply a cursor up escape sequence using the "height" of the
70+ # ascii art.
71+ #
72+ # 'log()' then moves the cursor to the right the "width" of the ascii art
73+ # with an additional amount of padding to add a gap between the art and
74+ # the information (See marker $[3]).
75+ #
76+ # When 'log()' has executed, the cursor is then located at marker $[4].
77+ # When 'log()' is run a second time, the next line of information is
78+ # printed, moving the cursor to marker $[5].
79+ #
80+ # Markers $[4] and $[5] repeat all the way down through the ascii art
81+ # until there is no more information left to print.
82+ #
83+ # Every time 'log()' is called the script keeps track of how many lines
84+ # were printed. When printing is complete the cursor is then manually
85+ # placed below the information and the art according to the "heights"
86+ # of both.
87+ #
88+ # The math is simple: move cursor down $((ascii_height - info_height)).
89+ # If the aim is to move the cursor from marker $[5] to marker $[6],
90+ # plus the ascii height is 8 while the info height is 2 it'd be a move
91+ # of 6 lines downwards.
92+ #
93+ # However, if the information printed is "taller" (takes up more lines)
94+ # than the ascii art, the cursor isn't moved at all!
95+ #
96+ # Once the cursor is at marker $[6], the script exits. This is the gist
97+ # of how this "dynamic" printing and layout works.
98+ #
99+ # This method allows ascii art to be stored without markers for info
100+ # and it allows for easy swapping of info order and amount.
101+ #
102+ # $[2] ___ $[3] goldie@KISS
103+ # $[4](.ยท | $[5] os KISS Linux
104+ # (<> |
105+ # / __ \
106+ # ( / \ /|
107+ # _/\ __)/_)
108+ # \/-____\/
109+ # $[1]
110+ #
111+ # $[6] /home/goldie $
112+
113+ # End here if no data was found.
114+ [ "$2" ] || return
115+
116+ # Store the values of '$1' and '$3' as we reset the argument list below.
117+ name=$1
118+ use_seperator=$3
119+
120+ # Use 'set --' as a means of stripping all leading and trailing
121+ # white-space from the info string. This also normalizes all
122+ # white-space inside of the string.
123+ #
124+ # Disable the shellcheck warning for word-splitting
125+ # as it's safe and intended ('set -f' disables globbing).
126+ # shellcheck disable=2046,2086
127+ {
128+ set -f
129+ set +f -- $2
130+ info=$*
131+ }
132+
133+ # Move the cursor to the right, the width of the ascii art with an
134+ # additional gap for text spacing.
135+ esc_p CUF "$ascii_width"
136+
137+ # Print the info name and color the text.
138+ esc_p SGR "3${PF_COL1-4}";
139+ esc_p SGR 1
140+ printf '%s' "$name"
141+ esc_p SGR 0
142+
143+ # Print the info name and info data separator, if applicable.
144+ [ "$use_seperator" ] || printf %s "$PF_SEP"
145+
146+ # Move the cursor backward the length of the *current* info name and
147+ # then move it forwards the length of the *longest* info name. This
148+ # aligns each info data line.
149+ esc_p CUB "${#name}"
150+ esc_p CUF "${PF_ALIGN:-$info_length}"
151+
152+ # Print the info data, color it and strip all leading whitespace
153+ # from the string.
154+ esc_p SGR "3${PF_COL2-9}"
155+ printf '%s' "$info"
156+ esc_p SGR 0
157+ printf '\n'
158+
159+ # Keep track of the number of times 'log()' has been run.
160+ info_height=$((${info_height:-0} + 1))
161+}
162+
163+get_title() {
164+ # Username is retrieved by first checking '$USER' with a fallback
165+ # to the 'id -un' command.
166+ user=${USER:-$(id -un)}
167+
168+ # Hostname is retrieved by first checking '$HOSTNAME' with a fallback
169+ # to the 'hostname' command.
170+ #
171+ # Disable the warning about '$HOSTNAME' being undefined in POSIX sh as
172+ # the intention for using it is allowing the user to overwrite the
173+ # value on invocation.
174+ # shellcheck disable=3028,2039
175+ hostname=${HOSTNAME:-${hostname:-$(hostname)}}
176+
177+ # If the hostname is still not found, fallback to the contents of the
178+ # /etc/hostname file.
179+ [ "$hostname" ] || read -r hostname < /etc/hostname
180+
181+ # Add escape sequences for coloring to user and host name. As we embed
182+ # them directly in the arguments passed to log(), we cannot use esc_p().
183+ esc SGR 1
184+ user=$e$user
185+ esc SGR "3${PF_COL3:-1}"
186+ user=$e$user
187+ esc SGR 1
188+ user=$user$e
189+ esc SGR 1
190+ hostname=$e$hostname
191+ esc SGR "3${PF_COL3:-1}"
192+ hostname=$e$hostname
193+
194+ log "${user}@${hostname}" " " " " >&6
195+}
196+
197+get_os() {
198+ # This function is called twice, once to detect the distribution name
199+ # for the purposes of picking an ascii art early and secondly to display
200+ # the distribution name in the info output (if enabled).
201+ #
202+ # On first run, this function displays _nothing_, only on the second
203+ # invocation is 'log()' called.
204+ [ "$distro" ] && {
205+ log os "$distro" >&6
206+ return
207+ }
208+
209+ case $os in
210+ (Linux*)
211+ # Some Linux distributions (which are based on others)
212+ # fail to identify as they **do not** change the upstream
213+ # distribution's identification packages or files.
214+ #
215+ # It is senseless to add a special case in the code for
216+ # each and every distribution (which _is_ technically no
217+ # different from what it is based on) as they're either too
218+ # lazy to modify upstream's identification files or they
219+ # don't have the know-how (or means) to ship their own
220+ # lsb-release package.
221+ #
222+ # This causes users to think there's a bug in system detection
223+ # tools like neofetch or pfetch when they technically *do*
224+ # function correctly.
225+ #
226+ # Exceptions are made for distributions which are independent,
227+ # not based on another distribution or follow different
228+ # standards.
229+ #
230+ # This applies only to distributions which follow the standard
231+ # by shipping unmodified identification files and packages
232+ # from their respective upstreams.
233+ if has lsb_release; then
234+ distro=$(lsb_release -sd)
235+
236+ # Android detection works by checking for the existence of
237+ # the follow two directories. I don't think there's a simpler
238+ # method than this.
239+ elif [ -d /system/app ] && [ -d /system/priv-app ]; then
240+ distro="Android $(getprop ro.build.version.release)"
241+
242+ elif [ -f /etc/os-release ]; then
243+ # This used to be a simple '. /etc/os-release' but I believe
244+ # this is insecure as we blindly executed whatever was in the
245+ # file. This parser instead simply handles 'key=val', treating
246+ # the file contents as plain-text.
247+ while IFS='=' read -r key val; do
248+ case $key in
249+ (PRETTY_NAME)
250+ distro=$val
251+ ;;
252+ esac
253+ done < /etc/os-release
254+
255+ else
256+ # Special cases for (independent) distributions which
257+ # don't follow any os-release/lsb standards whatsoever.
258+ has crux && distro=$(crux)
259+ has guix && distro='Guix System'
260+ fi
261+
262+ # 'os-release' and 'lsb_release' sometimes add quotes
263+ # around the distribution name, strip them.
264+ distro=${distro##[\"\']}
265+ distro=${distro%%[\"\']}
266+
267+ # Check to see if we're running Bedrock Linux which is
268+ # very unique. This simply checks to see if the user's
269+ # PATH contains a Bedrock specific value.
270+ case $PATH in
271+ (*/bedrock/cross/*)
272+ distro='Bedrock Linux'
273+ ;;
274+ esac
275+
276+ # Check to see if Linux is running in Windows 10 under
277+ # WSL1 (Windows subsystem for Linux [version 1]) and
278+ # append a string accordingly.
279+ #
280+ # If the kernel version string ends in "-Microsoft",
281+ # we're very likely running under Windows 10 in WSL1.
282+ if [ "$WSLENV" ]; then
283+ distro="${distro}${WSLENV+ on Windows 10 [WSL2]}"
284+
285+ # Check to see if Linux is running in Windows 10 under
286+ # WSL2 (Windows subsystem for Linux [version 2]) and
287+ # append a string accordingly.
288+ #
289+ # This checks to see if '$WSLENV' is defined. This
290+ # appends the Windows 10 string even if '$WSLENV' is
291+ # empty. We only need to check that is has been _exported_.
292+ elif [ -z "${kernel%%*-Microsoft}" ]; then
293+ distro="$distro on Windows 10 [WSL1]"
294+ fi
295+ ;;
296+
297+ (Darwin*)
298+ # Parse the SystemVersion.plist file to grab the macOS
299+ # version. The file is in the following format:
300+ #
301+ # <key>ProductVersion</key>
302+ # <string>10.14.6</string>
303+ #
304+ # 'IFS' is set to '<>' to enable splitting between the
305+ # keys and a second 'read' is used to operate on the
306+ # next line directly after a match.
307+ #
308+ # '_' is used to nullify a field. '_ _ line _' basically
309+ # says "populate $line with the third field's contents".
310+ while IFS='<>' read -r _ _ line _; do
311+ case $line in
312+ # Match 'ProductVersion' and read the next line
313+ # directly as it contains the key's value.
314+ ProductVersion)
315+ IFS='<>' read -r _ _ mac_version _
316+ continue
317+ ;;
318+
319+ ProductName)
320+ IFS='<>' read -r _ _ mac_product _
321+ continue
322+ ;;
323+ esac
324+ done < /System/Library/CoreServices/SystemVersion.plist
325+
326+ # Use the ProductVersion to determine which macOS/OS X codename
327+ # the system has. As far as I'm aware there's no "dynamic" way
328+ # of grabbing this information.
329+ case $mac_version in
330+ (10.4*) distro='Mac OS X Tiger' ;;
331+ (10.5*) distro='Mac OS X Leopard' ;;
332+ (10.6*) distro='Mac OS X Snow Leopard' ;;
333+ (10.7*) distro='Mac OS X Lion' ;;
334+ (10.8*) distro='OS X Mountain Lion' ;;
335+ (10.9*) distro='OS X Mavericks' ;;
336+ (10.10*) distro='OS X Yosemite' ;;
337+ (10.11*) distro='OS X El Capitan' ;;
338+ (10.12*) distro='macOS Sierra' ;;
339+ (10.13*) distro='macOS High Sierra' ;;
340+ (10.14*) distro='macOS Mojave' ;;
341+ (10.15*) distro='macOS Catalina' ;;
342+ (11*) distro='macOS Big Sur' ;;
343+ (12*) distro='macOS Monterey' ;;
344+ (*) distro='macOS' ;;
345+ esac
346+
347+ # Use the ProductName to determine if we're running in iOS.
348+ case $mac_product in
349+ (iP*) distro='iOS' ;;
350+ esac
351+
352+ distro="$distro $mac_version"
353+ ;;
354+
355+ (Haiku)
356+ # Haiku uses 'uname -v' for version information
357+ # instead of 'uname -r' which only prints '1'.
358+ distro=$(uname -sv)
359+ ;;
360+
361+ (Minix|DragonFly)
362+ distro="$os $kernel"
363+
364+ # Minix and DragonFly don't support the escape
365+ # sequences used, clear the exit trap.
366+ trap '' EXIT
367+ ;;
368+
369+ (SunOS)
370+ # Grab the first line of the '/etc/release' file
371+ # discarding everything after '('.
372+ IFS='(' read -r distro _ < /etc/release
373+ ;;
374+
375+ (OpenBSD*)
376+ # Show the OpenBSD version type (current if present).
377+ # kern.version=OpenBSD 6.6-current (GENERIC.MP) ...
378+ IFS=' =' read -r _ distro openbsd_ver _ <<-EOF
379+ $(sysctl kern.version)
380+ EOF
381+
382+ distro="$distro $openbsd_ver"
383+ ;;
384+
385+ (FreeBSD)
386+ distro="$os $(freebsd-version)"
387+ ;;
388+
389+ (*)
390+ # Catch all to ensure '$distro' is never blank.
391+ # This also handles the BSDs.
392+ distro="$os $kernel"
393+ ;;
394+ esac
395+}
396+
397+get_kernel() {
398+ case $os in
399+ # Don't print kernel output on some systems as the
400+ # OS name includes it.
401+ (*BSD*|Haiku|Minix)
402+ return
403+ ;;
404+ esac
405+
406+ # '$kernel' is the cached output of 'uname -r'.
407+ log kernel "$kernel" >&6
408+}
409+
410+get_host() {
411+ case $os in
412+ (Linux*)
413+ # Despite what these files are called, version doesn't
414+ # always contain the version nor does name always contain
415+ # the name.
416+ read -r name < /sys/devices/virtual/dmi/id/product_name
417+ read -r version < /sys/devices/virtual/dmi/id/product_version
418+ read -r model < /sys/firmware/devicetree/base/model
419+
420+ host="$name $version $model"
421+ ;;
422+
423+ (Darwin* | FreeBSD* | DragonFly*)
424+ host=$(sysctl -n hw.model)
425+ ;;
426+
427+ (NetBSD*)
428+ host=$(sysctl -n machdep.dmi.system-vendor \
429+ machdep.dmi.system-product)
430+ ;;
431+
432+ (OpenBSD*)
433+ host=$(sysctl -n hw.version)
434+ ;;
435+
436+ (*BSD* | Minix)
437+ host=$(sysctl -n hw.vendor hw.product)
438+ ;;
439+ esac
440+
441+ # Turn the host string into an argument list so we can iterate
442+ # over it and remove OEM strings and other information which
443+ # shouldn't be displayed.
444+ #
445+ # Disable the shellcheck warning for word-splitting
446+ # as it's safe and intended ('set -f' disables globbing).
447+ # shellcheck disable=2046,2086
448+ {
449+ set -f
450+ set +f -- $host
451+ host=
452+ }
453+
454+ # Iterate over the host string word by word as a means of stripping
455+ # unwanted and OEM information from the string as a whole.
456+ #
457+ # This could have been implemented using a long 'sed' command with
458+ # a list of word replacements, however I want to show that something
459+ # like this is possible in pure sh.
460+ #
461+ # This string reconstruction is needed as some OEMs either leave the
462+ # identification information as "To be filled by OEM", "Default",
463+ # "undefined" etc and we shouldn't print this to the screen.
464+ for word do
465+ # This works by reconstructing the string by excluding words
466+ # found in the "blacklist" below. Only non-matches are appended
467+ # to the final host string.
468+ case $word in
469+ (To | [Bb]e | [Ff]illed | [Bb]y | O.E.M. | OEM |\
470+ Not | Applicable | Specified | System | Product | Name |\
471+ Version | Undefined | Default | string | INVALID | ๏ฟฝ | os |\
472+ Type1ProductConfigId )
473+ continue
474+ ;;
475+ esac
476+
477+ host="$host$word "
478+ done
479+
480+ # '$arch' is the cached output from 'uname -m'.
481+ log host "${host:-$arch}" >&6
482+}
483+
484+get_uptime() {
485+ # Uptime works by retrieving the data in total seconds and then
486+ # converting that data into days, hours and minutes using simple
487+ # math.
488+ case $os in
489+ (Linux* | Minix* | SerenityOS*)
490+ IFS=. read -r s _ < /proc/uptime
491+ ;;
492+
493+ (Darwin* | *BSD* | DragonFly*)
494+ s=$(sysctl -n kern.boottime)
495+
496+ # Extract the uptime in seconds from the following output:
497+ # [...] { sec = 1271934886, usec = 667779 } Thu Apr 22 12:14:46 2010
498+ s=${s#*=}
499+ s=${s%,*}
500+
501+ # The uptime format from 'sysctl' needs to be subtracted from
502+ # the current time in seconds.
503+ s=$(($(date +%s) - s))
504+ ;;
505+
506+ (Haiku)
507+ # The boot time is returned in microseconds, convert it to
508+ # regular seconds.
509+ s=$(($(system_time) / 1000000))
510+ ;;
511+
512+ (SunOS)
513+ # Split the output of 'kstat' on '.' and any white-space
514+ # which exists in the command output.
515+ #
516+ # The output is as follows:
517+ # unix:0:system_misc:snaptime 14809.906993005
518+ #
519+ # The parser extracts: ^^^^^
520+ IFS=' .' read -r _ s _ <<-EOF
521+ $(kstat -p unix:0:system_misc:snaptime)
522+ EOF
523+ ;;
524+
525+ (IRIX)
526+ # Grab the uptime in a pretty format. Usually,
527+ # 00:00:00 from the 'ps' command.
528+ t=$(LC_ALL=POSIX ps -o etime= -p 1)
529+
530+ # Split the pretty output into days or hours
531+ # based on the uptime.
532+ case $t in
533+ (*-*) d=${t%%-*} t=${t#*-} ;;
534+ (*:*:*) h=${t%%:*} t=${t#*:} ;;
535+ esac
536+
537+ h=${h#0} t=${t#0}
538+
539+ # Convert the split pretty fields back into
540+ # seconds so we may re-convert them to our format.
541+ s=$((${d:-0}*86400 + ${h:-0}*3600 + ${t%%:*}*60 + ${t#*:}))
542+ ;;
543+ esac
544+
545+ # Convert the uptime from seconds into days, hours and minutes.
546+ d=$((s / 60 / 60 / 24))
547+ h=$((s / 60 / 60 % 24))
548+ m=$((s / 60 % 60))
549+
550+ # Only append days, hours and minutes if they're non-zero.
551+ case "$d" in ([!0]*) uptime="${uptime}${d}d "; esac
552+ case "$h" in ([!0]*) uptime="${uptime}${h}h "; esac
553+ case "$m" in ([!0]*) uptime="${uptime}${m}m "; esac
554+
555+ log uptime "${uptime:-0m}" >&6
556+}
557+
558+get_pkgs() {
559+ # This works by first checking for which package managers are
560+ # installed and finally by printing each package manager's
561+ # package list with each package one per line.
562+ #
563+ # The output from this is then piped to 'wc -l' to count each
564+ # line, giving us the total package count of whatever package
565+ # managers are installed.
566+ packages=$(
567+ case $os in
568+ (Linux*)
569+ # Commands which print packages one per line.
570+ has bonsai && bonsai list
571+ has crux && pkginfo -i
572+ has pacman-key && pacman -Qq
573+ has dpkg && dpkg-query -f '.\n' -W
574+ has rpm && rpm -qa
575+ has xbps-query && xbps-query -l
576+ has apk && apk info
577+ has guix && guix package --list-installed
578+ has opkg && opkg list-installed
579+
580+ # Directories containing packages.
581+ has kiss && printf '%s\n' /var/db/kiss/installed/*/
582+ has cpt-list && printf '%s\n' /var/db/cpt/installed/*/
583+ has brew && printf '%s\n' "$(brew --cellar)/"*
584+ has emerge && printf '%s\n' /var/db/pkg/*/*/
585+ has pkgtool && printf '%s\n' /var/log/packages/*
586+ has eopkg && printf '%s\n' /var/lib/eopkg/package/*
587+
588+ # 'nix' requires two commands.
589+ has nix-store && {
590+ nix-store -q --requisites /run/current-system/sw
591+ nix-store -q --requisites ~/.nix-profile
592+ }
593+ ;;
594+
595+ (Darwin*)
596+ # Commands which print packages one per line.
597+ has pkgin && pkgin list
598+ has dpkg && dpkg-query -f '.\n' -W
599+
600+ # Directories containing packages.
601+ has brew && printf '%s\n' /usr/local/Cellar/*
602+
603+ # 'port' prints a single line of output to 'stdout'
604+ # when no packages are installed and exits with
605+ # success causing a false-positive of 1 package
606+ # installed.
607+ #
608+ # 'port' should really exit with a non-zero code
609+ # in this case to allow scripts to cleanly handle
610+ # this behavior.
611+ has port && {
612+ pkg_list=$(port installed)
613+
614+ case "$pkg_list" in
615+ ("No ports are installed.")
616+ # do nothing
617+ ;;
618+
619+ (*)
620+ printf '%s\n' "$pkg_list"
621+ ;;
622+ esac
623+ }
624+ ;;
625+
626+ (FreeBSD*|DragonFly*)
627+ pkg info
628+ ;;
629+
630+ (OpenBSD*)
631+ printf '%s\n' /var/db/pkg/*/
632+ ;;
633+
634+ (NetBSD*)
635+ pkg_info
636+ ;;
637+
638+ (Haiku)
639+ printf '%s\n' /boot/system/package-links/*
640+ ;;
641+
642+ (Minix)
643+ printf '%s\n' /usr/pkg/var/db/pkg/*/
644+ ;;
645+
646+ (SunOS)
647+ has pkginfo && pkginfo -i
648+ has pkg && pkg list
649+ ;;
650+
651+ (IRIX)
652+ versions -b
653+ ;;
654+
655+ (SerenityOS)
656+ while IFS=" " read -r type _; do
657+ [ "$type" != dependency ] &&
658+ printf "\n"
659+ done < /usr/Ports/packages.db
660+ ;;
661+ esac | wc -l
662+ )
663+
664+ # 'wc -l' can have leading and/or trailing whitespace
665+ # depending on the implementation, so strip them.
666+ # Procedure explained at https://github.com/dylanaraps/pure-sh-bible
667+ # (trim-leading-and-trailing-white-space-from-string)
668+ packages=${packages#"${packages%%[![:space:]]*}"}
669+ packages=${packages%"${packages##*[![:space:]]}"}
670+
671+ case $os in
672+ # IRIX's package manager adds 3 lines of extra
673+ # output which we must account for here.
674+ (IRIX)
675+ packages=$((packages - 3))
676+ ;;
677+
678+ # OpenBSD's wc prints whitespace before the output
679+ # which needs to be stripped.
680+ (OpenBSD)
681+ packages=$((packages))
682+ ;;
683+ esac
684+
685+ case $packages in
686+ (1?*|[2-9]*)
687+ log pkgs "$packages" >&6
688+ ;;
689+ esac
690+}
691+
692+get_memory() {
693+ case $os in
694+ # Used memory is calculated using the following "formula":
695+ # MemUsed = MemTotal + Shmem - MemFree - Buffers - Cached - SReclaimable
696+ # Source: https://github.com/KittyKatt/screenFetch/issues/386
697+ (Linux*)
698+ # Parse the '/proc/meminfo' file splitting on ':' and 'k'.
699+ # The format of the file is 'key: 000kB' and an additional
700+ # split is used on 'k' to filter out 'kB'.
701+ while IFS=':k ' read -r key val _; do
702+ case $key in
703+ (MemTotal)
704+ mem_used=$((mem_used + val))
705+ mem_full=$val
706+ ;;
707+
708+ (Shmem)
709+ mem_used=$((mem_used + val))
710+ ;;
711+
712+ (MemFree | Buffers | Cached | SReclaimable)
713+ mem_used=$((mem_used - val))
714+ ;;
715+
716+ # If detected this will be used over the above calculation
717+ # for mem_used. Available since Linux 3.14rc.
718+ # See kernel commit 34e431b0ae398fc54ea69ff85ec700722c9da773
719+ (MemAvailable)
720+ mem_avail=$val
721+ ;;
722+ esac
723+ done < /proc/meminfo
724+
725+ case $mem_avail in
726+ (*[0-9]*)
727+ mem_used=$(((mem_full - mem_avail) / 1024))
728+ ;;
729+
730+ *)
731+ mem_used=$((mem_used / 1024))
732+ ;;
733+ esac
734+
735+ mem_full=$((mem_full / 1024))
736+ ;;
737+
738+ # Used memory is calculated using the following "formula":
739+ # (wired + active + occupied) * 4 / 1024
740+ (Darwin*)
741+ mem_full=$(($(sysctl -n hw.memsize) / 1024 / 1024))
742+
743+ # Parse the 'vmstat' file splitting on ':' and '.'.
744+ # The format of the file is 'key: 000.' and an additional
745+ # split is used on '.' to filter it out.
746+ while IFS=:. read -r key val; do
747+ case $key in
748+ (*' wired'*|*' active'*|*' occupied'*)
749+ mem_used=$((mem_used + ${val:-0}))
750+ ;;
751+ esac
752+
753+ # Using '<<-EOF' is the only way to loop over a command's
754+ # output without the use of a pipe ('|').
755+ # This ensures that any variables defined in the while loop
756+ # are still accessible in the script.
757+ done <<-EOF
758+ $(vm_stat)
759+ EOF
760+
761+ mem_used=$((mem_used * 4 / 1024))
762+ ;;
763+
764+ (OpenBSD*)
765+ mem_full=$(($(sysctl -n hw.physmem) / 1024 / 1024))
766+
767+ # This is a really simpler parser for 'vmstat' which grabs
768+ # the used memory amount in a lazy way. 'vmstat' prints 3
769+ # lines of output with the needed value being stored in the
770+ # final line.
771+ #
772+ # This loop simply grabs the 3rd element of each line until
773+ # the EOF is reached. Each line overwrites the value of the
774+ # previous one so we're left with what we wanted. This isn't
775+ # slow as only 3 lines are parsed.
776+ while read -r _ _ line _; do
777+ mem_used=${line%%M}
778+
779+ # Using '<<-EOF' is the only way to loop over a command's
780+ # output without the use of a pipe ('|').
781+ # This ensures that any variables defined in the while loop
782+ # are still accessible in the script.
783+ done <<-EOF
784+ $(vmstat)
785+ EOF
786+ ;;
787+
788+ # Used memory is calculated using the following "formula":
789+ # mem_full - ((inactive + free + cache) * page_size / 1024)
790+ (FreeBSD*|DragonFly*)
791+ mem_full=$(($(sysctl -n hw.physmem) / 1024 / 1024))
792+
793+ # Use 'set --' to store the output of the command in the
794+ # argument list. POSIX sh has no arrays but this is close enough.
795+ #
796+ # Disable the shellcheck warning for word-splitting
797+ # as it's safe and intended ('set -f' disables globbing).
798+ # shellcheck disable=2046
799+ {
800+ set -f
801+ set +f -- $(sysctl -n hw.pagesize \
802+ vm.stats.vm.v_inactive_count \
803+ vm.stats.vm.v_free_count \
804+ vm.stats.vm.v_cache_count)
805+ }
806+
807+ # Calculate the amount of used memory.
808+ # $1: hw.pagesize
809+ # $2: vm.stats.vm.v_inactive_count
810+ # $3: vm.stats.vm.v_free_count
811+ # $4: vm.stats.vm.v_cache_count
812+ mem_used=$((mem_full - (($2 + $3 + $4) * $1 / 1024 / 1024)))
813+ ;;
814+
815+ (NetBSD*)
816+ mem_full=$(($(sysctl -n hw.physmem64) / 1024 / 1024))
817+
818+ # NetBSD implements a lot of the Linux '/proc' filesystem,
819+ # this uses the same parser as the Linux memory detection.
820+ while IFS=':k ' read -r key val _; do
821+ case $key in
822+ (MemFree)
823+ mem_free=$((val / 1024))
824+ break
825+ ;;
826+ esac
827+ done < /proc/meminfo
828+
829+ mem_used=$((mem_full - mem_free))
830+ ;;
831+
832+ (Haiku)
833+ # Read the first line of 'sysinfo -mem' splitting on
834+ # '(', ' ', and ')'. The needed information is then
835+ # stored in the 5th and 7th elements. Using '_' "consumes"
836+ # an element allowing us to proceed to the next one.
837+ #
838+ # The parsed format is as follows:
839+ # 3501142016 bytes free (used/max 792645632 / 4293787648)
840+ IFS='( )' read -r _ _ _ _ mem_used _ mem_full <<-EOF
841+ $(sysinfo -mem)
842+ EOF
843+
844+ mem_used=$((mem_used / 1024 / 1024))
845+ mem_full=$((mem_full / 1024 / 1024))
846+ ;;
847+
848+ (Minix)
849+ # Minix includes the '/proc' filesystem though the format
850+ # differs from Linux. The '/proc/meminfo' file is only a
851+ # single line with space separated elements and elements
852+ # 2 and 3 contain the total and free memory numbers.
853+ read -r _ mem_full mem_free _ < /proc/meminfo
854+
855+ mem_used=$(((mem_full - mem_free) / 1024))
856+ mem_full=$(( mem_full / 1024))
857+ ;;
858+
859+ (SunOS)
860+ hw_pagesize=$(pagesize)
861+
862+ # 'kstat' outputs memory in the following format:
863+ # unix:0:system_pages:pagestotal 1046397
864+ # unix:0:system_pages:pagesfree 885018
865+ #
866+ # This simply uses the first "element" (white-space
867+ # separated) as the key and the second element as the
868+ # value.
869+ #
870+ # A variable is then assigned based on the key.
871+ while read -r key val; do
872+ case $key in
873+ (*total)
874+ pages_full=$val
875+ ;;
876+
877+ (*free)
878+ pages_free=$val
879+ ;;
880+ esac
881+ done <<-EOF
882+ $(kstat -p unix:0:system_pages:pagestotal \
883+ unix:0:system_pages:pagesfree)
884+ EOF
885+
886+ mem_full=$((pages_full * hw_pagesize / 1024 / 1024))
887+ mem_free=$((pages_free * hw_pagesize / 1024 / 1024))
888+ mem_used=$((mem_full - mem_free))
889+ ;;
890+
891+ (IRIX)
892+ # Read the memory information from the 'top' command. Parse
893+ # and split each line until we reach the line starting with
894+ # "Memory".
895+ #
896+ # Example output: Memory: 160M max, 147M avail, .....
897+ while IFS=' :' read -r label mem_full _ mem_free _; do
898+ case $label in
899+ (Memory)
900+ mem_full=${mem_full%M}
901+ mem_free=${mem_free%M}
902+ break
903+ ;;
904+ esac
905+ done <<-EOF
906+ $(top -n)
907+ EOF
908+
909+ mem_used=$((mem_full - mem_free))
910+ ;;
911+
912+ (SerenityOS)
913+ IFS='{}' read -r _ memstat _ < /proc/memstat
914+
915+ set -f -- "$IFS"
916+ IFS=,
917+
918+ for pair in $memstat; do
919+ case $pair in
920+ (*user_physical_allocated*)
921+ mem_used=${pair##*:}
922+ ;;
923+
924+ (*user_physical_available*)
925+ mem_free=${pair##*:}
926+ ;;
927+ esac
928+ done
929+
930+ IFS=$1
931+ set +f --
932+
933+ mem_used=$((mem_used * 4096 / 1024 / 1024))
934+ mem_free=$((mem_free * 4096 / 1024 / 1024))
935+
936+ mem_full=$((mem_used + mem_free))
937+ ;;
938+ esac
939+
940+ log memory "${mem_used:-?}M / ${mem_full:-?}M" >&6
941+}
942+
943+get_wm() {
944+ case $os in
945+ (Darwin*)
946+ # Don't display window manager on macOS.
947+ ;;
948+
949+ (*)
950+ # xprop can be used to grab the window manager's properties
951+ # which contains the window manager's name under '_NET_WM_NAME'.
952+ #
953+ # The upside to using 'xprop' is that you don't need to hardcode
954+ # a list of known window manager names. The downside is that
955+ # not all window managers conform to setting the '_NET_WM_NAME'
956+ # atom..
957+ #
958+ # List of window managers which fail to set the name atom:
959+ # catwm, fvwm, dwm, 2bwm, monster, wmaker and sowm [mine! ;)].
960+ #
961+ # The final downside to this approach is that it does _not_
962+ # support Wayland environments. The only solution which supports
963+ # Wayland is the 'ps' parsing mentioned below.
964+ #
965+ # A more naive implementation is to parse the last line of
966+ # '~/.xinitrc' to extract the second white-space separated
967+ # element.
968+ #
969+ # The issue with an approach like this is that this line data
970+ # does not always equate to the name of the window manager and
971+ # could in theory be _anything_.
972+ #
973+ # This also fails when the user launches xorg through a display
974+ # manager or other means.
975+ #
976+ #
977+ # Another naive solution is to parse 'ps' with a hardcoded list
978+ # of window managers to detect the current window manager (based
979+ # on what is running).
980+ #
981+ # The issue with this approach is the need to hardcode and
982+ # maintain a list of known window managers.
983+ #
984+ # Another issue is that process names do not always equate to
985+ # the name of the window manager. False-positives can happen too.
986+ #
987+ # This is the only solution which supports Wayland based
988+ # environments sadly. It'd be nice if some kind of standard were
989+ # established to identify Wayland environments.
990+ #
991+ # pfetch's goal is to remain _simple_, if you'd like a "full"
992+ # implementation of window manager detection use 'neofetch'.
993+ #
994+ # Neofetch use a combination of 'xprop' and 'ps' parsing to
995+ # support all window managers (including non-conforming and
996+ # Wayland) though it's a lot more complicated!
997+
998+ # Don't display window manager if X isn't running.
999+ [ "$DISPLAY" ] || return
1000+
1001+ # This is a two pass call to xprop. One call to get the window
1002+ # manager's ID and another to print its properties.
1003+ has xprop && {
1004+ # The output of the ID command is as follows:
1005+ # _NET_SUPPORTING_WM_CHECK: window id # 0x400000
1006+ #
1007+ # To extract the ID, everything before the last space
1008+ # is removed.
1009+ id=$(xprop -root -notype _NET_SUPPORTING_WM_CHECK)
1010+ id=${id##* }
1011+
1012+ # The output of the property command is as follows:
1013+ # _NAME 8t
1014+ # _NET_WM_PID = 252
1015+ # _NET_WM_NAME = "bspwm"
1016+ # _NET_SUPPORTING_WM_CHECK: window id # 0x400000
1017+ # WM_CLASS = "wm", "Bspwm"
1018+ #
1019+ # To extract the name, everything before '_NET_WM_NAME = \"'
1020+ # is removed and everything after the next '"' is removed.
1021+ wm=$(xprop -id "$id" -notype -len 25 -f _NET_WM_NAME 8t)
1022+ }
1023+
1024+ # Handle cases of a window manager _not_ populating the
1025+ # '_NET_WM_NAME' atom. Display nothing in this case.
1026+ case $wm in
1027+ (*'_NET_WM_NAME = '*)
1028+ wm=${wm##*_NET_WM_NAME = \"}
1029+ wm=${wm%%\"*}
1030+ ;;
1031+
1032+ (*)
1033+ # Fallback to checking the process list
1034+ # for the select few window managers which
1035+ # don't set '_NET_WM_NAME'.
1036+ while read -r ps_line; do
1037+ case $ps_line in
1038+ (*catwm*) wm=catwm ;;
1039+ (*fvwm*) wm=fvwm ;;
1040+ (*dwm*) wm=dwm ;;
1041+ (*2bwm*) wm=2bwm ;;
1042+ (*monsterwm*) wm=monsterwm ;;
1043+ (*wmaker*) wm='Window Maker' ;;
1044+ (*sowm*) wm=sowm ;;
1045+ (*penrose*) wm=penrose ;;
1046+ esac
1047+ done <<-EOF
1048+ $(ps x)
1049+ EOF
1050+ ;;
1051+ esac
1052+ ;;
1053+ esac
1054+
1055+ log wm "$wm" >&6
1056+}
1057+
1058+
1059+get_de() {
1060+ # This only supports Xorg related desktop environments though
1061+ # this is fine as knowing the desktop environment on Windows,
1062+ # macOS etc is useless (they'll always report the same value).
1063+ #
1064+ # Display the value of '$XDG_CURRENT_DESKTOP', if it's empty,
1065+ # display the value of '$DESKTOP_SESSION'.
1066+ log de "${XDG_CURRENT_DESKTOP:-$DESKTOP_SESSION}" >&6
1067+}
1068+
1069+get_shell() {
1070+ # Display the basename of the '$SHELL' environment variable.
1071+ log shell "${SHELL##*/}" >&6
1072+}
1073+
1074+get_editor() {
1075+ # Display the value of '$VISUAL', if it's empty, display the
1076+ # value of '$EDITOR'.
1077+ editor=${VISUAL:-"$EDITOR"}
1078+
1079+ log editor "${editor##*/}" >&6
1080+}
1081+
1082+get_palette() {
1083+ # Print the first 8 terminal colors. This uses the existing
1084+ # sequences to change text color with a sequence prepended
1085+ # to reverse the foreground and background colors.
1086+ #
1087+ # This allows us to save hardcoding a second set of sequences
1088+ # for background colors.
1089+ #
1090+ # False positive.
1091+ # shellcheck disable=2154
1092+ {
1093+ esc SGR 7
1094+ palette="$e$c1 $c1 $c2 $c2 $c3 $c3 $c4 $c4 $c5 $c5 $c6 $c6 "
1095+ esc SGR 0
1096+ palette="$palette$e"
1097+ }
1098+
1099+ # Print the palette with a new-line before and afterwards but no seperator.
1100+ printf '\n' >&6
1101+ log "$palette
1102+ " " " " " >&6
1103+}
1104+
1105+get_ascii() {
1106+ # This is a simple function to read the contents of
1107+ # an ascii file from 'stdin'. It allows for the use
1108+ # of '<<-EOF' to prevent the break in indentation in
1109+ # this source code.
1110+ #
1111+ # This function also sets the text colors according
1112+ # to the ascii color.
1113+ read_ascii() {
1114+ # 'PF_COL1': Set the info name color according to ascii color.
1115+ # 'PF_COL3': Set the title color to some other color. ยฏ\_(ใ)_/ยฏ
1116+ PF_COL1=${PF_COL1:-${1:-7}}
1117+ PF_COL3=${PF_COL3:-$((${1:-7}%8+1))}
1118+
1119+ # POSIX sh has no 'var+=' so 'var=${var}append' is used. What's
1120+ # interesting is that 'var+=' _is_ supported inside '$(())'
1121+ # (arithmetic) though there's no support for 'var++/var--'.
1122+ #
1123+ # There is also no $'\n' to add a "literal"(?) newline to the
1124+ # string. The simplest workaround being to break the line inside
1125+ # the string (though this has the caveat of breaking indentation).
1126+ while IFS= read -r line; do
1127+ ascii="$ascii$line
1128+"
1129+ done
1130+ }
1131+
1132+ # This checks for ascii art in the following order:
1133+ # '$1': Argument given to 'get_ascii()' directly.
1134+ # '$PF_ASCII': Environment variable set by user.
1135+ # '$distro': The detected distribution name.
1136+ # '$os': The name of the operating system/kernel.
1137+ #
1138+ # NOTE: Each ascii art below is indented using tabs, this
1139+ # allows indentation to continue naturally despite
1140+ # the use of '<<-EOF'.
1141+ #
1142+ # False positive.
1143+ # shellcheck disable=2154
1144+ read_ascii 4 <<-EOF
1145+ ${c4} ___
1146+ ${c4}(${c7}.. ${c4}|
1147+ ${c4}(${c5}<> ${c4}|
1148+ ${c4}/ ${c7}__ ${c4}\\
1149+ ${c4}( ${c7}/ \\ ${c4}/|
1150+ ${c5}_${c4}/\\ ${c7}__)${c4}/${c5}_${c4})
1151+ ${c5}\/${c4}-____${c5}\/
1152+ EOF
1153+
1154+ # Store the "width" (longest line) and "height" (number of lines)
1155+ # of the ascii art for positioning. This script prints to the screen
1156+ # *almost* like a TUI does. It uses escape sequences to allow dynamic
1157+ # printing of the information through user configuration.
1158+ #
1159+ # Iterate over each line of the ascii art to retrieve the above
1160+ # information. The 'sed' is used to strip '\033[3Xm' color codes from
1161+ # the ascii art so they don't affect the width variable.
1162+ while read -r line; do
1163+ ascii_height=$((${ascii_height:-0} + 1))
1164+
1165+ # This was a ternary operation but they aren't supported in
1166+ # Minix's shell.
1167+ [ "${#line}" -gt "${ascii_width:-0}" ] &&
1168+ ascii_width=${#line}
1169+
1170+ # Using '<<-EOF' is the only way to loop over a command's
1171+ # output without the use of a pipe ('|').
1172+ # This ensures that any variables defined in the while loop
1173+ # are still accessible in the script.
1174+ done <<-EOF
1175+ $(printf %s "$ascii" | sed 's/\[3.m//g')
1176+ EOF
1177+
1178+ # Add a gap between the ascii art and the information.
1179+ ascii_width=$((ascii_width + 4))
1180+
1181+ # Print the ascii art and position the cursor back where we
1182+ # started prior to printing it.
1183+ {
1184+ esc_p SGR 1
1185+ printf '%s' "$ascii"
1186+ esc_p SGR 0
1187+ esc_p CUU "$ascii_height"
1188+ } >&6
1189+}
1190+
1191+main() {
1192+ case $* in
1193+ -v)
1194+ printf '%s 0.7.0\n' "${0##*/}"
1195+ return 0
1196+ ;;
1197+
1198+ -d)
1199+ # Below exec is not run, stderr is shown.
1200+ ;;
1201+
1202+ '')
1203+ exec 2>/dev/null
1204+ ;;
1205+
1206+ *)
1207+ cat <<EOF
1208+${0##*/} show system information
1209+${0##*/} -d show stderr (debug mode)
1210+${0##*/} -v show version information
1211+EOF
1212+ return 0
1213+ ;;
1214+ esac
1215+
1216+ # Hide 'stdout' and selectively print to it using '>&6'.
1217+ # This gives full control over what it displayed on the screen.
1218+ exec 6>&1 >/dev/null
1219+
1220+ # Store raw escape sequence character for later reuse.
1221+ esc_c=$(printf '\033')
1222+
1223+ # Allow the user to execute their own script and modify or
1224+ # extend pfetch's behavior.
1225+ # shellcheck source=/dev/null
1226+ ! [ -f "$PF_SOURCE" ] || . "$PF_SOURCE"
1227+
1228+ # Ensure that the 'TMPDIR' is writable as heredocs use it and
1229+ # fail without the write permission. This was found to be the
1230+ # case on Android where the temporary directory requires root.
1231+ [ -w "${TMPDIR:-/tmp}" ] || export TMPDIR=~
1232+
1233+ # Generic color list.
1234+ # Disable warning about unused variables.
1235+ # shellcheck disable=2034
1236+ for _c in c1 c2 c3 c4 c5 c6 c7 c8; do
1237+ esc SGR "3${_c#?}" 0
1238+ export "$_c=$e"
1239+ done
1240+
1241+ # Disable line wrapping and catch the EXIT signal to enable it again
1242+ # on exit. Ideally you'd somehow query the current value and retain
1243+ # it but I'm yet to see this irk anyone.
1244+ esc_p DECAWM l >&6
1245+ trap 'esc_p DECAWM h >&6' EXIT
1246+
1247+ # Store the output of 'uname' to avoid calling it multiple times
1248+ # throughout the script. 'read <<EOF' is the simplest way of reading
1249+ # a command into a list of variables.
1250+ read -r os kernel arch <<-EOF
1251+ $(uname -srm)
1252+ EOF
1253+
1254+ # Always run 'get_os' for the purposes of detecting which ascii
1255+ # art to display.
1256+ get_os
1257+
1258+ # Allow the user to specify the order and inclusion of information
1259+ # functions through the 'PF_INFO' environment variable.
1260+ # shellcheck disable=2086
1261+ {
1262+ # Disable globbing and set the positional parameters to the
1263+ # contents of 'PF_INFO'.
1264+ set -f
1265+ set +f -- ${PF_INFO-ascii title os host kernel uptime pkgs memory}
1266+
1267+ # Iterate over the info functions to determine the lengths of the
1268+ # "info names" for output alignment. The option names and subtitles
1269+ # match 1:1 so this is thankfully simple.
1270+ for info do
1271+ command -v "get_$info" >/dev/null || continue
1272+
1273+ # This was a ternary operation but they aren't supported in
1274+ # Minix's shell.
1275+ [ "${#info}" -gt "${info_length:-0}" ] &&
1276+ info_length=${#info}
1277+ done
1278+
1279+ # Add an additional space of length to act as a gap.
1280+ info_length=$((info_length + 1))
1281+
1282+ # Iterate over the above list and run any existing "get_" functions.
1283+ for info do
1284+ "get_$info"
1285+ done
1286+ }
1287+
1288+ # Position the cursor below both the ascii art and information lines
1289+ # according to the height of both. If the information exceeds the ascii
1290+ # art in height, don't touch the cursor (0/unset), else move it down
1291+ # N lines.
1292+ #
1293+ # This was a ternary operation but they aren't supported in Minix's shell.
1294+ [ "${info_height:-0}" -lt "${ascii_height:-0}" ] &&
1295+ cursor_pos=$((ascii_height - info_height))
1296+
1297+ # Print '$cursor_pos' amount of newlines to correctly position the
1298+ # cursor. This used to be a 'printf $(seq X X)' however 'seq' is only
1299+ # typically available (by default) on GNU based systems!
1300+ while [ "${i:=0}" -le "${cursor_pos:-0}" ]; do
1301+ printf '\n'
1302+ i=$((i + 1))
1303+ done >&6
1304+}
1305+
1306+main "$@"
+1,
-1
1@@ -1,6 +1,6 @@
2 #!/bin/sh
3+set -x
4 o=$1
5 nn=`/bin/ls -1 $o|sort -n|tail -n 1`
6 n=`echo ${nn%%.*}+1|bc`
7 printf $n
8-# /usr/pkg/bin/scrot $@ -f $o/$n.png
+1,
-1
1@@ -1,4 +1,4 @@
2-#!/bin/guile
3+#!/usr/bin/env guile
4 !#
5 ;; from pascalecu
6 (set! *random-state* (random-state-from-platform))
+3,
-3
1@@ -1,10 +1,10 @@
2 #!/bin/sh -eu
3 case ${1##*.} in
4- m4a|mp3|wav|ogg|mp4|giv)
5- exec mpv "$@"
6+ m4a|mp3|wav|ogg|mp4|gif)
7+ exec mpv --sid=no --no-osd-bar "$@"
8 ;;
9 png|jpeg|jpg|PNG|JPG|JPEG)
10- exec mpv "$@"
11+ exec mpv --keep-open=yes --sid=no --no-osd-bar "$@"
12 ;;
13 c|scm|sh)
14 exec emacs "$@"
+58,
-0
1@@ -0,0 +1,58 @@
2+export XDG_RUNTIME_DIR=$HOME/xdg
3+export GUILE_AUTO_COMPILE=0
4+
5+function fish_prompt
6+ #printf "%s%s%s " (set_color -b white black) $(hostname) (set_color --reset)
7+ printf '$ '
8+end
9+
10+set -g fish_greeting ''
11+export DFM_TRASH=rm
12+
13+fish_add_path /sbin
14+fish_add_path /usr/sbin
15+fish_add_path /usr/bin
16+fish_add_path /usr/local/bin
17+fish_add_path $HOME/bin
18+
19+export ENV=$HOME/.profile
20+
21+set -l background 222222
22+set -l foreground c2c2b0
23+set -l selection e4c47a
24+set -l comment 666666
25+set -l red 685742
26+set -l orange b36d43
27+set -l yellow c9a554
28+set -l green 5f875f
29+set -l purple 78824b
30+set -l sky d7c483
31+set -l pink bb7744
32+
33+set -g fish_color_normal $foreground
34+set -g fish_color_command $sky
35+set -g fish_color_keyword $pink
36+set -g fish_color_quote $yellow
37+set -g fish_color_redirection $foreground
38+set -g fish_color_end $orange
39+set -g fish_color_error $red
40+set -g fish_color_param $purple
41+set -g fish_color_comment $comment
42+set -g fish_color_selection --background=$selection
43+set -g fish_color_search_match --background=$selection
44+set -g fish_color_operator $green
45+set -g fish_color_escape $pink
46+set -g fish_color_autosuggestion $comment
47+
48+set -g fish_pager_color_progress $comment
49+set -g fish_pager_color_prefix $sky
50+set -g fish_pager_color_completion $foreground
51+set -g fish_pager_color_description $comment
52+set -g fish_pager_color_selected_background --background=$selection
53+
54+[ -z $DISPLAY ] && [ $(tty) = "/dev/tty1" ] && {
55+for i in sway awww-daemon aws
56+ killall $i 2>/dev/null || :;
57+end
58+exec sway 2>/dev/null
59+}
+7,
-7
1@@ -1,7 +1,7 @@
2 * {
3- bg: #282828;
4+ bg: #222222;
5 bg-alt: @bg;
6- fg: #aaa;
7+ fg: #444;
8 fg-alt: #ebdbb2;
9 mg: @fg;
10
11@@ -10,20 +10,20 @@
12 }
13
14 configuration {
15- font: 'PxPlus IBM VGA 8x16 12';
16+ font: 'Scientifica 16';
17 }
18
19 window {
20- width: 35%;
21+ width: 15%;
22 height: 20%;
23- border: 1px;
24- border-radius: 0px;
25+ border: 0px;
26+ border-radius: 10px;
27 border-color: @fg-alt;
28 background-color: @bg;
29 }
30
31 mainbox {
32- border: 1px;
33+ border: 4px;
34 border-radius: 0px;
35 border-color: @fg;
36 padding: 0px;
M
foot.ini
+5,
-5
1@@ -1,15 +1,15 @@
2 # srcery
3 [main]
4-pad=0x0
5+pad=30x30
6 initial-window-size-pixels=400x300
7-resize-by-cells=yes
8-font=Iosevka:size=9
9+resize-by-cells=no
10+font=Iosevka Curly:size=9
11
12 [colors-dark]
13-alpha=0.85
14+alpha=1
15
16 [colors-light]
17-alpha=0.85
18+alpha=1
19
20 # colors (miasma) https://github.com/xero/miasma.nvim
21
+56,
-0
1@@ -0,0 +1,56 @@
2+animation_duration_ms 250
3+
4+blur disable
5+blur_xray disable
6+blur_passes 4
7+blur_radius 4
8+corner_radius 5
9+gaps inner 15
10+shadows enable
11+shadows_on_csd disable
12+
13+# You can also offset the shadow's position, make unfocused windows have different shadows, give shadows a nondefault color, and blur shadows
14+# shadow_inactive_color #0000007F
15+# shadow_offset 10 10
16+shadow_blur_radius 10
17+
18+set $mod Mod4
19+#set $term kitty --single-instance
20+set $term foot
21+set $menu rofi -show run -theme config.rasi
22+exec aws
23+
24+# output * bg ~/media/w/rk.png tile
25+ bindsym $mod+z exec $term
26+ bindsym $mod+e exec emacs
27+ bindsym $mod+a kill
28+ bindsym $mod+x exec $menu
29+
30+ floating_modifier $mod normal
31+ bindsym $mod+Shift+c reload
32+
33+ bindsym $mod+Shift+q exec swaynag -t warning -m 'You pressed the exit shortcut. Do you really want to exit SwayFX? This will end your Wayland session.' -B 'Yes, exit SwayFX' 'swaymsg exit'
34+#
35+ bindsym $mod+1 workspace number 1
36+ bindsym $mod+2 workspace number 2
37+ bindsym $mod+3 workspace number 3
38+ bindsym $mod+4 workspace number 4
39+ bindsym $mod+5 workspace number 5
40+ bindsym $mod+Shift+1 move container to workspace number 1
41+ bindsym $mod+Shift+2 move container to workspace number 2
42+ bindsym $mod+Shift+3 move container to workspace number 3
43+ bindsym $mod+Shift+4 move container to workspace number 4
44+ bindsym $mod+Shift+5 move container to workspace number 5
45+
46+ bindsym $mod+f fullscreen
47+ bindsym $mod+Shift+space floating toggle
48+
49+bindsym Print exec grect
50+
51+for_window [class=.*] floating enable
52+
53+default_border normal 0
54+default_floating_border normal 0
55+
56+set $a #d7c483
57+client.focused $a $a $a $a $a
+2,
-2
1@@ -10,8 +10,8 @@
2 --urlbar-focused-bg-color: var(--tab-active-bg-color);
3 --urlbar-not-focused-bg-color: var(--urlbar-focused-bg-color);
4 --toolbar-bgcolor: var(--tab-active-bg-color) !important;
5- --tab-font: 'Screen';
6- --urlbar-font: 'Screen';
7+ --tab-font: 'Misc Fixed';
8+ --urlbar-font: 'Misc Fixed';
9
10 /* try increasing if you encounter problems */
11 --urlbar-height-setting: 22px;