Env-info? How?
Forum rules
We don't support installations in VirtualBox, VMWare, qemu or others. We ignore posts about WINE, PlayOnLinux, Steam and Skype. We don't support btrfs, lvm, UEFI, side-by-side installations with GPT or dualboot with anything newer than Windows XP.
Google your problem first. Check the Wiki. Read the existing threads. It's okay to "hijack" an existing thread, yes! If your problem is not yet covered, open a new thread. To get the quickest possible help, mention the exact release codename in your post (uname -a is a good idea, too). Due to the lack of crystal balls, attach the output of lspci -nnk if you encounter hardware problems.
We don't support installations in VirtualBox, VMWare, qemu or others. We ignore posts about WINE, PlayOnLinux, Steam and Skype. We don't support btrfs, lvm, UEFI, side-by-side installations with GPT or dualboot with anything newer than Windows XP.
Google your problem first. Check the Wiki. Read the existing threads. It's okay to "hijack" an existing thread, yes! If your problem is not yet covered, open a new thread. To get the quickest possible help, mention the exact release codename in your post (uname -a is a good idea, too). Due to the lack of crystal balls, attach the output of lspci -nnk if you encounter hardware problems.
Env-info? How?
I've noticed on some recent screenshots that folks are using "env-info" to generate "screenfetch" or "archey"-like environment info, minus the annoying (and bloated, haha) ASCII logo. Is this a BBQ tool or script that I missed somehow? Did a search and turned up nothing.
I can haz env-info?
I can haz env-info?
-
- Baconator
- Posts: 10253
- Joined: Thu Sep 16, 2010 11:03 am
- Location: Pfälzerwald
- Contact:
Re: Env-info? How?
Code: Select all
#!/bin/bash
# simple screen information script
# similar to archey and screenfetch without annoying ASCII graphics
# this script is provided with NO GUARANTEE and NO SUPPORT
# if it breaks or does not do what you want, FIX IT YOURSELF
# wm array -- add any that need to be recognized
wms=( herbstluftwm i3 blackbox kwin awesome spectrwm matwm2 wmfs karmen fvwm cwm sithwm ratpoison evilwm xfwm4 openbox fluxbox pekwm)
# define colors for color-echo
red="\e[31m"
grn="\e[32m"
ylw="\e[33m"
cyn="\e[36m"
blu="\e[34m"
prp="\e[35m"
rst="\e[0m"
TMP=$(mktemp) # make temp file
color-echo() { # print with colors
echo -e $cyn$1': '$rst$2
}
print-kernel() {
color-echo 'Kernel' "$(uname -smr)"
}
print-uptime() {
up=$(</proc/uptime)
up=${up//.*} # string before first . is seconds
days=$((${up}/86400)) # seconds divided by 86400 is days
hours=$((${up}/3600%24)) # seconds divided by 3600 mod 24 is hours
mins=$((${up}/60%60)) # seconds divided by 60 mod 60 is mins
color-echo "Uptime" "$days"'d '"$hours"'h '"$mins"'m'
}
print-shell() {
color-echo 'Shell' $SHELL
}
print-cpu() {
arm=$(grep ARM /proc/cpuinfo) # ARM procinfo uses different format
if [ "$arm" != "" ]; then
cpu=$(grep -m1 -i 'Processor' /proc/cpuinfo)
else
cpu=$(grep -m1 -i 'model name' /proc/cpuinfo)
fi
color-echo 'CPU' "${cpu#*: }" # everything after colon is processor name
}
print-disk() {
df -h / > $TMP
total=$(awk 'NR==2 { print $2 }' $TMP) # field 2 on line 2 is total
used=$(awk 'NR==2 { print $3 }' $TMP) # field 3 on line 2 is used
color-echo 'Disk' "$used / $total"
}
print-mem() {
free -h > $TMP
total=$(awk 'NR==2 { print $2 }' $TMP) # field 2 on line 2 is total
used=$(awk 'NR==3 { print $3 }' $TMP) # field 3 on line 3 is used
color-echo 'Mem' "$used / $total"
}
print-wm() {
for wm in ${wms[@]}; do # pgrep through wmname array
pid=$(pgrep -u $USER $wm) # if found, this wmname has running process
if [ "$pid" ]; then
color-echo 'WM' $wm
fi
done
}
print-de() {
if [ $(pgrep -u $USER lxsession) ]; then # if lxsession is running, assume LXDE
color-echo 'DE' 'LXDE'
elif [ $(pgrep -u $USER xfce4-session) ]; then # if xfce4-session is running, assume Xfce
color-echo 'DE' 'Xfce'
fi
}
print-distro() {
[[ -e /etc/os-release ]] && source /etc/os-release
if [ -n "$PRETTY_NAME" ]; then
color-echo 'OS' "$PRETTY_NAME"
else
color-echo 'OS' "not found"
fi
}
print-colors() {
NAMES=('black' 'red' 'green' 'yellow' 'blue' 'magenta' 'cyan' 'white')
for f in $(seq 0 7); do
echo -en "\033[m\033[$(($f+30))m ${NAMES[$f]} " # normal colors
done
echo
for f in $(seq 0 7); do
echo -en "\033[m\033[1;$(($f+30))m ${NAMES[$f]} " # bold colors
done
echo -e "$rst\n"
}
echo -e '\n'$prp$USER'@'$HOSTNAME$rst'\n' # print user and host name
print-distro
print-uptime
print-shell
print-de
print-wm
print-disk
print-mem
print-kernel
print-cpu
echo
print-colors
rm $TMP # delete temp file
..gnutella..
Re: Env-info? How?
^Nice, thanks. I'll probably modify to omit the colors, I'm just not finding myself in "interior designer" mode like the rest of you girls. ;) *smooch*
Re: Env-info? How?
There is a slightly more recent version (minus the temp file and plus all the window managers) here: https://github.com/pidsley/codemangler
Re: Env-info? How?
^Thanks, pids!
Re: Env-info? How?
With some modifications, I've got the env-info script going on my slackbox here at work. I had to modify the following:
To read instead:
To get it to work properly in Slackware. Also commented out "print colors" per Pidsley's instructions, to get rid of the color info.
Screenshot or it didn't happen. Edit: Mem line still needs tweaking, not displaying RAM (M or G) at all.
Code: Select all
print-mem() {
# field 2 on line 2 is total, field 3 on line 3 is used
mem=$(free -h | awk 'NR==2 {total=$2} NR==3 {used=$3; print used" / "total}')
color-echo 'Mem' "$mem"
Code: Select all
print-mem() {
# field 2 on line 2 is total, field 3 on line 3 is used
mem=$(free -m | awk 'NR==2 {total=$2} NR==3 {used=$3; print used" / "total}')
color-echo 'Mem' "$mem"
Screenshot or it didn't happen. Edit: Mem line still needs tweaking, not displaying RAM (M or G) at all.
Re: Env-info? How?
hmm, different version of 'mem' on Slackware? the same problem might be with the RAM display?
All statements are true in some sense, false in some sense, meaningless in some sense, true and false in some sense, true and meaningless in some sense, false and meaningless in some sense, and true and false and meaningless in some sense.
- wuxmedia
- Grasshopper
- Posts: 6454
- Joined: Wed Oct 17, 2012 11:32 am
- Location: Back in Blighty
- Contact:
Re: Env-info? How?
it's seemingly using 'free', try 'free -mh' that appends a 'G' or 'M' to the end, awk should pick up the whole field.
or do you mean it's not the right numbers?
oh, how come free -h didn't work?
it's not a solaris/freebsd/windows version or something wacky?
or do you mean it's not the right numbers?
oh, how come free -h didn't work?
it's not a solaris/freebsd/windows version or something wacky?
Re: Env-info? How?
Here's what it looked like prior to my change:
I will try your suggestion, wux.
I will try your suggestion, wux.
Re: Env-info? How?
Ok, wux's didn't work, but pid's did:
mem=$(free -m | awk 'NR==2 {total=$2} NR==3 {used=$3; print used"M / "total"M"}')
mem=$(free -m | awk 'NR==2 {total=$2} NR==3 {used=$3; print used"M / "total"M"}')
Re: Env-info? How?
Apparently not all distros support "free -h" -- just all the ones I tested. :(
"free -m" works (and it's actually what I was using a few versions ago, before I decided "free -h" was prettier). /closed :)
"free -m" works (and it's actually what I was using a few versions ago, before I decided "free -h" was prettier). /closed :)
Re: Env-info? How?
just one little thing, and you can call me an OCD-motherfucker. but free -V will show you the version of 'free' so we can determine whether it is actually just a different one... i'm curious as to whether Slackware has an older or newer version or something else is going on here.
Code: Select all
[23:40:47]$ free -V
free from procps-ng 3.3.4
All statements are true in some sense, false in some sense, meaningless in some sense, true and false in some sense, true and meaningless in some sense, false and meaningless in some sense, and true and false and meaningless in some sense.
Re: Env-info? How?
all the distros I tested have free from the procps-ng package
3.3.8 in sid
3.3.3 in Wheezy
3.3.8 in Arch
3.3.8 in LFS
3.3.8 in CRUX
This page says procps-ng is a fork of procps, so maybe(probably) Slack has original procps?
https://sourceforge.net/projects/procps-ng/
3.3.8 in sid
3.3.3 in Wheezy
3.3.8 in Arch
3.3.8 in LFS
3.3.8 in CRUX
This page says procps-ng is a fork of procps, so maybe(probably) Slack has original procps?
https://sourceforge.net/projects/procps-ng/
Re: Env-info? How?
Indeed:
Of course Slackware would be kickin' it old school. ;)
Code: Select all
procps version 3.2.8
-
- Baconator
- Posts: 10253
- Joined: Thu Sep 16, 2010 11:03 am
- Location: Pfälzerwald
- Contact:
Re: Env-info? How?
I can confirm that -h (human-readable it is called, I think) has not worked a few versions ago, when I was still with aptosid, for sure. Guess we have the awk/mawk/gawk situation here, too.
..gnutella..
Re: Env-info? How?
Ok then. Anyone who has this problem can use
mem=$(free -m | awk 'NR==2 {total=$2} NR==3 {used=$3; print used"M / "total"M"}')
I probably won't change the script on github. But I might. :)
mem=$(free -m | awk 'NR==2 {total=$2} NR==3 {used=$3; print used"M / "total"M"}')
I probably won't change the script on github. But I might. :)