From 5661475a1552cf151bf7d14754a64b3fd4e4c127 Mon Sep 17 00:00:00 2001
From: Muhammad Herdiansyah <herdiansyah@openmailbox.org>
Date: Tue, 3 Jan 2017 22:41:21 +0700
Subject: [PATCH 01/16] OS: Added initial support for AIX

---
 neofetch | 1 +
 1 file changed, 1 insertion(+)

diff --git a/neofetch b/neofetch
index aae68a3e..53bde79c 100755
--- a/neofetch
+++ b/neofetch
@@ -39,6 +39,7 @@ get_os() {
         "SunOS") os="Solaris" ;;
         "Haiku") os="Haiku" ;;
         "MINIX") os="MINIX" ;;
+        "AIX") os="AIX" ;;
         *)
             printf "%s\n" "Unknown OS detected: '$kernel_name', aborting..." >&2
             printf "%s\n" "Open an issue on GitHub to add support for your OS." >&2

From 0cfe6f36089c094501bdae8cbc0c16c46fbb9a28 Mon Sep 17 00:00:00 2001
From: Muhammad Herdiansyah <herdiansyah@openmailbox.org>
Date: Tue, 3 Jan 2017 23:12:55 +0700
Subject: [PATCH 02/16] Distro: Added support for AIX

---
 neofetch | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/neofetch b/neofetch
index 53bde79c..40a5d638 100755
--- a/neofetch
+++ b/neofetch
@@ -189,6 +189,10 @@ get_distro() {
         "Haiku")
             distro="$(uname -sv | awk '{print $1 " " $2}')"
         ;;
+
+        "AIX")
+            distro="AIX $(oslevel)"
+        ;;
     esac
 
     [[ -z "$distro" ]] && distro="$os (Unknown)"

From 4626349b4d56eeabaa8840c09891aab7cbba2829 Mon Sep 17 00:00:00 2001
From: Muhammad Herdiansyah <herdiansyah@openmailbox.org>
Date: Wed, 4 Jan 2017 09:31:55 +0700
Subject: [PATCH 03/16] CPU: Added initial support for AIX

---
 neofetch | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/neofetch b/neofetch
index 40a5d638..1df45d03 100755
--- a/neofetch
+++ b/neofetch
@@ -278,6 +278,10 @@ get_model() {
         "Solaris")
             model="$(prtconf -b | awk -F':' '/banner-name/ {printf $2}')"
         ;;
+
+        "AIX")
+            model="$(prtconf | awk -F':' '/System Model/ {printf $2}')"
+        ;;
     esac
 
     # Remove dummy OEM info.
@@ -911,6 +915,22 @@ get_cpu() {
             # Get CPU cores.
             cores="$(sysinfo -cpu | grep -c -F 'CPU #')"
         ;;
+
+        "AIX")
+            # Get CPU name.
+            cpu="$(prtconf | awk -F':' '/Processor Type/ {printf $2}')"
+
+            # Get CPU speed.
+            speed="$(prtconf | awk -F':' '/Processor Clock Speed/ {printf $2}')"
+            speed="${speed/MHz}"
+            speed="$((speed / 100))"
+
+            # Get CPU cores.
+            case "$cpu_cores" in
+                "logical" | "on") cores="$(lparstat -i | awk -F':' '/Online Virtual CPUs/ {printf $2}')" ;;
+                "physical") cores="$(lparstat -i | awk -F':' '/Active Physical CPUs/ {printf $2}')"
+            esac
+        ;;
     esac
 
     # Fix for speeds under 1ghz.

From 367a5c83b6543bc6d09183c6cb5df3ebd15ed8ba Mon Sep 17 00:00:00 2001
From: Muhammad Herdiansyah <herdiansyah@openmailbox.org>
Date: Wed, 4 Jan 2017 09:33:30 +0700
Subject: [PATCH 04/16] CPU Usage: Added initial support for AIX

---
 neofetch | 1 +
 1 file changed, 1 insertion(+)

diff --git a/neofetch b/neofetch
index 1df45d03..0e29cf87 100755
--- a/neofetch
+++ b/neofetch
@@ -1001,6 +1001,7 @@ get_cpu_usage() {
                     "Solaris") cores="$(kstat -m cpu_info | grep -c -F "chip_id")" ;;
                     "Haiku") cores="$(sysinfo -cpu | grep -c -F 'CPU #')" ;;
                     "iPhone OS") cores="${cpu/*\(}"; cores="${cores/\)*}" ;;
+                    "AIX") cores="$(lparstat -i | awk -F':' '/Online Virtual CPUs/ {printf $2}')" ;;
                 esac
             fi
 

