From 4cfef9c1e4f3d8df75f629c2ee6292a5a56b5944 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 9 Mar 2020 12:27:53 +0200 Subject: [PATCH 1/8] pfetch: Initial IRIX support. --- pfetch | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/pfetch b/pfetch index 9baf21f..b8e2fd7 100755 --- a/pfetch +++ b/pfetch @@ -218,7 +218,7 @@ get_kernel() { case $os in # Don't print kernel output on some systems as the # OS name includes it. - *BSD*|Haiku|Minix) ;; + *BSD*|Haiku|Minix|IRIX*) ;; *) # '$kernel' is the cached output of 'uname -r'. @@ -336,6 +336,10 @@ get_uptime() { $(kstat -p unix:0:system_misc:snaptime) EOF ;; + + IRIX*) + # TODO + ;; esac # Convert the uptime from seconds into days, hours and minutes. @@ -447,6 +451,11 @@ get_pkgs() { has pkginfo && pkginfo -i has pkg && pkg list ;; + + IRIX*) + # TODO: result - 3. + versions -b + ;; esac | wc -l ` @@ -630,6 +639,10 @@ get_memory() { mem_free=$((pages_free * hw_pagesize / 1024 / 1024)) mem_used=$((mem_full - mem_free)) ;; + + IRIX*) + # TODO + ;; esac log memory "${mem_used:-?}M / ${mem_full:-?}M" @@ -1035,6 +1048,13 @@ get_ascii() { EOF ;; + [Ii]rix*) + read_ascii 4 <<-EOF + TODO + EOF + ;; + + [Ll]inux*[Ll]ite*|[Ll]ite*) read_ascii 3 <<-EOF ${c3} /\\ From be111026b19e09ece03a964ccff9c1e67dadf30a Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 9 Mar 2020 12:30:11 +0200 Subject: [PATCH 2/8] ascii: Remove blank line --- pfetch | 1 - 1 file changed, 1 deletion(-) diff --git a/pfetch b/pfetch index b8e2fd7..41f07b6 100755 --- a/pfetch +++ b/pfetch @@ -1054,7 +1054,6 @@ get_ascii() { EOF ;; - [Ll]inux*[Ll]ite*|[Ll]ite*) read_ascii 3 <<-EOF ${c3} /\\ From b2aac93208b8a93edaff96f26b8dc6c4bfb0af4d Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 9 Mar 2020 22:48:23 +0200 Subject: [PATCH 3/8] irix: Memory usage --- pfetch | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/pfetch b/pfetch index 41f07b6..69b08b7 100755 --- a/pfetch +++ b/pfetch @@ -641,7 +641,24 @@ get_memory() { ;; IRIX*) - # TODO + # Read the memory information from the 'top' command. Parse + # and split each line until we reach the line starting with + # "Memory". + # + # Example output: Memory: 160M max, 147M avail, ..... + while IFS=' :' read -r label mem_full _ mem_free _; do + case $label in + Memory) + mem_full=${mem_full%M} + mem_free=${mem_free%M} + break + ;; + esac + done <<-EOF + $(top -n) + EOF + + mem_used=$((mem_full - mem_free)) ;; esac From 39f767e45bc8e81609a67157bdb46c5819be345f Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 9 Mar 2020 22:57:10 +0200 Subject: [PATCH 4/8] irix: Uptime support. --- pfetch | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/pfetch b/pfetch index 69b08b7..c7dbd09 100755 --- a/pfetch +++ b/pfetch @@ -338,7 +338,22 @@ get_uptime() { ;; IRIX*) - # TODO + # Grab the uptime in a pretty format. Usually, + # 00:00:00 from the 'ps' command. + t=$(LC_ALL=POSIX ps -o etime= -p 1) + + # Split the pretty output into days or hours + # based on the uptime. + case $t in + *-*) d=${t%%-*} t=${t#*-} ;; + *:*:*) h=${t%%:*} t=${t#*:} ;; + esac + + h=${h#0} t=${t#0} + + # Convert the split pretty fields back into + # seconds so we may re-convert them to our format. + s=$((${d:-0}*86400 + ${h:-0}*3600 + ${t%%:*}*60 + ${t#*:})) ;; esac From e2068c61d5f0d3408745bc322847413dac736fd0 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 9 Mar 2020 23:07:42 +0200 Subject: [PATCH 5/8] IRIX: Packages support --- pfetch | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/pfetch b/pfetch index c7dbd09..d32a9b2 100755 --- a/pfetch +++ b/pfetch @@ -218,7 +218,7 @@ get_kernel() { case $os in # Don't print kernel output on some systems as the # OS name includes it. - *BSD*|Haiku|Minix|IRIX*) ;; + *BSD*|Haiku|Minix|IRIX) ;; *) # '$kernel' is the cached output of 'uname -r'. @@ -337,7 +337,7 @@ get_uptime() { EOF ;; - IRIX*) + IRIX) # Grab the uptime in a pretty format. Usually, # 00:00:00 from the 'ps' command. t=$(LC_ALL=POSIX ps -o etime= -p 1) @@ -467,13 +467,18 @@ get_pkgs() { has pkg && pkg list ;; - IRIX*) - # TODO: result - 3. + IRIX) versions -b ;; esac | wc -l ` + case $os in + # IRIX's package manager adds 3 lines of extra + # output which we must account for here. + IRIX) packages=$((packages - 3)) ;; + esac + [ "$packages" -gt 1 ] && log pkgs "$packages" } @@ -655,7 +660,7 @@ get_memory() { mem_used=$((mem_full - mem_free)) ;; - IRIX*) + IRIX) # Read the memory information from the 'top' command. Parse # and split each line until we reach the line starting with # "Memory". From 177d77c33523380a9ab5f7d920170c9488b6034b Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 9 Mar 2020 23:25:30 +0200 Subject: [PATCH 6/8] irix: Fix support --- pfetch | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pfetch b/pfetch index d32a9b2..2753301 100755 --- a/pfetch +++ b/pfetch @@ -1085,9 +1085,15 @@ get_ascii() { EOF ;; - [Ii]rix*) + [Ii][Rr][Ii][Xx]*) read_ascii 4 <<-EOF TODO + TODO + TODO + TODO + TODO + TODO + TODO EOF ;; From 6558b34254d9eb6b974e96e410555435b13e52f1 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 9 Mar 2020 23:41:13 +0200 Subject: [PATCH 7/8] irix: kernel information --- pfetch | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pfetch b/pfetch index 4058c39..2c8ee97 100755 --- a/pfetch +++ b/pfetch @@ -25,7 +25,7 @@ log() { # Construct the information string. out="[3${PF_COL1-4};1m${name}" out="$out${PF_SEP}[$((info_length-${#name}))C" - out="$out[3${PF_COL2-7}m${info}" + out="$out[3${PF_COL2-7}m${info:-?}" } get_title() { @@ -216,7 +216,12 @@ get_kernel() { case $os in # Don't print kernel output on some systems as the # OS name includes it. - *BSD*|Haiku|Minix|IRIX) ;; + *BSD*|Haiku|Minix) ;; + + IRIX) + kernel=$(uname -vR) + kernel=${kernel#* } + ;; *) # '$kernel' is the cached output of 'uname -r'. From 577e8483a787434f90f2843081eda706828174ea Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Tue, 10 Mar 2020 00:06:06 +0200 Subject: [PATCH 8/8] irix: ASCII --- pfetch | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/pfetch b/pfetch index 2c8ee97..5c1565a 100755 --- a/pfetch +++ b/pfetch @@ -25,7 +25,7 @@ log() { # Construct the information string. out="[3${PF_COL1-4};1m${name}" out="$out${PF_SEP}[$((info_length-${#name}))C" - out="$out[3${PF_COL2-7}m${info:-?}" + out="$out[3${PF_COL2-7}m$info" } get_title() { @@ -216,7 +216,9 @@ get_kernel() { case $os in # Don't print kernel output on some systems as the # OS name includes it. - *BSD*|Haiku|Minix) ;; + *BSD*|Haiku|Minix) + log kernel "?" + ;; IRIX) kernel=$(uname -vR) @@ -1089,14 +1091,14 @@ get_ascii() { ;; [Ii][Rr][Ii][Xx]*) - read_ascii 4 <<-EOF - TODO - TODO - TODO - TODO - TODO - TODO - TODO + read_ascii 1 <<-EOF + ${c1} __ + ${c1} \\ \\ __ + ${c1} \\ \\ / / + ${c1} \\ v / + ${c1} / . \\ + ${c1} /_/ \\ \\ + ${c1} \\_\\ EOF ;;