Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've searched a lot but I can't find a way to show nethogs in conky. nethogs prints to terminal and there seems to be no way to capture output in real time. This is one thing I have been wanting for conky FOR AGES.

share|improve this question

2 Answers 2

I don't think so.

nethogs is an interactive process using the ncurses library. It expects to launch in a terminal window and get input from the user.

Conky can run programs using the exec/execi/execp/execpi directives, but these are supposed to be "run once" programs which output text then exit. Conky takes that text and displays it.

Try writing to the nethogs developer and see if he'll add "batched" mode, like the batched mode of the top command. If you could get nethogs to run for a second then display its text and exit, you could use that text output in Conky.

share|improve this answer

I've tried to do the same with conky on Ubuntu 12.10. But then i had a better idea:

  • create a new profile for gnome-terminal (transparent, small font size, whatever you like)
  • install package devilspie (you can also try the GTK version gdevilspie
  • create a new config file for devilspie which will help to get rid of the window frame border and menu

e.g. /home/<user>/.devilspie/gnome-terminal.ds

contents:

(if (is (window_role) "borderless")
  (begin
    (undecorate)
    (geometry "-0-0")
    (below)
    (skip_tasklist)
  )
)

(geometry "-0-0") will place the window at the bottom right

When the configuration file gnome-terminal.ds has not been written/changed you have to create it and stop/restart the devilspie deamon to see any changes. Dont forget to add the daemon to your startup scripts (XFCE: Setting > Session and Startup).

Now we need a startup bash script which you can add to your autostart just like devilspie. Something like this:

#!/bin/bash

if [ $# -lt 1 ]
then
  echo "Usage: `basename $0` <iface>"
  exit 1
fi

killall -9 nethogs 2>/dev/null
sleep 5
`sudo -H -u <username> gnome-terminal -e "/usr/bin/nethogs -d 4 $1" --profile=<profile-name> --role=borderless`

exit 0

You must pass an argument to the script to specify the target device. Notice that there is a sleep command within the script, just to make sure that previous nethogs processes are not running.

share|improve this answer
    
Nicely done. btw conky seems to have an out_to_ncurses option but I haven't played with it. –  koogee Feb 15 '14 at 13:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.