Stories
Slash Boxes
Comments

SoylentNews is people

posted by martyb on Thursday January 17 2019, @01:45AM   Printer-friendly
from the automation++ dept.

Hi all,

I have been learning linux and have a secondary monitor that I wanted to use for showing some sensor data. Currently I need to manually enter in three commands and then arrange my windows each time I want to look at (and start-up, etc). I am using the nethogs, inxi, and lm-sensors libraries:

sudo nethogs
watch -n1 "inxi -s"
watch -n1 "sensors | grep Tdie"

The end result looks something like this:
https://i.ibb.co/TgWXKSn/sensors.png

Is it possible/easy to script the opening of these three terminal windows and position them onto a specific monitor? Or is there a completely different better way to go about this?

Also, is there a way for me to custom arrange the data on the screen? Eg, could I put the sensors "Tdie" data into two columns and remove the "high = +70.0 C" info?

[Beyond this specific case, is there a general solution with, say, a directory containing a separate shell script for launching each program, with a master script that specifies terminal width/height as well as (x,y) coordinates? --Ed.]


Original Submission

 
This discussion has been archived. No new comments can be posted.
Display Options Threshold/Breakthrough Mark All as Read Mark All as Unread
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
  • (Score: 5, Informative) by krishnoid on Thursday January 17 2019, @02:53AM (10 children)

    by krishnoid (1156) on Thursday January 17 2019, @02:53AM (#787732)

    Don't the X Window System --geometry WxH+xoff+yoff [x.org] arguments work?

    Starting Score:    1  point
    Moderation   +3  
       Interesting=1, Informative=2, Total=3
    Extra 'Informative' Modifier   0  
    Karma-Bonus Modifier   +1  

    Total Score:   5  
  • (Score: 0) by Anonymous Coward on Thursday January 17 2019, @03:07AM (5 children)

    by Anonymous Coward on Thursday January 17 2019, @03:07AM (#787741)

    This looks like it could work, I've just been using gnome-terminal though. I've been pretty happy with it, but perhaps I should try out xterm as well.

    • (Score: 3, Informative) by krishnoid on Thursday January 17 2019, @03:18AM (3 children)

      by krishnoid (1156) on Thursday January 17 2019, @03:18AM (#787749)

      Modern terminals such as gnome-term are much nicer than xterm; you should be able to use a similar geometry option [stackexchange.com] with gnome-terminal.

      • (Score: 0) by Anonymous Coward on Thursday January 17 2019, @03:26AM (1 child)

        by Anonymous Coward on Thursday January 17 2019, @03:26AM (#787756)

        Yes, this is definitely looking like an option once I figure out how to get it on a certain monitor.

        • (Score: 0) by Anonymous Coward on Thursday January 17 2019, @02:27PM

          by Anonymous Coward on Thursday January 17 2019, @02:27PM (#787887)

          Instead of specifying the monitor you want, you'll just use a large value of x so that your window's left edge begins after your monitors right edge ends. If you use xrandr, it will show you your total screen real estate, then just make your x offset large enough that it reaches the monitor you want your terminal on. Generally this is the total width divided by two, if your monitors are even. But really, you could just start feeding in larger and larget x values until your terminal reaches the right screen.

      • (Score: 3, Insightful) by coolgopher on Thursday January 17 2019, @03:58AM

        by coolgopher (1157) on Thursday January 17 2019, @03:58AM (#787769)

        Modern terminals such as gnome-term are much nicer than xterm

        I used to think that too. I've since gone back to XTerm. Much better configurability.

    • (Score: 3, Informative) by Azuma Hazuki on Thursday January 17 2019, @11:25PM

      by Azuma Hazuki (5086) on Thursday January 17 2019, @11:25PM (#788075) Journal

      RXVT-Unicode (urxvt) is awesome too, especially with a little fiddling to get some extensions going. With the URL grabber, the option to notify urgent on PM/highlight, and the "tabbed" extension, it even makes irssi a better X-Chat than X-Chat was, for example.

      --
      I am "that girl" your mother warned you about...
  • (Score: 2) by jimtheowl on Thursday January 17 2019, @03:12AM (3 children)

    by jimtheowl (5929) on Thursday January 17 2019, @03:12AM (#787744)
    Unix like operating systems actually shine at capturing your work, allowing you to automate it.

    The history command is useful for capturing any sequence of commands you just typed. Just redirect it to a file. That file then become the basis for your script.
    ie:

    history > myscript

    Add !/bin/sh at the start (for scripts, sh is more portable than bash), remove anything not required. You can replace values with variables if you want to make it more generic.

    That is it.
    • (Score: 2, Informative) by Anonymous Coward on Thursday January 17 2019, @03:33AM (1 child)

      by Anonymous Coward on Thursday January 17 2019, @03:33AM (#787762)

      Very helpful tip. Thank you. Except when I try to run something it opens in its own window:

      !/bin/sh

      gnome-terminal --geometry 73x31+100+300

      # new window, not the one placed above:
      watch -n1 inxi -z -F

      I am sure I will figure it out though.

      • (Score: 0) by Anonymous Coward on Thursday January 17 2019, @04:06AM

        by Anonymous Coward on Thursday January 17 2019, @04:06AM (#787772)

        not sure about gnome-terminal, but xterm and others use -e flag for this:
        xterm --geometry 73x31+100+300 -e watch -n1 inxi -z -F
        You can also use the flags to set window name/title/class to do some automatic detection for positioning etc.

    • (Score: 2) by maxwell demon on Thursday January 17 2019, @06:56AM

      by maxwell demon (1608) on Thursday January 17 2019, @06:56AM (#787805) Journal

      Add !/bin/sh at the start

      That should be #!/bin/sh

      --
      The Tao of math: The numbers you can count are not the real numbers.