From 428b73fc5acdcb579f11be28aa130fdbe87d46fa Mon Sep 17 00:00:00 2001 From: Andrew Titmuss Date: Tue, 5 Jun 2018 23:13:20 +1000 Subject: [PATCH 1/6] os: add cache_uname for Darwin (macOS/iOS) --- neofetch | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/neofetch b/neofetch index 96cd9850..c9410da7 100755 --- a/neofetch +++ b/neofetch @@ -774,7 +774,7 @@ get_os() { # $kernel_name is set in a function called cache_uname and is # just the output of "uname -s". case "$kernel_name" in - "Darwin"): "$(sw_vers -productName)" ;; + "Darwin"): "$darwin_name" ;; "SunOS"): "Solaris" ;; "Haiku"): "Haiku" ;; "MINIX"): "MINIX" ;; @@ -926,9 +926,6 @@ get_distro() { ;; "Mac OS X") - osx_version="$(sw_vers -productVersion)" - osx_build="$(sw_vers -buildVersion)" - case "$osx_version" in "10.4"*) codename="Mac OS X Tiger" ;; "10.5"*) codename="Mac OS X Leopard" ;; @@ -959,7 +956,7 @@ get_distro() { ;; "iPhone OS") - distro="iOS $(sw_vers -productVersion)" + distro="iOS $osx_version" # "uname -m" doesn't print architecture on iOS so we force it off. os_arch="off" @@ -4161,6 +4158,14 @@ cache_uname() { kernel_name="${uname[0]}" kernel_version="${uname[1]}" kernel_machine="${uname[2]}" + + if [[ "$kernel_name" == "Darwin" ]]; then + IFS=$'\n' read -d "" -ra sw_vers < <(awk -F'<|>' '/string/ {print $3}' \ + "/System/Library/CoreServices/SystemVersion.plist") + darwin_name="${sw_vers[2]}" + osx_version="${sw_vers[3]}" + osx_build="${sw_vers[0]}" + fi } get_ppid() { From e7645597e1d72198a3dfca2df7ada100562384cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Birger=20J=2E=20Nord=C3=B8lum?= Date: Tue, 5 Jun 2018 19:33:20 +0200 Subject: [PATCH 2/6] awk: Space around END --- neofetch | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/neofetch b/neofetch index c9410da7..781bedd6 100755 --- a/neofetch +++ b/neofetch @@ -1777,7 +1777,7 @@ get_cpu() { # Get CPU cores. case "$cpu_cores" in "logical" | "on") cores="$(grep -c "^processor" "$cpu_file")" ;; - "physical") cores="$(awk '/^core id/&&!a[$0]++{++i}END{print i}' "$cpu_file")" ;; + "physical") cores="$(awk '/^core id/&&!a[$0]++{++i} END {print i}' "$cpu_file")" ;; esac ;; @@ -2024,7 +2024,7 @@ get_gpu() { "Linux") # Read GPUs into array. gpu_cmd="$(lspci -mm | awk -F '\\"|\\" \\"|\\(' \ - '/"Display|"3D|"VGA/ {a[$0] = $3 " " $4} END{for(i in a) + '/"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" @@ -2229,13 +2229,13 @@ get_memory() { ;; "OpenBSD"*) ;; - *) mem_free="$(($(vmstat | awk 'END{printf $5}') / 1024))" ;; + *) mem_free="$(($(vmstat | awk 'END {printf $5}') / 1024))" ;; esac # Mem used. case "$kernel_name" in "OpenBSD"*) - mem_used="$(vmstat | awk 'END{printf $3}')" + mem_used="$(vmstat | awk 'END {printf $3}')" mem_used="${mem_used/M}" ;; @@ -2405,18 +2405,18 @@ get_song() { "banshee"*) song="$(banshee --query-artist --query-album --query-title |\ awk -F':' '/^artist/ {a=$2} /^album/ {b=$2} /^title/ {t=$2} - END{print a " \n " b " \n "t}')" + END {print a " \n " b " \n "t}')" ;; "amarok"*) song="$(qdbus org.kde.amarok /Player GetMetadata |\ awk -F':' '/^artist:/ {a=$2} /^album:/ {b=$2} /^title:/ {t=$2} - END{print a " \n " b " \n " t}')" + END {print a " \n " b " \n " t}')" ;; "pragha"*) song="$(pragha -c | awk -F':' '/^artist/ {a=$2} /^album/ {b=$2} /^title/ {t=$2} - END{print a " \n " b " \n " t}')" + END {print a " \n " b " \n " t}')" ;; "exaile"*) @@ -2429,7 +2429,7 @@ get_song() { song="$(dbus-send --print-reply --dest=net.sacredchao.QuodLibet \ /net/sacredchao/QuodLibet net.sacredchao.QuodLibet.CurrentSong |\ awk -F'"' '/artist/ {getline; a=$2} /album/ {getline; b=$2} - /title/ {getline; t=$2} END{print a " \n " b " \n " t}')" + /title/ {getline; t=$2} END {print a " \n " b " \n " t}')" ;; "pogo"*) @@ -2837,13 +2837,13 @@ END ;; "deepin-terminal"*) - term_font="$(awk -F '=' '/font=/ {a=$2} /font_size/ {b=$2} END{print a " " b}' \ + 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 '>|<' '/>TerminalFontTerminalFontSizeTerminalFontSize Date: Wed, 6 Jun 2018 18:02:07 +0200 Subject: [PATCH 3/6] misc: indent --- neofetch | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/neofetch b/neofetch index 781bedd6..3d5c2cc3 100755 --- a/neofetch +++ b/neofetch @@ -1568,7 +1568,7 @@ get_wm_theme() { "Sawfish") wm_theme="$(awk -F '\\(quote|\\)' '/default-frame-style/ {print $(NF-4)}' \ - "${HOME}/.sawfish/custom")" + "${HOME}/.sawfish/custom")" ;; "Cinnamon" | "Muffin" | "Mutter (Muffin)") @@ -2405,13 +2405,13 @@ get_song() { "banshee"*) song="$(banshee --query-artist --query-album --query-title |\ awk -F':' '/^artist/ {a=$2} /^album/ {b=$2} /^title/ {t=$2} - END {print a " \n " b " \n "t}')" + END {print a " \n " b " \n "t}')" ;; "amarok"*) song="$(qdbus org.kde.amarok /Player GetMetadata |\ awk -F':' '/^artist:/ {a=$2} /^album:/ {b=$2} /^title:/ {t=$2} - END {print a " \n " b " \n " t}')" + END {print a " \n " b " \n " t}')" ;; "pragha"*) @@ -2922,7 +2922,7 @@ END if(/Fullscreen/) getline; id=$2"]" } $0~id {if(id) {getline; print $2; exit}}' \ - "$mateterm_config")" + "$mateterm_config")" rm -f "$mateterm_config" From 059239d2a7d90448fc99bb0079501bb9ea324b64 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Thu, 7 Jun 2018 13:47:13 +0200 Subject: [PATCH 4/6] song: use get_song_dbus for pragha --- neofetch | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/neofetch b/neofetch index 3d5c2cc3..a0059a6d 100755 --- a/neofetch +++ b/neofetch @@ -2369,6 +2369,7 @@ get_song() { "audacious"*) get_song_dbus "audacious" ;; "vlc"*) get_song_dbus "vlc" ;; "gmusicbrowser"*) get_song_dbus "gmusicbrowser" ;; + "pragha"*) get_song_dbus "pragha" ;; "cmus"*) song="$(cmus-remote -Q | awk 'BEGIN { ORS=" "}; @@ -2414,11 +2415,6 @@ get_song() { END {print a " \n " b " \n " t}')" ;; - "pragha"*) - song="$(pragha -c | awk -F':' '/^artist/ {a=$2} /^album/ {b=$2} /^title/ {t=$2} - END {print a " \n " b " \n " t}')" - ;; - "exaile"*) song="$(dbus-send --print-reply --dest=org.exaile.Exaile /org/exaile/Exaile \ org.exaile.Exaile.Query | From 26389a8423c865c97cd43d8499f340caf78c11a8 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Fri, 8 Jun 2018 13:56:45 +0200 Subject: [PATCH 5/6] song: use get_song_dbus for amarok --- neofetch | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/neofetch b/neofetch index a0059a6d..559a7b33 100755 --- a/neofetch +++ b/neofetch @@ -2370,6 +2370,7 @@ get_song() { "vlc"*) get_song_dbus "vlc" ;; "gmusicbrowser"*) get_song_dbus "gmusicbrowser" ;; "pragha"*) get_song_dbus "pragha" ;; + "amarok"*) get_song_dbus "amarok" ;; "cmus"*) song="$(cmus-remote -Q | awk 'BEGIN { ORS=" "}; @@ -2409,12 +2410,6 @@ get_song() { END {print a " \n " b " \n "t}')" ;; - "amarok"*) - song="$(qdbus org.kde.amarok /Player GetMetadata |\ - awk -F':' '/^artist:/ {a=$2} /^album:/ {b=$2} /^title:/ {t=$2} - END {print a " \n " b " \n " t}')" - ;; - "exaile"*) song="$(dbus-send --print-reply --dest=org.exaile.Exaile /org/exaile/Exaile \ org.exaile.Exaile.Query | From abe6b82fc79a5a67f33f63e4741e7d2d90b10a86 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Fri, 8 Jun 2018 14:18:56 +0200 Subject: [PATCH 6/6] song: add comment for exaile --- neofetch | 1 + 1 file changed, 1 insertion(+) diff --git a/neofetch b/neofetch index 559a7b33..94262606 100755 --- a/neofetch +++ b/neofetch @@ -2411,6 +2411,7 @@ get_song() { ;; "exaile"*) + # NOTE: Exaile >= 4.0.0 will support mpris2. song="$(dbus-send --print-reply --dest=org.exaile.Exaile /org/exaile/Exaile \ org.exaile.Exaile.Query | awk -F':|,' '{if ($6 && $8 && $4) printf $6 " \n" $8 " \n" $4}')"