From f419c1c50eb26444009c7b2a1cad5f16ce62784d Mon Sep 17 00:00:00 2001
From: Muhammad Herdiansyah <herdiansyah@openmailbox.org>
Date: Wed, 4 Jan 2017 09:33:54 +0700
Subject: [PATCH 05/16] GPU: Added initial support for AIX

---
 neofetch | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/neofetch b/neofetch
index 0e29cf87..4b316e96 100755
--- a/neofetch
+++ b/neofetch
@@ -1121,7 +1121,7 @@ get_gpu() {
             esac
         ;;
 
-        "BSD" | "Solaris" | "MINIX")
+        "BSD" | "Solaris" | "MINIX" | "AIX")
             case "$kernel_name" in
                 "FreeBSD"* | "DragonFly"*)
                     gpu="$(pciconf -lv | grep -B 4 -F "VGA" | grep -F "device")"

From 60ab558dec2e243313f08d297177ff8766fecf39 Mon Sep 17 00:00:00 2001
From: Muhammad Herdiansyah <herdiansyah@openmailbox.org>
Date: Wed, 4 Jan 2017 09:40:34 +0700
Subject: [PATCH 06/16] Resolution: Added support for AIX

---
 neofetch | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/neofetch b/neofetch
index 4b316e96..f08f808a 100755
--- a/neofetch
+++ b/neofetch
@@ -1315,7 +1315,7 @@ get_song() {
 
 get_resolution() {
     case "$os" in
-        "Linux" | "BSD" | "Solaris" | "MINIX")
+        "Linux" | "BSD" | "Solaris" | "MINIX" | "AIX")
             if type -p xrandr >/dev/null; then
                 case "$refresh_rate" in
                     "on") resolution="$(xrandr --nograb --current | awk 'match($0,/[0-9]*\.[0-9]*\*/) {printf $1 " @ " substr($0,RSTART,RLENGTH) "Hz, "}')" ;;

From d896c29942200692e74390d475dbcf1a76280d32 Mon Sep 17 00:00:00 2001
From: Muhammad Herdiansyah <herdiansyah@openmailbox.org>
Date: Wed, 4 Jan 2017 10:53:43 +0700
Subject: [PATCH 07/16] Local IP: Added support for AIX

---
 neofetch | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/neofetch b/neofetch
index f08f808a..23a296c0 100755
--- a/neofetch
+++ b/neofetch
@@ -1778,9 +1778,9 @@ get_battery() {
 
 get_local_ip() {
     case "$os" in
-        "Linux" | "BSD" | "Solaris")
+        "Linux" | "BSD" | "Solaris" | "AIX")
             local_ip="$(ip route get 1 | awk '{print $NF;exit}')"
-            [[ -z "$local_ip" ]] && local_ip="$(ifconfig | awk '/broadcast/ {print $2}')"
+            [[ -z "$local_ip" ]] && local_ip="$(ifconfig -a | awk '/broadcast/ {print $2; exit}')"
         ;;
 
         "MINIX")

From 2b13b8a9cd060cf8dd391c8f363fbbbedbd50ffa Mon Sep 17 00:00:00 2001
From: Muhammad Herdiansyah <herdiansyah@openmailbox.org>
Date: Wed, 4 Jan 2017 12:45:33 +0700
Subject: [PATCH 08/16] Memory: Added support for AIX

---
 neofetch | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/neofetch b/neofetch
index 23a296c0..cded7796 100755
--- a/neofetch
+++ b/neofetch
@@ -1218,6 +1218,13 @@ get_memory() {
             mem_used="$(sysinfo -mem | awk -F '\\/|)' '{print $2; exit}')"
             mem_used="$((${mem_used/max} / 1024 / 1024))"
         ;;
+
+        "AIX")
+            mem_stat=($(svmon -G -O unit=MB))
+            mem_total="${mem_stat[11]/.*}"
+            mem_free="${mem_stat[16]/.*}"
+            mem_used="$((mem_total - mem_free))"
+        ;;
     esac
     memory="${mem_used}MB / ${mem_total}MB"
 

From 141f6f12c0c1a1c12bba6bd34ec89acbb63133fe Mon Sep 17 00:00:00 2001
From: Muhammad Herdiansyah <herdiansyah@openmailbox.org>
Date: Wed, 4 Jan 2017 12:52:05 +0700
Subject: [PATCH 09/16] Uptime: Added support for AIX

---
 neofetch | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/neofetch b/neofetch
