BSDinfo.sh
Forum rules
Your own work only.
Your own work only.
- ChefIronBelly
- Approved BBQer
- Posts: 1044
- Joined: Mon Jan 13, 2014 6:01 am
- Location: Michigan
BSDinfo.sh
Per Mr Pidsley's request here is the BSDinfo scripts. My hackery should not in anyway tarnish his good name. Limited testing and checking for malformed files.
Comes under the 'It is what it is' license.
ChefIronBelly/BSD-scripts
enjoy
Comes under the 'It is what it is' license.
ChefIronBelly/BSD-scripts
enjoy
(1/1) Installing: LinuxBBQ...................................[69%]==============[/]
- ChefIronBelly
- Approved BBQer
- Posts: 1044
- Joined: Mon Jan 13, 2014 6:01 am
- Location: Michigan
Re: BSDinfo.sh
No problem there rough but it wont take to much for me to clean them up.
(1/1) Installing: LinuxBBQ...................................[69%]==============[/]
Re: BSDinfo.sh
Excellent, thanks Chef!
Re: BSDinfo.sh
Thank you for sharing Chef! Looks like you have some very descent computers :D
cheers
simon
cheers
simon
Someone told me that I am delusional, I almost fell off my unicorn.
- ChefIronBelly
- Approved BBQer
- Posts: 1044
- Joined: Mon Jan 13, 2014 6:01 am
- Location: Michigan
Re: BSDinfo.sh
^^ anything sexy came from pidsley ;)
^ Cool
updated OpenBSD script.
^ Cool
updated OpenBSD script.
(1/1) Installing: LinuxBBQ...................................[69%]==============[/]
Re: BSDinfo.sh
[please pardon the script feedback -- I mean no offense]
Personally, I'd lose the code where you convert the wm name to mixed case, but that's just my preference. At least make it a function, since you use it in two different places. You could also make two arrays, one for pid searching and the other mixed case, then use the index of the found pid to index into the second array, like this:
This assumes that there is a one-to-one correspondence between the two arrays and that they are in the correct order.
This would also be a perfect case for an associative array, like this:
(thanks for making me finally learn how to use associative arrays in bash :)
Personally, I'd lose the code where you convert the wm name to mixed case, but that's just my preference. At least make it a function, since you use it in two different places. You could also make two arrays, one for pid searching and the other mixed case, then use the index of the found pid to index into the second array, like this:
Code: Select all
wms=( 2bwm 2wm 9wm aewm afterstep ahwm alopex amiwm antiwm awesome ratpoison blackbox bspwm catwm clfswm ctwm cwm dminiwm dragonflywm dwm echinus )
wmnames=( 2bwm 2wm 9wm Aewm Afterstep Ahwm Alopex AmiWM AntiWM AwesomeWM Ratpoison BlackBox Bspwm Catwm Clfswm Ctwm cwm DminiWM DragonflyWM DWM Echinus )
print-wm() {
for (( i=0; i<${#wms[*]}; i++ )); do # loop through wm array by index
pid=$(pgrep -x -u $USER ${wms[i]}) # if found, this wm has running process
if [[ "$pid" ]]; then
color-echo WM ${wmnames[$i]} # index into wmnames array
break
fi
done
}
This would also be a perfect case for an associative array, like this:
Code: Select all
declare -A wms=( [9wm]=9WM [ratpoison]=Ratpoison [blackbox]=BlackBox ) # small array for test purposes, expand as necessary
print-wm() {
for wm in ${!wms[@]}; do # loop through wm array by key
pid=$(pgrep -x -u $USER $wm) # if found, this wm key has running process
if [[ "$pid" ]]; then
color-echo WM ${wms[$wm]} # get the value for this key from the associative array
break
fi
done
}
- ChefIronBelly
- Approved BBQer
- Posts: 1044
- Joined: Mon Jan 13, 2014 6:01 am
- Location: Michigan
Re: BSDinfo.sh
That stuff was lifted straight from screenfetch. I may have tweaked a bit if it didn't work or tried to simplify per distro but most of it did work.
Anyway thanks for the feedback I will certainly be taking a close look at your suggestion.
Thank you
EDIT: I think the whole mixed array bit was used to cover all the linux and BSD iterations. I think since now they are specific per distro you are correct that bit can go. I will dig in tomorrow morning with a freshly caffeinated head to much sun today.
Anyway thanks for the feedback I will certainly be taking a close look at your suggestion.
Thank you
EDIT: I think the whole mixed array bit was used to cover all the linux and BSD iterations. I think since now they are specific per distro you are correct that bit can go. I will dig in tomorrow morning with a freshly caffeinated head to much sun today.
(1/1) Installing: LinuxBBQ...................................[69%]==============[/]
Re: BSDinfo.sh
Yes, I recognized the screenfetch code :) Those big case and if/elif blocks just bug me, but "it works pidsley, so stfu" is certainly a valid response.
No problem if you don't want to implement any of this -- it's only ideas and an excuse for me to try some things I haven't done before.
No problem if you don't want to implement any of this -- it's only ideas and an excuse for me to try some things I haven't done before.
- ChefIronBelly
- Approved BBQer
- Posts: 1044
- Joined: Mon Jan 13, 2014 6:01 am
- Location: Michigan
Re: BSDinfo.sh
Never... I agree I hate there code it was a matter of time vs effort when I was going thru the BSD thing. I really thought it would be a use one and done type usage. But as it turns out I really like them and have been using more and more.pidsley wrote:"it works pidsley, so stfu" is certainly a valid response.
I plan on implementing your suggestion and working my way down thru that code. Im sure I will have some things to bounce off you soon.
Happy 4th :)
(1/1) Installing: LinuxBBQ...................................[69%]==============[/]
- ChefIronBelly
- Approved BBQer
- Posts: 1044
- Joined: Mon Jan 13, 2014 6:01 am
- Location: Michigan
Re: BSDinfo.sh
I ended up using this... do you recognize it :D
pgrep flags are working a little different the -x -u never found the pid adding -a worked for FreeBSD. -x -u worked for NetBSD, OpenBSD.
pgrep flags are working a little different the -x -u never found the pid adding -a worked for FreeBSD. -x -u worked for NetBSD, OpenBSD.
Code: Select all
wms=( 2bwm 2wm 9wm aewm afterstep ahwm alopex amiwm antiwm awesome blackbox bspwm catwm clfswm ctwm cwm dminiwm dragonflywm dwm echinus \
euclid-wm evilpoison evilwm fluxbox flwm fvwm-crystal goomwwm hcwm herbstluftwm i3 icewm jwm karmen larswm lwm matwm2 mcwm monsterwm \
musca notion nwm olwm openbox oroborus pekwm ratpoison sapphire sawfish sscrotwm sithwm smallwm snapwm spectrwm stumpwm subtle tfwm tinywm tritium twm \
uwm vtwm w9wm weewm wind windowlab wm2 wmaker wmfs wmii wmx xfwm4 xmonad xoat yeahwm )
Code: Select all
print-wm() {
for wm in ${wms[@]}; do # pgrep through wmname array
pid=$(pgrep -a -x -u $USER $wm)
if [[ "$pid" ]]; then
color-echo 'WM' $wm
break
fi
done
}
-a Include process ancestors in the match list. By default, the
current pgrep or pkill process and all of its ancestors are
excluded (unless -v is used).
(1/1) Installing: LinuxBBQ...................................[69%]==============[/]
Re: BSDinfo.sh
Nice. I like having the wm name all lower case, and the code is much simpler now.
It does feel like I've seen that code somewhere before... :)
The differences in the BSD coreutils are part of what always puts me off using BSD. They are just different enough to be annoying.
It does feel like I've seen that code somewhere before... :)
The differences in the BSD coreutils are part of what always puts me off using BSD. They are just different enough to be annoying.
- ChefIronBelly
- Approved BBQer
- Posts: 1044
- Joined: Mon Jan 13, 2014 6:01 am
- Location: Michigan
Re: BSDinfo.sh
One fun fact I learned today was that the p* tools pkill pgrep etc came from Solaris 7 > BSD.
https://en.wikipedia.org/wiki/Pgrep
https://en.wikipedia.org/wiki/Pgrep
(1/1) Installing: LinuxBBQ...................................[69%]==============[/]
Re: BSDinfo.sh
^ Thank you, that is interesting.
Re: BSDinfo.sh
I use and found more clean readable than screenfetch. I removed screenfetch after i found this thread :P
Thanks for sharing ChefIronBelly
Thanks for sharing ChefIronBelly
Devuan/XFCE
- ChefIronBelly
- Approved BBQer
- Posts: 1044
- Joined: Mon Jan 13, 2014 6:01 am
- Location: Michigan
Re: BSDinfo.sh
All credits to pidsley this was my feeble attempt based on his good work.
(1/1) Installing: LinuxBBQ...................................[69%]==============[/]
Re: BSDinfo.sh
nili, are you using BSD or a BBQ spin? If you are using a BBQ spin you probably already have the original script. The BBQ version is called "env-info"Nili wrote:I use and found more clean readable than screenfetch. I removed screenfetch after i found this thread :P
Thanks for sharing ChefIronBelly
Re: BSDinfo.sh
I' m using simple netinst Debian 8.1 with your env-info a few (scrots) include env-infopidsley wrote:nili, are you using BSD or a BBQ spin? If you are using a BBQ spin you probably already have the original script. The BBQ version is called "env-info"
So thanks for making it, as i said removed screenfetch in favor of env-info script - i'm happy :P
I congratulated you for your editing effort, but i'm using pidsley's code for some time :DChefIronBelly wrote:All credits to pidsley this was my feeble attempt based on his good work.
Devuan/XFCE
- ChefIronBelly
- Approved BBQer
- Posts: 1044
- Joined: Mon Jan 13, 2014 6:01 am
- Location: Michigan
Re: BSDinfo.sh
Thank you appreciate it.
(1/1) Installing: LinuxBBQ...................................[69%]==============[/]