The officially official Devuan Forum!

You are not logged in.

#1 2020-06-13 12:47:37

HevyDevy
Member
Registered: 2019-09-06
Posts: 358  

system info practice script

Just thought i would share this here and ask a question or two..be mindful im only learning and hope to improve.

This is just a practice script to show system info but in a very basic way, has nothing on programs like neofetch or screenfetch etc.

So below is my effort so far and just want to know if this would work on your devuan system ok. Also id like to figure out a better method of displaying the window manager instead of using wmctrl, like something in coreutils.

Anyhow, needs bash and wmctrl as a dependency and is only work for devuan, i hope wink

#!/usr/bin/env bash

titles=('\e[1;34m%-6s\e[m\t') # blue titles
line=('\e[1;31m%-37s\e[m\n') # red line

printf "\n"

printf "\t" ; echo "$(whoami)@$(hostname)"

printf  $line | tr ' ' -

printf  $titles "os:" ; cat /etc/os-release | awk 'NR==1' | sed 's/............//;s/.//;s/.$//g'

printf  $titles "kernel:" ; uname --kernel-release

printf  $titles "uptime:" ; uptime -p | sed 's/^...//g'

printf  $titles "pkgs:" ; dpkg -l | wc -l

printf  $titles "memory:" ; free -mh | awk 'NR==2 {print $3" / "$2}'

printf  $titles "wm:" ; wmctrl -m | awk 'NR==1 {print $2}'

printf  $titles "shell:" ;  echo $SHELL

printf  $titles "editor:" ; echo $EDITOR

echo $'\e7\e[2;800H\e[16D\e[7m' $(date +"%Y/%m/%d %H:%M")$'\e8'

printf "\n"

prints out this with some colors and stuff like so.

        
          user@hostname
-------------------------------------
os:     Devuan GNU/Linux 3 (beowulf)
kernel: 4.19.0-9-amd64
uptime: 1 hour, 59 minutes
pkgs:   813
memory: 721Mi / 7.7Gi
wm:     dwm
shell:  /bin/bash
editor: vim

Last edited by HevyDevy (2020-06-13 13:04:23)

Offline

#2 2020-06-13 13:06:01

HevyDevy
Member
Registered: 2019-09-06
Posts: 358  

Re: system info practice script

also trying to work on incorporating the devuan logo in ascii somehow and also display manager and de for those who use them.

Last edited by HevyDevy (2020-06-13 13:07:28)

Offline

#3 2020-06-13 13:37:40

nixer
Member
From: North Carolina, USA
Registered: 2016-11-30
Posts: 211  

Re: system info practice script

just want to know if this would work on your devuan system

It works pretty good here.  I noticed the editor line at the bottom was empty though.  Is that because I do not have a default editor configured?

-------------------------------------
os:       Devuan GNU/Linux 4 (chimaera/ceres)
kernel:    5.6.0-2-amd64
uptime:    4 hours, 15 minutes
pkgs:     2028
memory:    4.0Gi / 15Gi
wm:       Xfwm4
shell:    /bin/bash
editor:

I did have to install wmctl as it was not installed.

Last edited by nixer (2020-06-13 13:38:38)

Offline

#4 2020-06-13 14:09:10

HevyDevy
Member
Registered: 2019-09-06
Posts: 358  

Re: system info practice script

Thanks nixer,

yeah if you havent got $EDITOR configured in .bashrc i dont think the script will display editor.

just put this in your bashrc

export EDITOR='vim'

replace vim for whatever editor you like.

cheers

Offline

#5 2020-06-13 14:09:36

Marjorie
Member
From: Teignmouth, UK
Registered: 2019-06-09
Posts: 221  

Re: system info practice script

Works for me, but I had to install the wmctrl package as it's not there by default.

user@hostname
-------------------------------------
os:   	Devuan GNU/Linux 3 (beowulf)
kernel:	4.19.0-9-amd64
uptime:	22 hours, 44 minutes
pkgs: 	2102
memory:	3.1Gi / 7.8Gi
wm:   	Mutter
shell:	/bin/bash
editor:	/usr/bin/gedit

Offline

#6 2020-06-13 14:14:21

HevyDevy
Member
Registered: 2019-09-06
Posts: 358  

Re: system info practice script

Thanks Marjorie, ill see if i can get rid of that dependency on wmctrl.

Offline

#7 2020-06-13 14:22:43

fsmithred
Administrator
Registered: 2016-11-25
Posts: 2,486  

Re: system info practice script

Works here on my beowulf. I didn't feel like installing wmctrl, so I changed that line to

printf  $titles "wm:" ; basename $(cat /etc/X11/default-display-manager)

Offline

#8 2020-06-13 14:45:41

HevyDevy
Member
Registered: 2019-09-06
Posts: 358  

Re: system info practice script

fsmithred wrote:

Works here on my beowulf. I didn't feel like installing wmctrl, so I changed that line to

printf  $titles "wm:" ; basename $(cat /etc/X11/default-display-manager)

Thanks fsmithred, that would work nicely for display managers i will add that in. cheers

Offline

#9 2020-06-13 15:44:08

Head_on_a_Stick
Member
From: London
Registered: 2019-03-24
Posts: 3,125  
Website

Re: system info practice script

HevyDevy wrote:
printf  $titles "os:" ; cat /etc/os-release | awk 'NR==1' | sed 's/............//;s/.//;s/.$//g'

You don't need cat:

printf  $titles "os:" ; awk 'NR==1' /etc/os-release | sed 's/............//;s/.//;s/.$//g'

Or with awk alone:

printf  $titles "os:" ; awk -F'"' '/PRETTY/{print $2}' /etc/os-release
HevyDevy wrote:
printf  $titles "pkgs:" ; dpkg -l | wc -l

That will return a slightly larger number because the dpkg output prints an information section and also lists some non-installed packages, try this instead:

printf  $titles "pkgs:" ; dpkg -l | grep -c '^ii'

Brianna Ghey — Rest In Power

Offline

#10 2020-06-13 16:39:55

HevyDevy
Member
Registered: 2019-09-06
Posts: 358  

Re: system info practice script

Nice, thanks Hoas. I was thinking that cat was not needed.

Offline

#11 2020-06-13 17:24:56

fanderal
Member
Registered: 2017-01-14
Posts: 80  

Re: system info practice script

Works here. Installed wmctrl to show fluxbox, then saw fsmithred's edit and tried it. The difference: wmctrl capitalizes the 'F' in fluxbox, default-display-manager doesn't. wink

-------------------------------------
os:     Devuan GNU/Linux 4 (chimaera/ceres)
kernel: 5.4.0-0.bpo.2-rt-amd64
uptime: 10 days, 2 hours, 22 minutes
pkgs:   865
memory: 93Mi / 3.7Gi
wm:     fluxbox
shell:  /bin/bash
editor: nano

Offline

#12 2020-06-14 09:57:53

HevyDevy
Member
Registered: 2019-09-06
Posts: 358  

Re: system info practice script

Thanks fanderal, ive installed xdm display manager and tried that command of fsmithred but only get xdm (i have dwm as wm), must only work for lxdm, lightdm, gdm etc, what display manager are you using?

Last edited by HevyDevy (2020-06-14 09:58:34)

Offline

Board footer