index cded7796..44456279 100755
--- a/neofetch
+++ b/neofetch
@@ -349,6 +349,14 @@ get_uptime() {
                     seconds="$(kstat -p unix:0:system_misc:snaptime | awk '{print $2}')"
                     seconds="${seconds/.*}"
                 ;;
+
+                "AIX")
+                    t="$(LC_ALL=POSIX ps -o etime= -p 1)"
+                    d="0" h="0"
+                    case "$t" in *"-"*) d="${t%%-*}"; t="${t#*-}";; esac
+                    case "$t" in *":"*":"*) h="${t%%:*}"; t="${t#*:}";; esac
+                    seconds="$((d*86400 + h*3600 + ${t%%:*}*60 + ${t#*:}))"
+                ;;
             esac
 
             days="$((seconds / 60 / 60 / 24)) days"

From 9667fccbd79838844a862ce5b9d9b06691e48001 Mon Sep 17 00:00:00 2001
From: Muhammad Herdiansyah <herdiansyah@openmailbox.org>
Date: Wed, 4 Jan 2017 13:02:09 +0700
Subject: [PATCH 10/16] Disk: Added support for AIX

---
 neofetch | 1 +
 1 file changed, 1 insertion(+)

diff --git a/neofetch b/neofetch
index 44456279..be5f6114 100755
--- a/neofetch
+++ b/neofetch
@@ -1672,6 +1672,7 @@ get_disk() {
     case "$os" in
         "Haiku") err "Disk doesn't work on Haiku due to the non-standard 'df'"; return ;;
         "Mac OS X") df_flags=(-P -h) ;;
+        "AIX") df_flags=(-P -g) ;;
         *) df_flags=(-h) ;;
     esac
 

From 79ef172623e72ff022310389fe26ef5cb93c8bc9 Mon Sep 17 00:00:00 2001
From: Muhammad Herdiansyah <herdiansyah@openmailbox.org>
Date: Mon, 9 Jan 2017 17:07:21 +0700
Subject: [PATCH 11/16] ASCII: Added ASCII art for AIX

---
 ascii/distro/aix | 20 ++++++++++++++++++++
 neofetch         |  5 +++++
 2 files changed, 25 insertions(+)
 create mode 100644 ascii/distro/aix

