[download]
local/bin/pfetch
1
2
3
4
5
6
7 esc() {
8 case $1 in
9 CUU) e="${esc_c}[${2}A" ;; # cursor up
10 CUD) e="${esc_c}[${2}B" ;; # cursor down
11 CUF) e="${esc_c}[${2}C" ;; # cursor right
12 CUB) e="${esc_c}[${2}D" ;; # cursor left
13
14
15 SGR)
16 case ${PF_COLOR:=1} in
17 (1)
18 e="${esc_c}[${2}m"
19 ;;
20
21 (0)
22
23 e=
24 ;;
25 esac
26 ;;
27
28
29 DECAWM)
30 case $TERM in
31 (dumb | minix | cons25)
32
33 e=
34 ;;
35
36 (*)
37 e="${esc_c}[?7${2}"
38 ;;
39 esac
40 ;;
41 esac
42 }
43
44
45 esc_p() {
46 esc "$@"
47 printf '%s' "$e"
48 }
49
50
51
52
53 has() {
54 _cmd=$(command -v "$1") 2>/dev/null || return 1
55 [ -x "$_cmd" ] || return 1
56 }
57
58 log() {
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113 [ "$2" ] || return
114
115
116 name=$1
117
118
119
120
121
122
123
124
125 {
126 set -f
127 set +f -- $2
128 info=$*
129 }
130
131
132
133 esc_p CUF "$ascii_width"
134
135
136 esc_p SGR "3${PF_COL1-4}";
137 esc_p SGR 1
138 printf '%s' "$name"
139 esc_p SGR 0
140
141
142 printf %s "$PF_SEP"
143
144
145
146
147 esc_p CUB "${#name}"
148 esc_p CUF "${PF_ALIGN:-$info_length}"
149
150
151
152 esc_p SGR "3${PF_COL2-7}"
153 printf '%s' "$info"
154 esc_p SGR 0
155 printf '\n'
156
157
158 info_height=$((${info_height:-0} + 1))
159 }
160
161 get_title() {
162
163
164 user=${USER:-$(id -un)}
165
166
167
168
169
170
171
172
173 host=${HOSTNAME:-${host:-$(hostname)}}
174
175
176
177 [ "$host" ] || read -r host < /etc/hostname
178
179
180
181 esc SGR 1
182 user=$e$user
183 esc SGR "3${PF_COL3:-1}"
184 user=$e$user
185 esc SGR 1
186 user=$user$e
187 esc SGR 1
188 host=$e$host
189 esc SGR "3${PF_COL3:-1}"
190 host=$e$host
191
192 log "${user}@${host}" " " >&6
193 }
194
195 get_os() {
196
197
198
199
200
201
202 [ "$distro" ] && {
203 log os "$distro" >&6
204 return
205 }
206
207 case $os in
208 (Linux*)
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231 if has lsb_release; then
232 distro=$(lsb_release -sd)
233
234
235
236
237 elif [ -d /system/app ] && [ -d /system/priv-app ]; then
238 distro="Android $(getprop ro.build.version.release)"
239
240 else
241
242
243
244
245 while IFS='=' read -r key val; do
246 case $key in
247 (PRETTY_NAME)
248 distro=$val
249 ;;
250 esac
251 done < /etc/os-release
252 fi
253
254
255
256 distro=${distro##[\"\']}
257 distro=${distro%%[\"\']}
258
259
260
261 has crux && distro=$(crux)
262 has guix && distro='Guix System'
263
264
265
266
267 case $PATH in
268 (*/bedrock/cross/*)
269 distro='Bedrock Linux'
270 ;;
271 esac
272
273
274
275
276
277
278
279 if [ "$WSLENV" ]; then
280 distro="${distro}${WSLENV+ on Windows 10 [WSL2]}"
281
282
283
284
285
286
287
288
289 elif [ -z "${kernel%%*-Microsoft}" ]; then
290 distro="$distro on Windows 10 [WSL1]"
291 fi
292 ;;
293
294 (Darwin*)
295
296
297
298
299
300
301
302
303
304
305
306
307 while IFS='<>' read -r _ _ line _; do
308 case $line in
309
310
311 ProductVersion)
312 IFS='<>' read -r _ _ mac_version _
313 break
314 ;;
315 esac
316 done < /System/Library/CoreServices/SystemVersion.plist
317
318
319
320
321 case $mac_version in
322 (10.4*) distro='Mac OS X Tiger' ;;
323 (10.5*) distro='Mac OS X Leopard' ;;
324 (10.6*) distro='Mac OS X Snow Leopard' ;;
325 (10.7*) distro='Mac OS X Lion' ;;
326 (10.8*) distro='OS X Mountain Lion' ;;
327 (10.9*) distro='OS X Mavericks' ;;
328 (10.10*) distro='OS X Yosemite' ;;
329 (10.11*) distro='OS X El Capitan' ;;
330 (10.12*) distro='macOS Sierra' ;;
331 (10.13*) distro='macOS High Sierra' ;;
332 (10.14*) distro='macOS Mojave' ;;
333 (10.15*) distro='macOS Catalina' ;;
334 (*) distro='macOS' ;;
335 esac
336
337 distro="$distro $mac_version"
338 ;;
339
340 (Haiku)
341
342
343 distro=$(uname -sv)
344 ;;
345
346 (Minix|DragonFly)
347 distro="$os $kernel"
348
349
350
351 trap '' EXIT
352 ;;
353
354 (SunOS)
355
356
357 IFS='(' read -r distro _ < /etc/release
358 ;;
359
360 (OpenBSD*)
361
362
363 IFS=' =' read -r _ distro openbsd_ver _ <<-EOF
364 $(sysctl kern.version)
365 EOF
366
367 distro="$distro $openbsd_ver"
368 ;;
369
370 FreeBSD)
371 distro="$os $(freebsd-version)"
372 ;;
373
374 (*)
375
376
377 distro="$os $kernel"
378 ;;
379 esac
380 }
381
382 get_kernel() {
383 case $os in
384
385
386 (*BSD*|Haiku|Minix)
387 return
388 ;;
389 esac
390
391
392 log kernel "$kernel" >&6
393 }
394
395 get_host() {
396 case $os in
397 (Linux*)
398
399
400
401 read -r name < /sys/devices/virtual/dmi/id/product_name
402 read -r version < /sys/devices/virtual/dmi/id/product_version
403 read -r model < /sys/firmware/devicetree/base/model
404
405 host="$name $version $model"
406 ;;
407
408 (Darwin* | FreeBSD* | DragonFly*)
409 host=$(sysctl -n hw.model)
410 ;;
411
412 (NetBSD*)
413 host=$(sysctl -n machdep.dmi.system-vendor \
414 machdep.dmi.system-product)
415 ;;
416
417 (OpenBSD*)
418 host=$(sysctl -n hw.version)
419 ;;
420
421 (*BSD* | Minix)
422 host=$(sysctl -n hw.vendor hw.product)
423 ;;
424 esac
425
426
427
428
429
430
431
432
433 {
434 set -f
435 set +f -- $host
436 host=
437 }
438
439
440
441
442
443
444
445
446
447
448
449 for word do
450
451
452
453 case $word in
454 (To | [Bb]e | [Ff]illed | [Bb]y | O.E.M. | OEM |\
455 Not | Applicable | Specified | System | Product | Name |\
456 Version | Undefined | Default | string | INVALID | ๏ฟฝ | os )
457 continue
458 ;;
459 esac
460
461 host="$host$word "
462 done
463
464
465 log host "${host:-$arch}" >&6
466 }
467
468 get_uptime() {
469
470
471
472 case $os in
473 (Linux* | Minix*)
474 IFS=. read -r s _ < /proc/uptime
475 ;;
476
477 Darwin* | *BSD* | DragonFly*)
478 s=$(sysctl -n kern.boottime)
479
480
481
482 s=${s#*=}
483 s=${s%,*}
484
485
486
487 s=$(($(date +%s) - s))
488 ;;
489
490 (Haiku)
491
492
493 s=$(($(system_time) / 1000000))
494 ;;
495
496 (SunOS)
497
498
499
500
501
502
503
504 IFS=' .' read -r _ s _ <<-EOF
505 $(kstat -p unix:0:system_misc:snaptime)
506 EOF
507 ;;
508
509 (IRIX)
510
511
512 t=$(LC_ALL=POSIX ps -o etime= -p 1)
513
514
515
516 case $t in
517 (*-*) d=${t%%-*} t=${t#*-} ;;
518 (*:*:*) h=${t%%:*} t=${t#*:} ;;
519 esac
520
521 h=${h#0} t=${t#0}
522
523
524
525 s=$((${d:-0}*86400 + ${h:-0}*3600 + ${t%%:*}*60 + ${t#*:}))
526 ;;
527 esac
528
529
530 d=$((s / 60 / 60 / 24))
531 h=$((s / 60 / 60 % 24))
532 m=$((s / 60 % 60))
533
534
535 case "$d" in ([!0]*) uptime="${uptime}${d}d "; esac
536 case "$h" in ([!0]*) uptime="${uptime}${h}h "; esac
537 case "$m" in ([!0]*) uptime="${uptime}${m}m "; esac
538
539 log uptime "${uptime:-0m}" >&6
540 }
541
542 get_pkgs() {
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559 packages=`
560 case $os in
561 (Linux*)
562
563 has bonsai && bonsai list
564 has crux && pkginfo -i
565 has pacman-key && pacman -Qq
566 has dpkg && dpkg-query -f '.\n' -W
567 has rpm && rpm -qa
568 has xbps-query && xbps-query -l
569 has apk && apk info
570 has guix && guix package --list-installed
571 has opkg && opkg list-installed
572
573
574 has kiss && printf '%s\n' /var/db/kiss/installed/*/
575 has cpt-list && printf '%s\n' /var/db/cpt/installed/*/
576 has brew && printf '%s\n' "$(brew --cellar)/"*
577 has emerge && printf '%s\n' /var/db/pkg/*/*/
578 has pkgtool && printf '%s\n' /var/log/packages/*
579 has eopkg && printf '%s\n' /var/lib/eopkg/package/*
580
581
582 has nix-store && {
583 nix-store -q --requisites /run/current-system/sw
584 nix-store -q --requisites ~/.nix-profile
585 }
586 ;;
587
588 (Darwin*)
589
590 has pkgin && pkgin list
591
592
593 has brew && printf '%s\n' /usr/local/Cellar/*
594
595
596
597
598
599
600
601
602
603 has port && {
604 pkg_list=$(port installed)
605
606 case "$pkg_list" in
607 ("No ports are installed.")
608
609 ;;
610
611 (*)
612 printf '%s\n' "$pkg_list"
613 ;;
614 esac
615 }
616 ;;
617
618 (FreeBSD*|DragonFly*)
619 pkg info
620 ;;
621
622 (OpenBSD*)
623 printf '%s\n' /var/db/pkg/*/
624 ;;
625
626 (NetBSD*)
627 pkg_info
628 ;;
629
630 (Haiku)
631 printf '%s\n' /boot/system/package-links/*
632 ;;
633
634 (Minix)
635 printf '%s\n' /usr/pkg/var/db/pkg/*/
636 ;;
637
638 (SunOS)
639 has pkginfo && pkginfo -i
640 has pkg && pkg list
641 ;;
642
643 (IRIX)
644 versions -b
645 ;;
646 esac | wc -l
647 `
648
649 case $os in
650
651
652 (IRIX)
653 packages=$((packages - 3))
654 ;;
655 esac
656
657 case $packages in
658 (1?*|[2-9]*)
659 log pkgs "$packages" >&6
660 ;;
661 esac
662 }
663
664 get_memory() {
665 case $os in
666
667
668
669 (Linux*)
670
671
672
673 while IFS=':k ' read -r key val _; do
674 case $key in
675 (MemTotal)
676 mem_used=$((mem_used + val))
677 mem_full=$val
678 ;;
679
680 (Shmem)
681 mem_used=$((mem_used + val))
682 ;;
683
684 (MemFree | Buffers | Cached | SReclaimable)
685 mem_used=$((mem_used - val))
686 ;;
687
688
689
690
691 (MemAvailable)
692 mem_avail=$val
693 ;;
694 esac
695 done < /proc/meminfo
696
697 case $mem_avail in
698 (*[0-9]*)
699 mem_used=$(((mem_full - mem_avail) / 1024))
700 ;;
701
702 *)
703 mem_used=$((mem_used / 1024))
704 ;;
705 esac
706
707 mem_full=$((mem_full / 1024))
708 ;;
709
710
711
712 (Darwin*)
713 mem_full=$(($(sysctl -n hw.memsize) / 1024 / 1024))
714
715
716
717
718 while IFS=:. read -r key val; do
719 case $key in
720 (*' wired'*|*' active'*|*' occupied'*)
721 mem_used=$((mem_used + ${val:-0}))
722 ;;
723 esac
724
725
726
727
728
729 done <<-EOF
730 $(vm_stat)
731 EOF
732
733 mem_used=$((mem_used * 4 / 1024))
734 ;;
735
736 (OpenBSD*)
737 mem_full=$(($(sysctl -n hw.physmem) / 1024 / 1024))
738
739
740
741
742
743
744
745
746
747
748 while read -r _ _ line _; do
749 mem_used=${line%%M}
750
751
752
753
754
755 done <<-EOF
756 $(vmstat)
757 EOF
758 ;;
759
760
761
762 (FreeBSD*|DragonFly*)
763 mem_full=$(($(sysctl -n hw.physmem) / 1024 / 1024))
764
765
766
767
768
769
770
771 {
772 set -f
773 set +f -- $(sysctl -n hw.pagesize \
774 vm.stats.vm.v_inactive_count \
775 vm.stats.vm.v_free_count \
776 vm.stats.vm.v_cache_count)
777 }
778
779
780
781
782
783
784 mem_used=$((mem_full - (($2 + $3 + $4) * $1 / 1024 / 1024)))
785 ;;
786
787 (NetBSD*)
788 mem_full=$(($(sysctl -n hw.physmem64) / 1024 / 1024))
789
790
791
792 while IFS=':k ' read -r key val _; do
793 case $key in
794 (MemFree)
795 mem_free=$((val / 1024))
796 break
797 ;;
798 esac
799 done < /proc/meminfo
800
801 mem_used=$((mem_full - mem_free))
802 ;;
803
804 (Haiku)
805
806
807
808
809
810
811
812 IFS='( )' read -r _ _ _ _ mem_used _ mem_full <<-EOF
813 $(sysinfo -mem)
814 EOF
815
816 mem_used=$((mem_used / 1024 / 1024))
817 mem_full=$((mem_full / 1024 / 1024))
818 ;;
819
820 (Minix)
821
822
823
824
825 read -r _ mem_full mem_free _ < /proc/meminfo
826
827 mem_used=$(((mem_full - mem_free) / 1024))
828 mem_full=$(( mem_full / 1024))
829 ;;
830
831 (SunOS)
832 hw_pagesize=$(pagesize)
833
834
835
836
837
838
839
840
841
842
843 while read -r key val; do
844 case $key in
845 (*total)
846 pages_full=$val
847 ;;
848
849 (*free)
850 pages_free=$val
851 ;;
852 esac
853 done <<-EOF
854 $(kstat -p unix:0:system_pages:pagestotal \
855 unix:0:system_pages:pagesfree)
856 EOF
857
858 mem_full=$((pages_full * hw_pagesize / 1024 / 1024))
859 mem_free=$((pages_free * hw_pagesize / 1024 / 1024))
860 mem_used=$((mem_full - mem_free))
861 ;;
862
863 (IRIX)
864
865
866
867
868
869 while IFS=' :' read -r label mem_full _ mem_free _; do
870 case $label in
871 (Memory)
872 mem_full=${mem_full%M}
873 mem_free=${mem_free%M}
874 break
875 ;;
876 esac
877 done <<-EOF
878 $(top -n)
879 EOF
880
881 mem_used=$((mem_full - mem_free))
882 ;;
883 esac
884
885 log memory "${mem_used:-?}M / ${mem_full:-?}M" >&6
886 }
887
888 get_wm() {
889 case $os in
890 (Darwin*)
891
892 ;;
893
894 (*)
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944 [ "$DISPLAY" ] || return
945
946
947
948 has xprop && {
949
950
951
952
953
954 id=$(xprop -root -notype _NET_SUPPORTING_WM_CHECK)
955 id=${id##* }
956
957
958
959
960
961
962
963
964
965
966 wm=$(xprop -id "$id" -notype -len 25 -f _NET_WM_NAME 8t)
967 }
968
969
970
971 case $wm in
972 (*'_NET_WM_NAME = '*)
973 wm=${wm##*_NET_WM_NAME = \"}
974 wm=${wm%%\"*}
975 ;;
976
977 (*)
978
979
980
981 while read -r ps_line; do
982 case $ps_line in
983 (*catwm*) wm=catwm ;;
984 (*fvwm*) wm=fvwm ;;
985 (*dwm*) wm=dwm ;;
986 (*2bwm*) wm=2bwm ;;
987 (*monsterwm*) wm=monsterwm ;;
988 (*wmaker*) wm='Window Maker' ;;
989 (*sowm*) wm=sowm ;;
990 esac
991 done <<-EOF
992 $(ps x)
993 EOF
994 ;;
995 esac
996 ;;
997 esac
998
999 log wm "$wm" >&6
1000 }
1001
1002
1003 get_de() {
1004
1005
1006
1007
1008
1009
1010 log de "${XDG_CURRENT_DESKTOP:-$DESKTOP_SESSION}" >&6
1011 }
1012
1013 get_shell() {
1014
1015 log shell "${SHELL##*/}" >&6
1016 }
1017
1018 get_editor() {
1019
1020
1021 log editor "${VISUAL:-$EDITOR}" >&6
1022 }
1023
1024 get_palette() {
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034 {
1035 esc SGR 7
1036 palette="$e$c1 $c1 $c2 $c2 $c3 $c3 $c4 $c4 $c5 $c5 $c6 $c6 "
1037 esc SGR 0
1038 palette="$palette$e"
1039 }
1040
1041
1042 printf '\n' >&6
1043 log "$palette
1044 " " " >&6
1045 }
1046
1047 get_ascii() {
1048
1049
1050
1051
1052
1053
1054
1055 read_ascii() {
1056
1057
1058 PF_COL1=${PF_COL1:-${1:-7}}
1059 PF_COL3=${PF_COL3:-$((${1:-7}%8+1))}
1060
1061
1062
1063
1064
1065
1066
1067
1068 while IFS= read -r line; do
1069 ascii="$ascii$line
1070 "
1071 done
1072 }
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086 case ${1:-${PF_ASCII:-${distro:-$os}}} in
1087 ([Aa]lpine*)
1088 read_ascii 4 <<-EOF
1089 ${c4} /\\ /\\
1090 /${c7}/ ${c4}\\ \\
1091 /${c7}/ ${c4}\\ \\
1092 /${c7}// ${c4}\\ \\
1093 ${c7}// ${c4}\\ \\
1094 ${c4}\\
1095 EOF
1096 ;;
1097
1098 ([Aa]ndroid*)
1099 read_ascii 2 <<-EOF
1100 ${c2} ;, ,;
1101 ${c2} ';,.-----.,;'
1102 ${c2} ,' ',
1103 ${c2} / O O \\
1104 ${c2}| |
1105 ${c2}'-----------------'
1106 EOF
1107 ;;
1108
1109 ([Aa]rch*)
1110 read_ascii 4 <<-EOF
1111 ${c6} /\\
1112 ${c6} / \\
1113 ${c6} /\\ \\
1114 ${c4} / \\
1115 ${c4} / ,, \\
1116 ${c4} / | | -\\
1117 ${c4} /_-'' ''-_\\
1118 EOF
1119 ;;
1120
1121 ([Aa]rco*)
1122 read_ascii 4 <<-EOF
1123 ${c4} /\\
1124 ${c4} / \\
1125 ${c4} / /\\ \\
1126 ${c4} / / \\ \\
1127 ${c4} / / \\ \\
1128 ${c4} / / _____\\ \\
1129 ${c4}/_/ \`----.\\_\\
1130 EOF
1131 ;;
1132
1133 ([Aa]rtix*)
1134 read_ascii 6 <<-EOF
1135 ${c4} /\\
1136 ${c4} / \\
1137 ${c4} /\`'.,\\
1138 ${c4} / ',
1139 ${c4} / ,\`\\
1140 ${c4} / ,.'\`. \\
1141 ${c4}/.,'\` \`'.\\
1142 EOF
1143 ;;
1144
1145 ([Bb]edrock*)
1146 read_ascii 4 <<-EOF
1147 ${c7}__
1148 ${c7}\\ \\___
1149 ${c7} \\ _ \\
1150 ${c7} \\___/
1151 EOF
1152 ;;
1153
1154 ([Bb]uildroot*)
1155 read_ascii 3 <<-EOF
1156 ${c3} ___
1157 ${c3} / \` \\
1158 ${c3}| : :|
1159 ${c3}-. _:__.-
1160 ${c3} \` ---- \`
1161 EOF
1162 ;;
1163
1164 ([Cc]ent[Oo][Ss]*)
1165 read_ascii 5 <<-EOF
1166 ${c2} ____${c3}^${c5}____
1167 ${c2} |\\ ${c3}|${c5} /|
1168 ${c2} | \\ ${c3}|${c5} / |
1169 ${c5}<---- ${c4}---->
1170 ${c4} | / ${c2}|${c3} \\ |
1171 ${c4} |/__${c2}|${c3}__\\|
1172 ${c2} v
1173 EOF
1174 ;;
1175
1176 ([Dd]ahlia*)
1177 read_ascii 1 <<-EOF
1178 ${c1} _
1179 ${c1} ___/ \\___
1180 ${c1} | _-_ |
1181 ${c1} | / \ |
1182 ${c1}/ | | \\
1183 ${c1}\\ | | /
1184 ${c1} | \ _ _ / |
1185 ${c1} |___ - ___|
1186 ${c1} \\_/
1187 EOF
1188 ;;
1189
1190 ([Dd]ebian*)
1191 read_ascii 1 <<-EOF
1192 ${c1} _____
1193 ${c1} / __ \\
1194 ${c1}| / |
1195 ${c1}| \\___-
1196 ${c1}-_
1197 ${c1} --_
1198 EOF
1199 ;;
1200
1201 ([Dd]ragon[Ff]ly*)
1202 read_ascii 1 <<-EOF
1203 ,${c1}_${c7},
1204 ('-_${c1}|${c7}_-')
1205 >--${c1}|${c7}--<
1206 (_-'${c1}|${c7}'-_)
1207 ${c1}|
1208 ${c1}|
1209 ${c1}|
1210 EOF
1211 ;;
1212
1213 ([Ee]lementary*)
1214 read_ascii <<-EOF
1215 ${c7} _______
1216 ${c7} / ____ \\
1217 ${c7}/ | / /\\
1218 ${c7}|__\\ / / |
1219 ${c7}\\ /__/ /
1220 ${c7}\\_______/
1221 EOF
1222 ;;
1223
1224 ([Ee]ndeavour*)
1225 read_ascii 4 <<-EOF
1226 ${c1}/${c4}\\
1227 ${c1}/${c4}/ \\${c6}\\
1228 ${c1}/${c4}/ \\ ${c6}\\
1229 ${c1}/ ${c4}/ _) ${c6})
1230 ${c1}/_${c4}/___-- ${c6}__-
1231 ${c6}/____--
1232 EOF
1233 ;;
1234
1235 ([Ff]edora*)
1236 read_ascii 4 <<-EOF
1237 ${c7} _____
1238 / __)${c4}\\${c7}
1239 | / ${c4}\\ \\${c7}
1240 ${c4}__${c7}_| |_${c4}_/ /${c7}
1241 ${c4}/ ${c7}(_ _)${c4}_/${c7}
1242 ${c4}/ /${c7} | |
1243 ${c4}\\ \\${c7}__/ |
1244 ${c4}\\${c7}(_____/
1245 EOF
1246 ;;
1247
1248 ([Ff]ree[Bb][Ss][Dd]*)
1249 read_ascii 1 <<-EOF
1250 ${c1}/\\,-'''''-,/\\
1251 ${c1}\\_) (_/
1252 ${c1}| |
1253 ${c1}| |
1254 ${c1}; ;
1255 ${c1}'-_____-'
1256 EOF
1257 ;;
1258
1259 ([Gg]entoo*)
1260 read_ascii 5 <<-EOF
1261 ${c5} _-----_
1262 ${c5}( \\
1263 ${c5}\\ 0 \\
1264 ${c7} \\ )
1265 ${c7} / _/
1266 ${c7}( _-
1267 ${c7}\\____-
1268 EOF
1269 ;;
1270
1271 ([Gg][Nn][Uu]*)
1272 read_ascii 3 <<-EOF
1273 ${c2} _-\`\`-, ,-\`\`-_
1274 ${c2} .' _-_| |_-_ '.
1275 ${c2}./ /_._ _._\\ \\.
1276 ${c2}: _/_._\`:'_._\\_ :
1277 ${c2}\\:._/ ,\` \\ \\ \\_.:/
1278 ${c2} ,-';'.@) \\ @) \\
1279 ${c2} ,'/' ..- .\\,-.|
1280 ${c2} /'/' \\(( \\\` ./ )
1281 ${c2} '/'' \\_,----'
1282 ${c2} '/'' ,;/''
1283 ${c2} \`\`;'
1284 EOF
1285 ;;
1286
1287 ([Gg]uix[Ss][Dd]*|[Gg]uix*)
1288 read_ascii 3 <<-EOF
1289 ${c3}|.__ __.|
1290 ${c3}|__ \\ / __|
1291 ${c3}\\ \\ / /
1292 ${c3}\\ \\ / /
1293 ${c3}\\ \\ / /
1294 ${c3}\\ \\/ /
1295 ${c3}\\__/
1296 EOF
1297 ;;
1298
1299 ([Hh]aiku*)
1300 read_ascii 3 <<-EOF
1301 ${c3} ,^,
1302 ${c3} / \\
1303 ${c3}*--_ ; ; _--*
1304 ${c3}\\ '" "' /
1305 ${c3}'. .'
1306 ${c3}.-'" "'-.
1307 ${c3}'-.__. .__.-'
1308 ${c3}|_|
1309 EOF
1310 ;;
1311
1312 ([Hh]yperbola*)
1313 read_ascii <<-EOF
1314 ${c7} |\`__.\`/
1315 ${c7} \____/
1316 ${c7} .--.
1317 ${c7} / \\
1318 ${c7} / ___ \\
1319 ${c7}/ .\` \`.\\
1320 ${c7}/.\` \`.\\
1321 EOF
1322 ;;
1323
1324 ([Ii]nstant[Oo][Ss]*)
1325 read_ascii <<-EOF
1326 ${c0} ,-''-,
1327 ${c0}: .''. :
1328 ${c0}: ',,' :
1329 ${c0} '-____:__
1330 ${c0} : \`.
1331 ${c0} \`._.'
1332 EOF
1333 ;;
1334
1335 ([Ii][Rr][Ii][Xx]*)
1336 read_ascii 1 <<-EOF
1337 ${c1} __
1338 ${c1} \\ \\ __
1339 ${c1} \\ \\ / /
1340 ${c1} \\ v /
1341 ${c1} / . \\
1342 ${c1} /_/ \\ \\
1343 ${c1} \\_\\
1344 EOF
1345 ;;
1346
1347 ([Kk][Dd][Ee]*[Nn]eon*)
1348 read_ascii 6 <<-EOF
1349 ${c7} .${c6}__${c7}.${c6}__${c7}.
1350 ${c6} / _${c7}.${c6}_ \\
1351 ${c6} / / \\ \\
1352 ${c7} . ${c6}| ${c7}O${c6} | ${c7}.
1353 ${c6} \\ \\_${c7}.${c6}_/ /
1354 ${c6} \\${c7}.${c6}__${c7}.${c6}__${c7}.${c6}/
1355 EOF
1356 ;;
1357
1358 ([Ll]inux*[Ll]ite*|[Ll]ite*)
1359 read_ascii 3 <<-EOF
1360 ${c3} /\\
1361 ${c3} / \\
1362 ${c3} / ${c7}/ ${c3}/
1363 ${c3}> ${c7}/ ${c3}/
1364 ${c3}\\ ${c7}\\ ${c3}\\
1365 ${c3}\\_${c7}\\${c3}_\\
1366 ${c7} \\
1367 EOF
1368 ;;
1369
1370 ([Ll]inux*[Mm]int*|[Mm]int)
1371 read_ascii 2 <<-EOF
1372 ${c2} ___________
1373 ${c2}|_ \\
1374 ${c2}| ${c7}| _____ ${c2}|
1375 ${c2}| ${c7}| | | | ${c2}|
1376 ${c2}| ${c7}| | | | ${c2}|
1377 ${c2}| ${c7}\\__${c7}___/ ${c2}|
1378 ${c2}\\_________/
1379 EOF
1380 ;;
1381
1382
1383 ([Ll]inux*)
1384 read_ascii 4 <<-EOF
1385 ${c4} ___
1386 ${c4}(${c7}.. ${c4}|
1387 ${c4}(${c5}<> ${c4}|
1388 ${c4}/ ${c7}__ ${c4}\\
1389 ${c4}( ${c7}/ \\ ${c4}/|
1390 ${c5}_${c4}/\\ ${c7}__)${c4}/${c5}_${c4})
1391 ${c5}\/${c4}-____${c5}\/
1392 EOF
1393 ;;
1394
1395 ([Mm]ac[Oo][Ss]*|[Dd]arwin*)
1396 read_ascii 1 <<-EOF
1397 ${c1} .:'
1398 ${c1} _ :'_
1399 ${c2} .'\`_\`-'_\`\`.
1400 ${c2}:________.-'
1401 ${c3}:_______:
1402 ${c4} :_______\`-;
1403 ${c5} \`._.-._.'
1404 EOF
1405 ;;
1406
1407 ([Mm]ageia*)
1408 read_ascii 2 <<-EOF
1409 ${c6} *
1410 ${c6} *
1411 ${c6} **
1412 ${c7} /\\__/\\
1413 ${c7}/ \\
1414 ${c7}\\ /
1415 ${c7} \\____/
1416 EOF
1417 ;;
1418
1419 ([Mm]anjaro*)
1420 read_ascii 2 <<-EOF
1421 ${c2}||||||||| ||||
1422 ${c2}||||||||| ||||
1423 ${c2}|||| ||||
1424 ${c2}|||| |||| ||||
1425 ${c2}|||| |||| ||||
1426 ${c2}|||| |||| ||||
1427 ${c2}|||| |||| ||||
1428 EOF
1429 ;;
1430
1431 ([Mm]inix*)
1432 read_ascii 4 <<-EOF
1433 ${c4} ,, ,,
1434 ${c4};${c7},${c4} ', ,' ${c7},${c4};
1435 ${c4}; ${c7}',${c4} ',,' ${c7},'${c4} ;
1436 ${c4}; ${c7}',${c4} ${c7},'${c4} ;
1437 ${c4}; ${c7};, '' ,;${c4} ;
1438 ${c4}; ${c7};${c4};${c7}',,'${c4};${c7};${c4} ;
1439 ${c4}', ${c7};${c4};; ;;${c7};${c4} ,'
1440 ${c4} '${c7};${c4}' '${c7};${c4}'
1441 EOF
1442 ;;
1443
1444 ([Mm][Xx]*)
1445 read_ascii <<-EOF
1446 ${c7} \\\\ /
1447 ${c7} \\\\/
1448 ${c7} \\\\
1449 ${c7} /\\/ \\\\
1450 ${c7} / \\ /\\
1451 ${c7} / \\/ \\
1452 ${c7}/__________\\
1453 EOF
1454 ;;
1455
1456 ([Nn]et[Bb][Ss][Dd]*)
1457 read_ascii 3 <<-EOF
1458 ${c7}\\\\${c3}\`-______,----__
1459 ${c7} \\\\ ${c3}__,---\`_
1460 ${c7} \\\\ ${c3}\`.____
1461 ${c7} \\\\${c3}-______,----\`-
1462 ${c7} \\\\
1463 ${c7} \\\\
1464 ${c7} \\\\
1465 EOF
1466 ;;
1467
1468 ([Nn]ix[Oo][Ss]*)
1469 read_ascii 4 <<-EOF
1470 ${c4} \\\\ \\\\ //
1471 ${c4} ==\\\\__\\\\/ //
1472 ${c4} // \\\\//
1473 ${c4}==// //==
1474 ${c4} //\\\\___//
1475 ${c4}// /\\\\ \\\\==
1476 ${c4} // \\\\ \\\\
1477 EOF
1478 ;;
1479
1480 ([Oo]pen[Bb][Ss][Dd]*)
1481 read_ascii 3 <<-EOF
1482 ${c3} _____
1483 ${c3} \\- -/
1484 ${c3} \\_/ \\
1485 ${c3} | ${c7}O O${c3} |
1486 ${c3} |_ < ) 3 )
1487 ${c3} / \\ /
1488 ${c3} /-_____-\\
1489 EOF
1490 ;;
1491
1492 ([Oo]pen[Ss][Uu][Ss][Ee]*[Tt]umbleweed*)
1493 read_ascii 2 <<-EOF
1494 ${c2} _____ ______
1495 ${c2} / ____\\ / ____ \\
1496 ${c2}/ / \`/ / \\ \\
1497 ${c2}\\ \\____/ /,____/ /
1498 ${c2} \\______/ \\_____/
1499 EOF
1500 ;;
1501
1502 ([Oo]pen[Ss][Uu][Ss][Ee]*|[Oo]pen*SUSE*|SUSE*|suse*)
1503 read_ascii 2 <<-EOF
1504 ${c2} _______
1505 ${c2}__| __ \\
1506 ${c2} / .\\ \\
1507 ${c2} \\__/ |
1508 ${c2} _______|
1509 ${c2} \\_______
1510 ${c2}__________/
1511 EOF
1512 ;;
1513
1514 ([Oo]pen[Ww]rt*)
1515 read_ascii 1 <<-EOF
1516 ${c1} _______
1517 ${c1}| |.-----.-----.-----.
1518 ${c1}| - || _ | -__| |
1519 ${c1}|_______|| __|_____|__|__|
1520 ${c1} ________|__| __
1521 ${c1}| | | |.----.| |_
1522 ${c1}| | | || _|| _|
1523 ${c1}|________||__| |____|
1524 EOF
1525 ;;
1526
1527 ([Pp]arabola*)
1528 read_ascii 5 <<-EOF
1529 ${c5} __ __ __ _
1530 ${c5}.\`_//_//_/ / \`.
1531 ${c5} / .\`
1532 ${c5} / .\`
1533 ${c5} /.\`
1534 ${c5} /\`
1535 EOF
1536 ;;
1537
1538 ([Pp]op!_[Oo][Ss]*)
1539 read_ascii 6 <<-EOF
1540 ${c6}______
1541 ${c6}\\ _ \\ __
1542 ${c6}\\ \\ \\ \\ / /
1543 ${c6}\\ \\_\\ \\ / /
1544 ${c6}\\ ___\\ /_/
1545 ${c6} \\ \\ _
1546 ${c6} __\\_\\__(_)_
1547 ${c6}(___________)
1548 EOF
1549 ;;
1550
1551 ([Pp]ure[Oo][Ss]*)
1552 read_ascii <<-EOF
1553 ${c7} _____________
1554 ${c7}| _________ |
1555 ${c7}| | | |
1556 ${c7}| | | |
1557 ${c7}| |_________| |
1558 ${c7}|_____________|
1559 EOF
1560 ;;
1561
1562 ([Rr]aspbian*)
1563 read_ascii 1 <<-EOF
1564 ${c2} __ __
1565 ${c2} (_\\)(/_)
1566 ${c1} (_(__)_)
1567 ${c1}(_(_)(_)_)
1568 ${c1} (_(__)_)
1569 ${c1} (__)
1570 EOF
1571 ;;
1572
1573 ([Ss]lackware*)
1574 read_ascii 4 <<-EOF
1575 ${c4} ________
1576 ${c4} / ______|
1577 ${c4} | |______
1578 ${c4} \\______ \\
1579 ${c4} ______| |
1580 ${c4}| |________/
1581 ${c4}|____________
1582 EOF
1583 ;;
1584
1585 ([Ss]un[Oo][Ss]|[Ss]olaris*)
1586 read_ascii 3 <<-EOF
1587 ${c3} . .; .
1588 ${c3} . :; :: ;: .
1589 ${c3} .;. .. .. .;.
1590 ${c3}.. .. .. ..
1591 ${c3} .;, ,;.
1592 EOF
1593 ;;
1594
1595 ([Uu]buntu*)
1596 read_ascii 3 <<-EOF
1597 ${c3} _
1598 ${c3} ---(_)
1599 ${c3} _/ --- \\
1600 ${c3}(_) | |
1601 ${c3} \\ --- _/
1602 ${c3} ---(_)
1603 EOF
1604 ;;
1605
1606 ([Vv]oid*)
1607 read_ascii 2 <<-EOF
1608 ${c2} _______
1609 ${c2} _ \\______ -
1610 ${c2}| \\ ___ \\ |
1611 ${c2}| | / \ | |
1612 ${c2}| | \___/ | |
1613 ${c2}| \\______ \\_|
1614 ${c2} -_______\\
1615 EOF
1616 ;;
1617
1618 (*)
1619
1620
1621
1622 [ "$1" ] || {
1623 get_ascii "$os"
1624 return
1625 }
1626
1627 printf 'error: %s is not currently supported.\n' "$os" >&6
1628 printf 'error: Open an issue for support to be added.\n' >&6
1629 exit 1
1630 ;;
1631 esac
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641 while read -r line; do
1642 ascii_height=$((${ascii_height:-0} + 1))
1643
1644
1645
1646 [ "${#line}" -gt "${ascii_width:-0}" ] &&
1647 ascii_width=${#line}
1648
1649
1650
1651
1652
1653 done <<-EOF
1654 $(printf %s "$ascii" | sed 's/\[3.m//g')
1655 EOF
1656
1657
1658 ascii_width=$((ascii_width + 4))
1659
1660
1661
1662 {
1663 esc_p SGR 1
1664 printf '%s' "$ascii"
1665 esc_p SGR 0
1666 esc_p CUU "$ascii_height"
1667 } >&6
1668 }
1669
1670 main() {
1671 [ "$1" = --version ] && {
1672 printf 'pfetch 0.7.0\n'
1673 exit 0
1674 }
1675
1676
1677
1678 [ "$1" = -v ] || {
1679 exec 2>/dev/null
1680 }
1681
1682
1683
1684 exec 6>&1 >/dev/null
1685
1686
1687 esc_c=$(printf '\033')
1688
1689
1690
1691
1692 . "${PF_SOURCE:-/dev/null}" ||:
1693
1694
1695
1696
1697 [ -w "${TMPDIR:-/tmp}" ] || export TMPDIR=~
1698
1699
1700
1701
1702 for _c in c1 c2 c3 c4 c5 c6 c7 c8; do
1703 esc SGR "3${_c#?}" 0
1704 export "$_c=$e"
1705 done
1706
1707
1708
1709
1710 esc_p DECAWM l >&6
1711 trap 'esc_p DECAWM h >&6' EXIT
1712
1713
1714
1715
1716 read -r os kernel arch <<-EOF
1717 $(uname -srm)
1718 EOF
1719
1720
1721
1722 get_os
1723
1724
1725
1726
1727 {
1728
1729
1730 set -f
1731 set +f -- ${PF_INFO-ascii title os host kernel uptime pkgs memory}
1732
1733
1734
1735
1736 for info do
1737 command -v "get_$info" >/dev/null || continue
1738
1739
1740
1741 [ "${#info}" -gt "${info_length:-0}" ] &&
1742 info_length=${#info}
1743 done
1744
1745
1746 info_length=$((info_length + 1))
1747
1748
1749 for info do
1750 "get_$info"
1751 done
1752 }
1753
1754
1755
1756
1757
1758
1759
1760 [ "${info_height:-0}" -lt "${ascii_height:-0}" ] &&
1761 cursor_pos=$((ascii_height - info_height))
1762
1763
1764
1765
1766 while [ "${i:=0}" -le "${cursor_pos:-0}" ]; do
1767 printf '\n'
1768 i=$((i + 1))
1769 done >&6
1770 }
1771
1772 main "$@"
|