forked from fuck2ky/Arch_install
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfetch
829 lines (678 loc) · 27.8 KB
/
fetch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
#!/usr/bin/env bash
# Copyright (c) 2019 Erik Dubois
# Copyright (c) 2019 Brad Heffernan
# Copyright (c) 2016-2018 Dylan Araps
# parts are coming from neofetch
# e.g. terminal font code
# and unknown sources
# The MIT License (MIT)
#
# Copyright (c) 2016-2018 Dylan Araps, Erik Dubois, Brad Heffernan
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-${HOME}/.config}"
get_packages(){
has() { type -p "$1" >/dev/null && manager="$_"; }
dir() { ((packages+=$#)); pac "$#"; }
pac() { (($1 > 0)) && { managers+=("$1 (${manager})"); manager_string+="${manager}, "; }; }
tot() { IFS=$'\n' read -d "" -ra pkgs < <("$@");((packages+="${#pkgs[@]}"));pac "${#pkgs[@]}"; }
# Package Manager Programs.
has "pacman-key" && tot pacman -Qq --color never
has "dpkg" && tot dpkg-query -f '.\n' -W
has "rpm" && tot rpm -qa
has "xbps-query" && tot xbps-query -l
has "apk" && tot apk info
has "opkg" && tot opkg list-installed
has "pacman-g2" && tot pacman-g2 -Q
has "lvu" && tot lvu installed
has "tce-status" && tot tce-status -i
has "pkg_info" && tot pkg_info
has "tazpkg" && tot tazpkg list && ((packages-=6))
has "sorcery" && tot gaze installed
has "alps" && tot alps showinstalled
has "butch" && tot butch list
# Counting files/dirs.
has "emerge" && dir /var/db/pkg/*/*/
has "nix-env" && dir /nix/store/*/
has "guix" && dir /gnu/store/*/
has "Compile" && dir /Programs/*/
has "eopkg" && dir /var/lib/eopkg/package/*
has "crew" && dir /usr/local/etc/crew/meta/*.filelist
has "pkgtool" && dir /var/log/packages/*
has "cave" && dir /var/db/paludis/repositories/cross-installed/*/data/*/ \
/var/db/paludis/repositories/installed/data/*/
# Other (Needs complex command)
has "kpm-pkg" && ((packages+="$(kpm --get-selections | grep -cv deinstall$)"))
case "$kernel_name" in
"FreeBSD") has "pkg" && tot pkg info ;;
"SunOS") has "pkginfo" && tot pkginfo -i ;;
*)
has "pkg" && dir /var/db/pkg/*
((packages == 0)) && \
has "pkg" && tot pkg list
;;
esac
# List these last as they accompany regular package managers.
has "flatpak" && tot flatpak list
# Snap hangs if the command is run without the daemon running.
# Only run snap if the daemon is also running.
has "snap" && ps -e | grep -qFm 1 "snapd" >/dev/null && tot snap list && ((packages-=1))
if ((packages == 0)); then
unset packages
else
packages+=" (${manager_string%,*})"
fi
packages="${packages/pacman-key/pacman}"
packages="${packages/nix-env/nix}"
echo "$packages"
}
#{{{ MEMORY
get_mem(){
while IFS=":" read -r a b; do
case "$a" in
"MemTotal") mem_used="$((mem_used+=${b/kB}))"; mem_total="${b/kB}" ;;
"Shmem") mem_used="$((mem_used+=${b/kB}))" ;;
"MemFree" | "Buffers" | "Cached" | "SReclaimable")
mem_used="$((mem_used-=${b/kB}))"
;;
esac
done < /proc/meminfo
mem_used="$((mem_used / 1024))"
mem_total="$((mem_total / 1024))"
memory="${mem_used}${mem_label:-MiB} / ${mem_total}${mem_label:-MiB}"
echo "$memory"
}
#}}}
#{{{ UPTIME
strip_date() {
case "$1" in
"0 "*) unset "${1/* }" ;;
"1 "*) printf "%s" "${1/s}" ;;
*) printf "%s" "$1" ;;
esac
}
get_uptime(){
seconds=`< /proc/uptime`
seconds="${seconds/.*}"
days="$((seconds / 60 / 60 / 24)) days"
hours="$((seconds / 60 / 60 % 24)) hours"
mins="$((seconds / 60 % 60)) minutes"
# Remove plural if < 2.
((${days/ *} == 1)) && days="${days/s}"
((${hours/ *} == 1)) && hours="${hours/s}"
((${mins/ *} == 1)) && mins="${mins/s}"
# Hide empty fields.
((${days/ *} == 0)) && unset days
((${hours/ *} == 0)) && unset hours
((${mins/ *} == 0)) && unset mins
uptime="${days:+$days, }${hours:+$hours, }${mins}"
uptime="${uptime%', '}"
uptime="${uptime:-${seconds} seconds}"
uptime="${uptime/ days/d}"
uptime="${uptime/ day/d}"
uptime="${uptime/ hours/h}"
uptime="${uptime/ hour/h}"
uptime="${uptime/ minutes/m}"
uptime="${uptime/ minute/m}"
uptime="${uptime/ seconds/s}"
uptime="${uptime//,}"
echo "$uptime"
}
#}}}
#{{{ GPU
get_gpu(){
gpu_cmd="$(lspci -mm | awk -F '\"|\" \"|\\(' \
'/"Display|"3D|"VGA/ {a[$0] = $3 " " $4} END {for(i in a)
{if(!seen[a[i]]++) print a[i]}}')"
IFS=$'\n' read -d "" -ra gpus <<< "$gpu_cmd"
[[ "${gpus[0]}" == *Intel* && "${gpus[1]}" == *Intel* ]] && unset -v "gpus[0]"
for gpu in "${gpus[@]}"; do
case "$gpu" in
*"AMD"*)
brand="${gpu/*AMD*ATI*/AMD ATI}"
brand="${brand:-${gpu/*AMD*/AMD}}"
brand="${brand:-${gpu/*ATI*/ATi}}"
gpu="${gpu/'[AMD/ATI]' }"
gpu="${gpu/'[AMD]' }"
gpu="${gpu/OEM }"
gpu="${gpu/Advanced Micro Devices, Inc.}"
gpu="${gpu/ \/ *}"
gpu="${gpu/*\[}"
gpu="${gpu/\]*}"
gpu="$brand $gpu"
;;
*"nvidia"*)
gpu="${gpu/*\[}"
gpu="${gpu/\]*}"
gpu="NVIDIA $gpu"
;;
*"intel"*)
gpu="${gpu/*Intel/Intel}"
gpu="${gpu/'(R)'}"
gpu="${gpu/'Corporation'}"
gpu="${gpu/ \(*}"
gpu="${gpu/Integrated Graphics Controller}"
[[ -z "$(trim "$gpu")" ]] && gpu="Intel Integrated Graphics"
;;
*"virtualbox"*)
gpu="VirtualBox Graphics Adapter"
;;
esac
done
gpu="${gpu/AMD }"
gpu="${gpu/NVIDIA }"
gpu="${gpu/Intel }"
echo "$gpu"
}
#gpu="$(glxinfo | grep -F 'OpenGL renderer string')"
#gpu="${gpu/'OpenGL renderer string: '}"
#gpu="${gpu/(*}"
#}}}
#{{{ SYSTEM
get_shell(){
shell="${SHELL##*/} "
case "${shell_name:=${SHELL##*/}}" in
"bash") shell+="${BASH_VERSION/-*}" ;;
"sh" | "ash" | "dash") ;;
"mksh" | "ksh")
shell+="$("$SHELL" -c "printf %s \$KSH_VERSION")"
shell="${shell/ * KSH}"
shell="${shell/version}"
;;
"tcsh")
shell+="$("$SHELL" -c "printf %s \$tcsh")"
;;
*)
shell+="$("$SHELL" --version 2>&1)"
shell="${shell/ "${shell_name}"}"
;;
esac
# Remove unwanted info.
shell="${shell/, version}"
shell="${shell/xonsh\//xonsh }"
shell="${shell/options*}"
shell="${shell/\(*\)}"
echo "$shell"
}
get_cpu(){
cpu_file="/proc/cpuinfo"
speed_type="bios_limit"
cpu_cores="physical"
case "$kernel_machine" in
"frv" | "hppa" | "m68k" | "openrisc" | "or"* | "powerpc" | "ppc"* | "sparc"*)
cpu="$(awk -F':' '/^cpu\t|^CPU/ {printf $2; exit}' "$cpu_file")"
;;
"s390"*)
cpu="$(awk -F'=' '/machine/ {print $4; exit}' "$cpu_file")"
;;
"ia64" | "m32r")
cpu="$(awk -F':' '/model/ {print $2; exit}' "$cpu_file")"
[[ -z "$cpu" ]] && cpu="$(awk -F':' '/family/ {printf $2; exit}' "$cpu_file")"
;;
*)
cpu="$(awk -F ': | @' '/model name|Processor|^cpu model|chip type|^cpu type/ {
printf $2;
exit
}' "$cpu_file")"
[[ "$cpu" == *"processor rev"* ]] && \
cpu="$(awk -F':' '/Hardware/ {print $2; exit}' "$cpu_file")"
;;
esac
speed_dir="/sys/devices/system/cpu/cpu0/cpufreq"
speed="$(awk -F ': |\\.' '/cpu MHz|^clock/ {printf $2; exit}' "$cpu_file")"
speed="${speed/MHz}"
# Get CPU cores.
cores="$(grep -c "^processor" "$cpu_file")"
#cores="$(awk '/^core id/&&!a[$0]++{++i} END {print i}' "$cpu_file")"
# Remove un-needed patterns from cpu output.
cpu="${cpu//(tm)}"
cpu="${cpu//(TM)}"
cpu="${cpu//(r)}"
cpu="${cpu//(R)}"
cpu="${cpu//CPU}"
cpu="${cpu//Processor}"
cpu="${cpu//Dual-Core}"
cpu="${cpu//Quad-Core}"
cpu="${cpu//Six-Core}"
cpu="${cpu//Eight-Core}"
cpu="${cpu//, * Compute Cores*}"
cpu="${cpu//, * COMPUTE CORES*}"
cpu="${cpu//Core / }"
cpu="${cpu//(\"AuthenticAMD\"*)}"
cpu="${cpu//with Radeon * Graphics}"
cpu="${cpu//, altivec supported}"
cpu="${cpu//FPU*}"
cpu="${cpu//Chip Revision*}"
cpu="${cpu//Technologies, Inc}"
cpu="${cpu//Core2/Core 2}"
# Trim spaces from core and speed output
cores="${cores//[[:space:]]}"
speed="${speed//[[:space:]]}"
# Remove CPU brand from the output.
cpu="${cpu/AMD }"
cpu="${cpu/Intel }"
cpu="${cpu/Core? Duo }"
cpu="${cpu/Qualcomm }"
cpu="${cpu} (${cores}C)"
echo "$cpu"
}
#}}}
#{{{ ENVIROMENT
get_res(){
if type -p xrandr >/dev/null; then
resolution="$(xrandr --nograb --current |\
awk -F 'connected |\\+|\\(' \
'/ connected/ && $2 {printf $2 ", "}')"
resolution="${resolution/primary }"
resolution="${resolution//\*}"
elif type -p xwininfo >/dev/null; then
read -r w h \
< <(xwininfo -root | awk -F':' '/Width|Height/ {printf $2}')
resolution="${w}x${h}"
elif type -p xdpyinfo >/dev/null; then
resolution="$(xdpyinfo | awk '/dimensions:/ {printf $2}')"
fi
resolution="${resolution%,*}"
echo "$resolution"
}
get_wm(){
((wm_run == 1)) && return
if [[ "$DISPLAY" ]]; then
id="$(xprop -root -notype _NET_SUPPORTING_WM_CHECK)"
id="${id##* }"
if [[ "$id" != "found." ]]; then
wm="$(xprop -id "$id" -notype -len 100 -f _NET_WM_NAME 8t)"
wm="${wm/*WM_NAME = }"
wm="${wm/\"}"
wm="${wm/\"*}"
fi
# Window Maker does not set _NET_WM_NAME
[[ "$wm" =~ "WINDOWMAKER" ]] && wm="wmaker"
# Fallback for non-EWMH WMs.
[[ -z "$wm" ]] && \
wm="$(ps -e | grep -m 1 -o -F \
-e "catwm" \
-e "dwm" \
-e "2bwm" \
-e "monsterwm" \
-e "tinywm")"
fi
wm_run=1
echo "$wm"
}
trim() {
set -f
# shellcheck disable=2048,2086
set -- $*
printf '%s\n' "${*//[[:space:]]/ }"
set +f
}
trim_quotes() {
trim_output="${1//\'}"
trim_output="${trim_output//\"}"
printf "%s" "$trim_output"
}
get_ppid() {
# Get parent process ID of PID.
ppid="$(grep -i -F "PPid:" "/proc/${1:-$PPID}/status")"
ppid="$(trim "${ppid/PPid:}")"
printf "%s" "$ppid"
}
get_process_name() {
# Get PID name.
name="$(< "/proc/${1:-$PPID}/comm")"
printf "%s" "$name"
}
get_term(){
while [[ -z "$term" ]]; do
parent="$(get_ppid "$parent")"
[[ -z "$parent" ]] && break
name="$(get_process_name "$parent")"
case "${name// }" in
"${SHELL/*\/}"|*"sh"|"screen"|"su"*) ;;
"login"*|*"Login"*|"init"|"(init)")
term="$(tty)"
;;
"ruby"|"1"|"systemd"|"sshd"*|"python"*|"USER"*"PID"*|"kdeinit"*|"launchd"*)
break
;;
"gnome-terminal-") term="gnome-terminal" ;;
*"nvim") term="Neovim Terminal" ;;
*"NeoVimServer"*) term="VimR Terminal" ;;
*"tmux"*) term="tmux" ;;
*) term="${name##*/}" ;;
esac
done
# Log that the function was run.
term_run=1
echo "$term"
}
get_termfn(){
xrdb="$(xrdb -query)"
term_font="$(grep -i "${term/d}"'\**\.*font' <<< "$xrdb")"
term_font="${term_font/*"*font:"}"
term_font="${term_font/*".font:"}"
term_font="${term_font/*"*.font:"}"
term_font="$(trim "$term_font")"
[[ -z "$term_font" && "$term" == "xterm" ]] && \
term_font="$(grep '^XTerm.vt100.faceName' <<< "$xrdb")"
term_font="$(trim "${term_font/*"faceName:"}")"
# xft: isn't required at the beginning so we prepend it if it's missing
[[ "${term_font:0:1}" != "-" && \
"${term_font:0:4}" != "xft:" ]] && \
term_font="xft:$term_font"
# Xresources has two different font formats, this checks which
# one is in use and formats it accordingly.
case "$term_font" in
*"xft:"*)
term_font="${term_font/xft:}"
term_font="${term_font/:*}"
;;
"-"*)
IFS=- read -r _ _ term_font _ <<< "$term_font"
;;
esac
echo "$term_font"
}
get_kernel(){
IFS=" " read -ra uname <<< "$(uname -srm)"
unset IFS
echo "${uname[1]}"
}
get_term_font() {
((term_run != 1)) && get_term
case "$term" in
"alacritty"*)
shopt -s nullglob
confs=({$XDG_CONFIG_HOME,$HOME}/{alacritty,}/{.,}alacritty.ym?)
shopt -u nullglob
[[ -f "${confs[0]}" ]] || return
term_font="$(awk -F ':|#' '/normal:/ {getline; print}' "${confs[0]}")"
term_font="${term_font/*family:}"
term_font="${term_font/$'\n'*}"
term_font="${term_font/\#*}"
;;
"Apple_Terminal")
term_font="$(osascript <<END
tell application "Terminal" to font name of window frontmost
END
)"
;;
"iTerm2")
# Unfortunately the profile name is not unique, but it seems to be the only thing
# that identifies an active profile. There is the "id of current session of current win-
# dow" though, but that does not match to a guid in the plist.
# So, be warned, collisions may occur!
# See: https://groups.google.com/forum/#!topic/iterm2-discuss/0tO3xZ4Zlwg
local current_profile_name profiles_count profile_name diff_font
current_profile_name="$(osascript <<END
tell application "iTerm2" to profile name \
of current session of current window
END
)"
# Warning: Dynamic profiles are not taken into account here!
# https://www.iterm2.com/documentation-dynamic-profiles.html
font_file="${HOME}/Library/Preferences/com.googlecode.iterm2.plist"
# Count Guids in "New Bookmarks"; they should be unique
profiles_count="$(PlistBuddy -c "Print ':New Bookmarks:'" "$font_file" | \
grep -w -c "Guid")"
for ((i=0; i<profiles_count; i++)); do
profile_name="$(PlistBuddy -c "Print ':New Bookmarks:${i}:Name:'" "$font_file")"
if [[ "$profile_name" == "$current_profile_name" ]]; then
# "Normal Font"
term_font="$(PlistBuddy -c "Print ':New Bookmarks:${i}:Normal Font:'" \
"$font_file")"
# Font for non-ascii characters
# Only check for a different non-ascii font, if the user checked
# the "use a different font for non-ascii text" switch.
diff_font="$(PlistBuddy -c "Print ':New Bookmarks:${i}:Use Non-ASCII Font:'" \
"$font_file")"
if [[ "$diff_font" == "true" ]]; then
non_ascii="$(PlistBuddy -c "Print ':New Bookmarks:${i}:Non Ascii Font:'" \
"$font_file")"
[[ "$term_font" != "$non_ascii" ]] && \
term_font="$term_font (normal) / $non_ascii (non-ascii)"
fi
fi
done
;;
"deepin-terminal"*)
term_font="$(awk -F '=' '/font=/ {a=$2} /font_size/ {b=$2} END {print a,b}' \
"${XDG_CONFIG_HOME}/deepin/deepin-terminal/config.conf")"
;;
"GNUstep_Terminal")
term_font="$(awk -F '>|<' '/>TerminalFont</ {getline; f=$3}
/>TerminalFontSize</ {getline; s=$3} END {print f,s}' \
"${HOME}/GNUstep/Defaults/Terminal.plist")"
;;
"Hyper"*)
term_font="$(awk -F':|,' '/fontFamily/ {print $2; exit}' "${HOME}/.hyper.js")"
term_font="$(trim_quotes "$term_font")"
;;
"kitty"*)
kitty_config="$(kitty --debug-config)"
[[ "$kitty_config" != *font_family* ]] && return
term_font="$(awk '/^font_family|^font_size/ {$1="";gsub("^ *","",$0);print $0}' \
<<< "$kitty_config")"
;;
"konsole" | "yakuake")
# Get Process ID of current konsole window / tab
child="$(get_ppid "$$")"
IFS=$'\n' read -d "" -ra konsole_instances \
<<< "$(qdbus | awk '/org.kde.konsole/ {print $1}')"
for i in "${konsole_instances[@]}"; do
IFS=$'\n' read -d "" -ra konsole_sessions <<< "$(qdbus "$i" | grep -F '/Sessions/')"
for session in "${konsole_sessions[@]}"; do
if ((child == "$(qdbus "$i" "$session" processId)")); then
profile="$(qdbus "$i" "$session" environment |\
awk -F '=' '/KONSOLE_PROFILE_NAME/ {print $2}')"
break
fi
done
[[ "$profile" ]] && break
done
# We could have two profile files for the same profile name, take first match
profile_filename="$(grep -l "Name=${profile}" "$HOME"/.local/share/konsole/*.profile)"
profile_filename="${profile_filename/$'\n'*}"
[[ "$profile_filename" ]] && \
term_font="$(awk -F '=|,' '/Font=/ {print $2,$3}' "$profile_filename")"
;;
"lxterminal"*)
term_font="$(awk -F '=' '/fontname=/ {print $2; exit}' \
"${XDG_CONFIG_HOME}/lxterminal/lxterminal.conf")"
;;
"mate-terminal")
# To get the actual config we have to create a temporarily file with the
# --save-config option.
mateterm_config="/tmp/mateterm.cfg"
# Ensure /tmp exists and we do not overwrite anything.
if [[ -d "/tmp" && ! -f "$mateterm_config" ]]; then
mate-terminal --save-config="$mateterm_config"
role="$(xprop -id "${WINDOWID}" WM_WINDOW_ROLE)"
role="${role##* }"
role="${role//\"}"
profile="$(awk -F '=' -v r="$role" \
'$0~r {
getline;
if(/Maximized/) getline;
if(/Fullscreen/) getline;
id=$2"]"
} $0~id {if(id) {getline; print $2; exit}}' \
"$mateterm_config")"
rm -f "$mateterm_config"
mate_get() {
gsettings get org.mate.terminal.profile:/org/mate/terminal/profiles/"$1"/ "$2"
}
if [[ "$(mate_get "$profile" "use-system-font")" == "true" ]]; then
term_font="$(gsettings get org.mate.interface monospace-font-name)"
else
term_font="$(mate_get "$profile" "font")"
fi
term_font="$(trim_quotes "$term_font")"
fi
;;
"mintty")
term_font="$(awk -F '=' '!/^($|#)/ && /Font/ {printf $2; exit}' "${HOME}/.minttyrc")"
;;
"pantheon"*)
term_font="$(gsettings get org.pantheon.terminal.settings font)"
[[ -z "${term_font//\'}" ]] && \
term_font="$(gsettings get org.gnome.desktop.interface monospace-font-name)"
term_font="$(trim_quotes "$term_font")"
;;
"qterminal")
term_font="$(awk -F '=' '/fontFamily=/ {a=$2} /fontSize=/ {b=$2} END {print a,b}' \
"${XDG_CONFIG_HOME}/qterminal.org/qterminal.ini")"
;;
"sakura"*)
term_font="$(awk -F '=' '/^font=/ {print $2; exit}' \
"${XDG_CONFIG_HOME}/sakura/sakura.conf")"
;;
"st")
term_font="$(ps -o command= -p "$parent" | grep -F -- "-f")"
if [[ "$term_font" ]]; then
term_font="${term_font/*-f/}"
term_font="${term_font/ -*/}"
else
# On Linux we can get the exact path to the running binary through the procfs
# (in case `st` is launched from outside of $PATH) on other systems we just
# have to guess and assume `st` is invoked from somewhere in the users $PATH
[[ -L "/proc/$parent/exe" ]] && binary="/proc/$parent/exe" || binary="$(type -p st)"
# Grep the output of strings on the `st` binary for anything that looks vaguely
# like a font definition. NOTE: There is a slight limitation in this approach.
# Technically "Font Name" is a valid font. As it doesn't specify any font options
# though it is hard to match it correctly amongst the rest of the noise.
[[ -n "$binary" ]] && \
term_font="$(strings "$binary" | grep -F -m 1 \
-e "pixelsize=" \
-e "size=" \
-e "antialias=" \
-e "autohint=")"
fi
term_font="${term_font/xft:}"
term_font="${term_font/:*}"
;;
"terminology")
term_font="$(strings "${XDG_CONFIG_HOME}/terminology/config/standard/base.cfg" |\
awk '/^font\.name$/{print a}{a=$0}')"
term_font="${term_font/.pcf}"
term_font="${term_font/:*}"
;;
"termite")
[[ -f "${XDG_CONFIG_HOME}/termite/config" ]] && \
termite_config="${XDG_CONFIG_HOME}/termite/config"
term_font="$(awk -F '= ' '/\[options\]/ {
opt=1
}
/^\s*font/ {
if(opt==1) a=$2;
opt=0
} END {print a}' "/etc/xdg/termite/config" \
"$termite_config")"
;;
"urxvt" | "urxvtd" | "rxvt-unicode" | "xterm")
xrdb="$(xrdb -query)"
term_font="$(grep -im 1 -e "^${term/d}"'\**\.*font' -e '^\*font' <<< "$xrdb")"
term_font="${term_font/*"*font:"}"
term_font="${term_font/*".font:"}"
term_font="${term_font/*"*.font:"}"
term_font="$(trim "$term_font")"
[[ -z "$term_font" && "$term" == "xterm" ]] && \
term_font="$(grep '^XTerm.vt100.faceName' <<< "$xrdb")"
term_font="$(trim "${term_font/*"faceName:"}")"
# xft: isn't required at the beginning so we prepend it if it's missing
[[ "${term_font:0:1}" != "-" && "${term_font:0:4}" != "xft:" ]] && \
term_font="xft:$term_font"
# Xresources has two different font formats, this checks which
# one is in use and formats it accordingly.
case "$term_font" in
*"xft:"*)
term_font="${term_font/xft:}"
term_font="${term_font/:*}"
;;
"-"*)
IFS=- read -r _ _ term_font _ <<< "$term_font"
;;
esac
;;
"xfce4-terminal")
term_font="$(awk -F '=' '/^FontName/{a=$2}/^FontUseSystem=TRUE/{a=$0} END {print a}' \
"${XDG_CONFIG_HOME}/xfce4/terminal/terminalrc")"
[[ "$term_font" == "FontUseSystem=TRUE" ]] && \
term_font="$(gsettings get org.gnome.desktop.interface monospace-font-name)"
term_font="$(trim_quotes "$term_font")"
# Default fallback font hardcoded in terminal-preferences.c
[[ -z "$term_font" ]] && term_font="Monospace 12"
;;
esac
}
get_term_font > /dev/null 2>&1
if [ -n "$DISPLAY" ]; then
res=$(get_res)
wmname=$(get_wm)
term=$(get_term)
termfn=$term_font
else
wmname="none"
res="none"
term="none"
termfn="none"
fi
#cpuspe="`sed -n '/model\ name/s/^.*:\ //p' /proc/cpuinfo | uniq` (x`nproc`)"
system=`lsb_release -sir`
system="${system/$'\n'/ }"
birthd=`last | grep "begins" | sed 's/wtmp begins //g'`
#}}}
c00=$'\e[0;30m' #d black
c01=$'\e[0;31m' #d red
c02=$'\e[0;32m' #l green
c03=$'\e[0;33m' #d tan
c04=$'\e[0;34m' #d grey
c05=$'\e[0;35m' #d pink
c06=$'\e[0;36m' #d teal
c07=$'\e[0;37m' #d white
c08=$'\e[1;30m' #l black
c09=$'\e[1;31m' #l red
c10=$'\e[1;32m' #d brown
c11=$'\e[1;33m' #l tan
c12=$'\e[1;34m' #l blue
c13=$'\e[1;35m' #l pink
c14=$'\e[1;36m' #l teal
c15=$'\e[1;37m' #l white
f0=$'\e[0;32m'
f1=$'\e[1;37m'
f2=$'\e[0;37m'
cat << EOF
${c01}▉▉ | ${f2}System ${c08}....... $f1$system
${c09} ▉▉| ${f2}Packages ${c08}..... $f1$(get_packages)
${c07}▉▉ | ${f2}Uptime ${c08}...... $f1$(get_uptime)
${c15} ▉▉| ${f2}Resolution ${c08}.. $f1$res
${c02}▉▉ |
${c10} ▉▉| ${f2}WM ${c08}........... $f1$wmname
${c03}▉▉ | ${f2}Shell ${c08}........ $f1$(get_shell)
${c11} ▉▉| ${f2}Terminal ${c08}..... $f1$term
${c08}▉▉ | ${f2}Term Font ${c08}.... $f1$termfn
${c12} ▉▉|
${c05}▉▉ | ${f2}Kernel ${c08}....... $f1$(get_kernel)
${c13} ▉▉| ${f2}Processor ${c08}.... $f1$(get_cpu)
${c06}▉▉ | ${f2}Gpu ${c08}.......... $f1$(get_gpu)
${c14} ▉▉|
${c07}▉▉ | ${f2}Birthday ${c08}..... $f1$birthd
${c15} ▉▉| ${f2}Memory ${c08}....... $f1$(get_mem)
EOF