diff --git a/ascii/distro/aix b/ascii/distro/aix
new file mode 100644
index 00000000..8526b7c6
--- /dev/null
+++ b/ascii/distro/aix
@@ -0,0 +1,20 @@
+${c1}           `:+ssssossossss+-`
+        .oys///oyhddddhyo///sy+.
+      /yo:+hNNNNNNNNNNNNNNNNh+:oy/
+    :h/:yNNNNNNNNNNNNNNNNNNNNNNy-+h:
+  `ys.yNNNNNNNNNNNNNNNNNNNNNNNNNNy.ys
+ `h+-mNNNNNNNNNNNNNNNNNNNNNNNNNNNNm-oh
+ h+-NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN.oy
+/d`mNNNNNNN/::mNNNd::m+:/dNNNo::dNNNd`m:
+h//NNNNNNN: . .NNNh  mNo  od. -dNNNNN:+y
+N.sNNNNNN+ -N/ -NNh  mNNd.   sNNNNNNNo-m
+N.sNNNNNs  +oo  /Nh  mNNs` ` /mNNNNNNo-m
+h//NNNNh  ossss` +h  md- .hm/ `sNNNNN:+y
+:d`mNNN+/yNNNNNd//y//h//oNNNNy//sNNNd`m-
+ yo-NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNm.ss
+ `h+-mNNNNNNNNNNNNNNNNNNNNNNNNNNNNm-oy
+   sy.yNNNNNNNNNNNNNNNNNNNNNNNNNNs.yo
+    :h+-yNNNNNNNNNNNNNNNNNNNNNNs-oh-
+      :ys:/yNNNNNNNNNNNNNNNmy/:sy:
+        .+ys///osyhhhhys+///sy+.
+            -/osssossossso/-
diff --git a/neofetch b/neofetch
index be5f6114..a8dec614 100755
--- a/neofetch
+++ b/neofetch
@@ -2580,6 +2580,11 @@ get_distro_colors() {
     #
     # $ascii_distro is the same as $distro.
     case "$ascii_distro" in
+        "AIX"*)
+            set_colors 2 7
+            ascii_file="aix"
+        ;;
+
         "alpine_small")
             set_colors 4 7
             ascii_file="alpine_small"

From 8a3981bf9226c454b6c20182f0e02f472e6aa4fd Mon Sep 17 00:00:00 2001
From: Muhammad Herdiansyah <herdiansyah@openmailbox.org>
Date: Mon, 9 Jan 2017 18:48:21 +0700
Subject: [PATCH 12/16] Kernel: Stop function when OS = AIX

---
 neofetch | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/neofetch b/neofetch
index a8dec614..2b580734 100755
--- a/neofetch
+++ b/neofetch
@@ -304,6 +304,9 @@ get_title() {
 }
 
 get_kernel() {
+    # Since AIX is an integrated system, it's better to skip this function altogether
+    [[ "$os" == "AIX" ]] && return
+
     case "$kernel_shorthand" in
         "on")  kernel="$kernel_version" ;;
         "off") kernel="$kernel_name $kernel_version" ;;

From d5e35803d646e0f4eead6999c565ae9ff7d23ae7 Mon Sep 17 00:00:00 2001
From: Muhammad Herdiansyah <herdiansyah@openmailbox.org>
Date: Mon, 9 Jan 2017 18:50:28 +0700
Subject: [PATCH 13/16] CPU (Cores): Strip spaces

---
 neofetch | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/neofetch b/neofetch
index 2b580734..281d26f2 100755
--- a/neofetch
+++ b/neofetch
@@ -971,6 +971,9 @@ get_cpu() {
     cpu="${cpu//, altivec supported}"
     cpu="${cpu//FPU*}"
 
+    # Trim spaces from core output
+    cores="${cores//[[:space:]]}"
+
     # Add CPU cores to the output.
     [[ "$cpu_cores" != "off" && "$cores" ]] && \
         cpu="${cpu/@/(${cores}) @}"

From 311623359684e16347633a22c542f7bae9b4a844 Mon Sep 17 00:00:00 2001
From: Muhammad Herdiansyah <herdiansyah@openmailbox.org>
Date: Mon, 9 Jan 2017 20:46:26 +0700
Subject: [PATCH 14/16] Install Date: Disable AIX ls

---
 neofetch | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/neofetch b/neofetch
index 281d26f2..c2cb16c2 100755
--- a/neofetch
+++ b/neofetch
@@ -1865,6 +1865,7 @@ get_install_date() {
                 *) install_file="/" ;;
             esac
         ;;
+        "AIX") install_file="/var/adm/ras/bosinstlog" ;;
     esac
 
     ls_prog="$(ls --version 2>&1)"
@@ -1873,6 +1874,7 @@ get_install_date() {
         *"crtime"*) install_date="$(ls -tdcE "$install_file" | awk '{printf $6 " " $7}')" ;; # xpg4 (Solaris)
         *"ACFHLRSZ"*) install_date="$(ls -dl "$install_file" | awk '{printf $6 " " $7}')" ;; # Toybox
         *"GNU coreutils"*) install_date="$(ls -tcd --full-time "$install_file" | awk '{printf $6 " " $7}')" ;;
+        *"ACFHLNRS"*) err "Install Date doesn't work because your 'ls' does not support showing full date and time."; return ;; # AIX ls
         *) install_date="$(ls -dlctT "$install_file" | awk '{printf $9 " " $6 " "$7 " " $8}')" ;;
     esac
 

From a7842e7b75a6aafe9cb2893dcc95c73cfd0f857b Mon Sep 17 00:00:00 2001
From: Muhammad Herdiansyah <herdiansyah@openmailbox.org>
Date: Mon, 9 Jan 2017 21:02:27 +0700
Subject: [PATCH 15/16] Docs: CHANGELOG

---
 CHANGELOG.md | 1 +
 1 file changed, 1 insertion(+)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7329b38e..bc07b16d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -15,6 +15,7 @@ Neofetch now has an irc channel at `#neofetch` on Freenode. If you have any ques
 
 ## OS
 
+- Added support for AIX.
 - Added support for GNU/kFreeBSD.
 - Added support for MINIX.
 - Added support for MX.

From 8eeffc3b8cc033022505e6747b96c9fddf1933e7 Mon Sep 17 00:00:00 2001
From: Muhammad Herdiansyah <herdiansyah@openmailbox.org>
Date: Mon, 9 Jan 2017 21:42:12 +0700
Subject: [PATCH 16/16] Packages: Added support for AIX

---
 neofetch | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/neofetch b/neofetch
index c2cb16c2..8cd1578c 100755
--- a/neofetch
+++ b/neofetch
@@ -508,6 +508,11 @@ get_packages() {
         "Haiku")
             packages="$(ls -1 /boot/system/package-links | wc -l)"
         ;;
+
+        "AIX")
+            packages="$(lslpp -J -l -q | grep -cv '^#')"
+            packages="$((packages+=$(rpm -qa | wc -l)))"
+        ;;
     esac
 
     ((packages == 0)) && unset packages