You are not logged in.

#1 2017-06-17 13:07:33

brontosaurusrex
Middle Office
Registered: 2015-09-29
Posts: 2,739

pipeSysInfo, work in progress

https://raw.githubusercontent.com/bront … ipeSysInfo

pipeSysInfo may display

10% cpu used
634/16040M, 4% mem used
69G disk free, 28% ~ used
dl 475, up 57 kB/s, up 2 hours, 12 minutes
macpro @ Debian GNU/Linux 9.0 (stretch)

and pipeSysInfo pipe will say similar, only formated for openbox menu usage

<openbox_pipe_menu>
<item label="10% cpu used" />
<item label="627/16040M, 4% mem used" />
<item label="69G disk free, 28% ~ used" />
<item label="dl 537, up 51 kB/s, up 2 hours, 14 minutes" />
<item label="macpro @ Debian GNU/Linux 9.0 (stretch)">
    <action name="Execute">
        <execute>scrot -q 0 -d 7 -e 'mv  ~'</execute>
    </action>
</item>
</openbox_pipe_menu>

Eventually I wanna have display like

#       13:13 - 17.jun 2017
#       ||||   |||||||||||||||||||||||||||||| cpu 4%
#       |   ||||||||||||||||||||||||||||||||| mem 245M/15G used
#       ||||||||||||||||||||||   |||||||||||| disk ~ 32% used, 65G free
#       dl 1.1M, up 34k, uptime: 2h, node: i5

or (better)

#       ||||   |||||||||||||||||||||||||||||| cpu
#       |   ||||||||||||||||||||||||||||||||| mem
#       ||||||||||||||||||||||   |||||||||||| 65G disk free
#       dl 14, up 248 kB/s

in openbox menu (pipe menu). Which means that survival of non-monospaced fonts is essential. Cli version may be more verbose.

Improvements/testing of this version are welcome.

changelog:
- cli and pipe versions merged.
- download/upload speed calculus needs some time diff, so script will appear to run slow (about a second).

problems:
- download/upload fails already on 2nd machine (changing tail -1 to grep eth0 fixes this localy), it was expected due to guesswork approach.

Last edited by brontosaurusrex (2017-06-20 09:51:52)

Offline

#2 2017-06-17 14:30:06

Head_on_a_Stick
Member
From: London
Registered: 2015-09-29
Posts: 9,066
Website

Re: pipeSysInfo, work in progress

Interesting project smile

Firstly, the script only uses a single bashism in the form of the here-string at line 33 — if you replace this with a (POSIX) here-document then you can switch to a /bin/sh shebang for better portability.

So this:

read -r _ _ _ avail use _ <<< $(df -h ~ | tail -1)
echo "$avail ~ disk free," "$use used"

Becomes:

read -r _ _ _ avail use _ <<!
$(df -h ~ | tail -1)
!
echo "$avail ~ disk free," "$use used"

Secondly:

An easy way to have current download/upload speed?

Have you seen https://askubuntu.com/questions/450604/ … n-terminal?

Offline

#3 2017-06-17 14:34:22

brontosaurusrex
Middle Office
Registered: 2015-09-29
Posts: 2,739

Re: pipeSysInfo, work in progress

HoaS: is there a bashism checker?

Offline

#4 2017-06-17 14:44:09

Head_on_a_Stick
Member
From: London
Registered: 2015-09-29
Posts: 9,066
Website

Re: pipeSysInfo, work in progress

brontosaurusrex wrote:

is there a bashism checker?

checkbashisms

https://packages.debian.org/jessie/devscripts

EDIT: hmmm, maybe I was mistaken, your script appears "clean":

empty@testbed:~ $ checkbashisms testinfo                                       
empty@testbed:~ $

My apologies, it's not a bashism as such but it's certainly not POSIX:

empty@testbed:~ $ sed -i 's/bash/sh/' ~/bin/testinfo
empty@testbed:~ $ testinfo                                                     
Sat 17 Jun 15:50:22 BST 2017
10% cpu used
955/7907M, 12.08% mem used
/home/empty/bin/testinfo: 33: /home/empty/bin/testinfo: Syntax error: redirection unexpected
2|empty@testbed:~ $

Last edited by Head_on_a_Stick (2017-06-17 14:51:44)

Offline

#5 2017-06-17 14:57:22

brontosaurusrex
Middle Office
Registered: 2015-09-29
Posts: 2,739

Re: pipeSysInfo, work in progress

I think it's "checkbashisms -f script"

possible bashism in testInfo line 30 (<<< here string):
read -r _ _ _ avail use _ <<< $(df -h ~ | tail -1)
possible bashism in testInfo line 38 ($HOST(TYPE|NAME)):
echo "$HOSTNAME running $rel

so yes, its not clean smile

Last edited by brontosaurusrex (2017-06-17 14:58:23)

Offline

#6 2017-06-18 02:04:57

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,557
Website

Re: pipeSysInfo, work in progress

^"clean" is a bit emotive perhaps? Bash isn't a virus. Of course POSIX-compliant scripts will be more portable, if that's a concern for your usage case.


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Offline

#7 2017-06-18 07:00:21

brontosaurusrex
Middle Office
Registered: 2015-09-29
Posts: 2,739

Re: pipeSysInfo, work in progress

It's not a concern personally and I'd guess it will break at the methods of getting info from the system 1st. I wonder if python has higher level methods of getting that same info?

Last edited by brontosaurusrex (2017-06-18 07:24:41)

Offline

#8 2017-06-18 11:16:10

Head_on_a_Stick
Member
From: London
Registered: 2015-09-29
Posts: 9,066
Website

Re: pipeSysInfo, work in progress

Bash is rather useful for certain things, like these progress bars from the awesome Greg's Wiki:

http://mywiki.wooledge.org/BashFAQ/044

Perhaps they could be adapted for your display?

The extra functionality would then justify the bash shebang 8)

Offline

#9 2017-06-18 17:09:18

brontosaurusrex
Middle Office
Registered: 2015-09-29
Posts: 2,739

Re: pipeSysInfo, work in progress

HoaS: I think ill take my alsa slider code and put that into some function (We are looking at the moment in time here only, no animation would be possible in ob menus I assume?).

^ Added pipe-menu version (the ugly one without bars).

Last edited by brontosaurusrex (2017-06-18 17:47:26)

Offline

Board footer

Powered by FluxBB