- Notifications
You must be signed in to change notification settings - Fork1
Jeansen/cdmn
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
cdmn (cpu,disk,memory,network) is a Perl extension forurxvt whichextends urxvt to show the utilization of different system resources.
Originally I planned to have some LED-like indicators but soon decided to make this extension more verbose andchanged the simple LED look to animated bars. With time, increasing knowledge and a lot of trial and error, Icontinued to optimize the UX and added additional features.
Here's a short screencast of what it looks like on my system:
In the above example I starttest-ng
to simulate the utilization of one logical CPU core. If you watch the CPU gauges,you will notice, that only one bar rizes to the maximum and becomes red.
Because the space is to small I switch from overlay mode to fixed mode which puts the gauges on its on row. I then hideand show labels.
Next I display the side bar, navigate through some tabs, expand and shrink the sidebar and finally hide it again. ThenI hide the gauges completely, bring them back in overlay mode and ultimately switch back to fixed mode again.
The keysyms for this are defined inDefault keysyms. Of course you can overwrite them to yourliking!
I have created a dedicated docker container for easy demonstrations.Given you haveinstalled docker just run thefollowing commands:
cd /tmpgit clone https://github.com/Jeansen/cdmn.git/tmp/cdmn/resources/test/run.sh -e /tmp/cdmn/cdmn -x /tmp/cdmn/resources/test/Xresources_demo
If you do not see anything after the docker image finished downloading or the created window is very small you mightneed to comment out a font setting. Simply prepend a!
to the line starting withURxvt*font:
intmp/cdmn/resources/test/Xresources_demo
and try again.
To simulate some cpud,disk and memory load play around with the following command:
stress-ng --cpu 4 --io 3 --vm 2 --vm-bytes 1G --timeout 5s
Before using the package provided by your distribution, I strongly recommend that youcompile rxvt-unicode yourself. While developing this extension I came across a bug thatresults in constant memory consumption over time.
Anyway, if you first want to check what this extension can do for you, there is still the option of installing rxvtwithsudo apt-get install rxvt-unicode-256color
.
Make sure the version is 9.22. Anything else may not work!
Install needed Perl libraries:sudo apt-get install libfilesys-df-perl libparams-validate-perl
Then clone this repository to a place of your liking, e.g.git clone https://github.com/Jeansen/cdmn.git ~/cdmn
andset the resourceURxvt*perl-lib
. In this example this would beURxvt*perl-lib: /path/to/cdmn/
.
Then load the changes withxrdb -load ~/.Xresources
.
Now, runurxvt -pe cdmn
.
Make sure you pull updates on a regular basis to enjoy new features and improved stability.
Of course you can have the extension loaded automatically by adding the resourceURxvt*perl-ext-common: cdmn
to your .Xresources file. But I would not recommend it at the moment.
Also have a look in theresources/test
folder. There are some demo files that you can use a a starting point.
Wireless is a bit of a speciality because there is no constant maximal rx/tx speed. The value is constantly evaluatedand not available viasysfs orprocfs. Therefore cdmn usesiwconfig
as part of its calculation.Unfortunately this requires root privileges. To make thinks work, put the following in/et/sudoers
:
<your username here> ALL = NOPASSWD: /sbin/iwconfig
Keysym | Function |
---|---|
Meta-l | Show/Hide left labels |
Meta-o | Show/Hide captions in overlay mode |
Meta-h | Show/Hide captions in normal mode Toggle between overlay to normal mode |
Meta-p | Show/Hide sidebar |
Meta-k | Show next pane |
Meta-j | Show previous pane |
Ctrl-k | Scroll up in current pane |
Ctrl-j | Scroll down in current pane |
Ctrl-. | Shrink the sidebar by one column |
Ctrl-, | Expand the sidebar by one column |
Normally the Meta key maps to the ALT key. If the bindings do not work, please check your system mappings.
If you do not like the default settings, you canchange them.
cdmn offers two visual modes: overlay and normal.
Theoverlay mode simply does what the name already implies. It creates an overlay on top of the current terminal.If some text is not visible, just hidecdmn for a moment. This is what theMeta-o
binding is for.
On the other hand, if you don't wantcdmn to blank out some of the terminals output or interfere with your currenttyping, then simply usenormal mode. In this mode a complete line or column (depending on your settings) will bereserved forcdmn. You can switch to this mode withMeta-h
.
Each binding can be used to switch modes or to hide and showcdmn in a given mode. For instance, if you are inoverlay mode you can useMeta-h
to go to normal mode and then useMeta-h
repeatedly to toggle the visibility ofcdmn. Just try it! It should be fairly intuitive.
Additional information can be accessed with theMeta-p
binding. This will show the sidebar containing multiplepanes with more verbose information. UseMeta-j
andMeta-k
to navigate between these panes andCtrl-j
andCtrl-k
to scroll up and down. Don't worry, you will be able to set these bindings, soon.
The sidebar is in heavy development at the moment. Stay tuned but do not expect too much ;-)
Following is a list of gauges you can customize to your liking:
Gauge name | Description |
---|---|
disk | Disk utilization |
cpu | CPU utilization |
memory | Available/Used memory |
network | Network utilization |
cpu_temp | CPU temperature |
battery | Battery status |
mount | Used/remaining space for mount points |
hidpp | Battery status of HID++ devices (Mice, Keyboard, ...) |
Labels can be defined with the following resources. Each label defines the text you would like to see next to thecorresponding gauges:
Resource | Default |
---|---|
URxvt.cdmn.label.disk | DISK |
URxvt.cdmn.label.cpu | CPU |
URxvt.cdmn.label.memory | MEM |
URxvt.cdmn.label.network | NET |
URxvt.cdmn.label.cpu_temp | TEMP |
URxvt.cdmn.label.battery | BAT |
URxvt.cdmn.label.mount | MOUNT |
URxvt.cdmn.label.hidpp | HID |
URxvt.cdmn.label.swap | SWAP |
In addition you can set colors for different parts. All colors default to the terminal foreground (-2) or background(-1). Normally you will not need to use these values. After all, they are the defaults. But you might want touse any number between 0 and 255.
Resource | Function | Default (Other) |
---|---|---|
URxvt.cdmn.label.fg | Foreground color for all labels. | -2 (0-155) |
URxvt.cdmn.label.bg | Background color for all labels. | -1 (0-155) |
URxvt.cdmn.caption.bg | Global background, e.g. padding. | -2 (0-155) |
Want to know what colors have which number? Try this one-liner in your terminal and see for yourself:
for i in {0..255}; do echo -e "\e[38;05;${i}m${i}"; done | column -c 80 -s ' '; echo -e "\e[m"
And finally, you can define if you would like bold labels and where to position labels:
Resource | Function | Default (Other) |
---|---|---|
URxvt.cdmn.label.bold | Bold labels | false (true) |
URxvt.cdmn.label.position | Labels position | left (right) |
Starting with the layout, you can define the position, order, initial visibility and more with the following resources.
Resource | Function | Default |
---|---|---|
URxvt.cdmn.padding | How much space (in characters) you would like to have between each caption (label + gauges). | 2 |
URxvt.label.padding | How much space (in characters) you would like to have between a label and its gauges. | 1 |
URxvt.cdmn.x | Horizontal position (by character) where values >= 0 will result in a left alignment and negative numbers in a right alignment. | -1 |
URxvt.cdmn.y | Vertical position (by row) where 0 will be the first line and -1 the last. | 0 |
URxvt.cdmn.gauges.order | List of gauges to show and their order. This list must contain existing labels. | CPU,DISK,MEM,NETWORK |
URxvt.cdmn.showing | Initially show gauges. | 1 |
URxvt.cdmn.showing.labels | Initially show labels. | 1 |
More fine-grained settings are possible with the following resources:
URxvt.cdmn.gauges.disksURxvt.cdmn.disk.readURxvt.cdmn.disk.writeURxvt.cdmn.gauges.batteriesURxvt.cdmn.gauges.coresURxvt.cdmn.network.rxURxvt.cdmn.network.txURxvt.cdmn.gauges.mountsURxvt.cdmn.gauges.hidppsURxvt.cdmn.gauges.swaps
Each of the above resources expects a list of device names to show gauges for.
By default if you do not specify anythingcdmn will assume you would like to see everything.
That is, if you do specify valid values for let's sayURxvt.cdmn.batteries
then you will only see what you specified.
There are some exceptions, though.
If you do not provide
URxvt.cdmn.network.rx
and/orURxvt.cdmn.network.tx
then there will be only one gauge foreach interface. On the other hand, if you do provideURxvt.cdmn.network.rx
and/orURxvt.cdmn.network.tx
, thenyou will only see those gauges. Ultimately you will have to explicitly list all interfaces you would like when youprovide values forURxvt.cdmn.network.rx
and/orURxvt.cdmn.network.tx
. This also means you will have to providevalues for 'rx' and 'tx' where the default was to only show one gauge combining 'rx' and 'tx' values.The other exceptions to this rule are
URxvt.cdmn.disk.read
andURxvt.cdmn.disk.write
. These act as an additiontoURxvt.cdmn.gauges.disks
and allow you to define for which disks you would like to see additional read and/orwrite utilization. Of course you could leave outURxvt.cdmn.gauges.disks
and only provide values for disks youwould like to monitor in detail.
Note, that the additional gauges toURxvt.cdmn.gauges.disks
are subsets of it. If you were to set all three settingsto a value ofsda
and copied a large file from one folder to another on this disk, you would see three gauges: Onewith about 100 percent for the combined read and write utilization and two others with about 50 percent each becausehalf of the time was spent reading in data and the other half of the time was spent writing data.
Also note, that a missing resource setting forURxvt.cdmn.gauges.disks
will only be replace by a list of disksavailable on startup. After that the (default) list will be used as if you had specified it explicitly. That is, if youlater on attach another disk (for instance via USB), that disk will not add an additional gauge. If you would like tohave additional gauges for any disk that you attach afterwards, you will have toenableURxvt.cdmn.allow-new-devices
Eachavailable gauge has the following settings that you can useto adapt its visual style.
Resource | Function | Default (Other) |
---|---|---|
URxvt.cdmn.<guage>.style | The kind of gauges you prefer. Either a bar that can grow and shrink or simple flashing LED. | bar (led) |
URxvt.cdmn.<guage>.graph.width | Width of graph in samplings, for example 5. | not set |
URxvt.cdmn.<guage>.graph.expand | If graph width should take up as much space as possible. | not set |
URxvt.cdmn.<guage>.detail | How much detail, e.g. a gauge for every logical core or just one gauge. | true (false) |
URxvt.cdmn.<guage>.invert | Invert colors. | true (false) |
URxvt.cdmn.<guage>.colors | The colors to be used apart from any global setting. | true (false) |
URxvt.cdmn.<guage>.inverse | Inverse gauges value interpretation, e.g. a full bar for 0 instead for 100%. | true (false) |
If you specifyURxvt.cdmn.<guage>.graph.width
andURxvt.cdmn.<guage>.graph.expand
, the latter one takes precedence.
You can further define the visual representation and orientation with the following settings.
Resource | Function | Default (Other) |
---|---|---|
URxvt.cdmn.visual.alignment | Vertical or horizontal alignment. | row (col) |
URxvt.cdmn.style.bar.symbols | Symbols to use forURxvt.cdmn.<guage>.style: bar | ⎯,▁,▂,▃,▄,▅,▆,▇,█ |
URxvt.cdmn.style.led.symbol | Symbol to use forURxvt.cdmn.<guage>.style: led | ■ |
In addition you can define a list of colors that will serve as a visual cue for different values. This will be mostuseful when using the LED style. Suppose you would like to simulate a red LED that increases in brightness for every20%. SettingURxvt.cdmn.gauges.colors
to '0,0,52,88,124,160,196' would just do that, where the first color definesthe background color and all other are the foreground colors. The second color will be the color of inactivity - inthis case 0 which is black.
You can also set (and overwrite) colors individually for each gauge with the following resources:
URxvt.cdmn.network.colorsURxvt.cdmn.disk.colorsURxvt.cdmn.cpu.colorsURxvt.cdmn.cpu_temp.colorsURxvt.cdmn.memory.colors URxvt.cdmn.battery.colorsURxvt.cdmn.mount.colors
If you only define one color it will be interpreted as a foreground color.URxvt.cdmn.gauges.bg
(either your value orthe implicit default -2) will be used for the background color.
Even further tweaking is possible with options such as the refresh rate and sensitivity.
Resource | Function | Default (Other) |
---|---|---|
URxvt.cdmn.refresh | How often to take samples in seconds. Decimal numbers are possible, for example 0.1 for every 100 milliseconds. | 1 |
URxvt.cdmn.sensitivity | Threshold at which to show changes | 1 |
The refresh rate is simply the time in seconds when all gauges should be updated. The sensitivity on the other handdefines the threshold when to first indicate any change.
Note that the sensitivity shrinks the delta for intermediate values. You maybe have setURxvt.cdmn.gauges.colors
to 5color values (the first being the initial color) to show a visual cue for every 20 percent increase. If you set thesensitivity to 90 those values would be evaluated in the remaining delta of 10 instead of 100.
Here is an example. Say we have the following resources excerpt:
URxvt.cdmn.gauges.order: CPU URxvt.cdmn.gauges.colors: 0,52,88,124,160,196URxvt.cdmn.style: ledURxvt.cdmn.refresh: 1URxvt.cdmn.sensitivity: 1
This results in a flashing LED-like gauge for CPU activity that has 5 red tones (a brighter tone for every 20%increase), which flashes (updates) every second but only if there is at least 1% of activity. Setting the sensitivityto 50 would result in the LED-like gauge to flash first at 50% load with the color of 124. It is also possibleto use fractions of seconds, e.g. 0.1, 1.1 and so on.
Finally there are even more settings ...
Resource | Function | Default (Other) |
---|---|---|
URxvt.cdmn.disk.mountsonly | Only show disk gauges for disks with at least one mount point. | true (false) |
URxvt.cdmn.allow-new-devices | Add gauges for new devices even in the presence of a predefined list. | true (false) |
There is an initial .Xresouces file in the resources folder with some minimal necessary settings, including somecolor overwrites to make it look like the example screenshots. Make sure you adapt the lineURxvt*perl-lib: /home/<USERNAME>/.urxvt/
accordingly.
If you do not like the defaultkeysyms, you can change them:
Resource | Default | Function |
---|---|---|
URxvt.cdmn.Keysym.labels.show | Meta-l | Show/Hide labels |
URxvt.cdmn.Keysym.overlay.toggle | Meta-o | Show/Hide cpations in overlay mode |
URxvt.cdmn.Keysym.toggle | Meta-h | Show/Hide cpations in normal mode Toggle between overlay to normal mode |
URxvt.cdmn.Keysym.sidebar.toggle | Meta-p | Show/Hide sidebar |
URxvt.cdmn.Keysym.sidebar.pane.next | Meta-k | Show next pane |
URxvt.cdmn.Keysym.sidebar.pane.prev | Meta-j | Show previous pane |
URxvt.cdmn.Keysym.sidebar.scroll.up | Ctrl-k | Scroll up in current pane |
URxvt.cdmn.Keysym.sidebar.scroll.down | Ctrl-j | Scroll down in current pane |
URxvt.cdmn.Keysym.sidebar.shrink | Ctrl-period | Shrink the sidebar by one column |
URxvt.cdmn.Keysym.sidebar.expand | Ctrl-comma | Expand the sidebar by one column |
Now, while still in development, there are already some things that work and that you can customize:
Resource | Function | Default (Other) | Notes |
---|---|---|---|
URxvt.cdmn.sidebar.bg | Background color | Terminal background (0-255) | |
URxvt.cdmn.sidebar.fg | Foreground color | Terminal foreground (0-255) | |
URxvt.cdmn.sidebar.border.fg | Border color | Terminal foreground (0-255) | |
URxvt.cdmn.sidebar.width | How much space to use for the sidebar in percentages | 50 (30-100) | IfURxvt.cdmn.sidebar.position set toleft orright |
URxvt.cdmn.sidebar.height | How much space to use for the sidebar in percentages | 40 (30-100) | IfURxvt.cdmn.sidebar.position set tobottom ortop |
URxvt.cdmn.sidebar.position | Sidebar position | right (top, bottom, left, center) | |
URxvt.cdmn.sidebar.header.position | Header position | top (bottom) | |
URxvt.cdmn.sidebar.label.position | Label position for graphs | top (bottom) | |
URxvt.cdmn.sidebar.label.detail | If the label should be the device name, real name or both | full (simple, real) | Fallback is 'simple' if set to real or full and the real name is not available |
URxvt.cdmn.sidebar.graph.symbols | Use given symbols for depicting graphs | '■, □' (ANY) | Any character or list of two characters, e.g.: █ ░ ▪ ▫ ▬ ▭ ○ ● |
URxvt.cdmn.sidebar.border.visible | Show border | 1 (0) | IfURxvt.cdmn.sidebar.position set tobottom ortop |
Most of these settings should be self-explanatory. Some values are only taken into account with specific sidebarpositions. For instance, if you setURxvt.cdmn.sidebar.position
toleft
orright
, only your setting forURxvt.cdmn.sidebar.width
will be honored whereasURxvt.cdmn.sidebar.height
will be fixed at 100%. Similarly, if yousetURxvt.cdmn.sidebar.position
totop
orbottom
only your setting forURxvt.cdmn.sidebar.height
will be honoredwhereasURxvt.cdmn.sidebar.width
will be fixed at 100%. Finally,center
will set both, width and height, to 100% andignore any of your settings for width and height. In addition you can decide if you would like to have a border when youposition the sidebar left or right.
For the graphs shown on each pane you can set the symbols to use. Generally, there are two symbols. One symbols servesas the background and the other serves as the indicator. But you can also leave out the second symbols if you want tohave a transparent effect. Depending on the order you can decide how the graphs will fill - either from left to right orvice-versa. Just play with the settings and see what fits best for you!
cdmn tries hard to watch for any changes. For instance, if you remove your laptop from any power supply,cdmnwill be aware of this change and render the label next to your battery gauge(s) differently by removing theflash symbol.
If you do not overwrite the default settings,cdmn will show you everything available and all changes it becomesaware of. On the other hand, if you do define some overwritescdmn will show you only those. If a specified deviceis not available, it will be simply ignored until it is available.
With reference to therobustness principle cdmn will silentlyignore incompatible or invalid values or configurations and apply defaults where applicable.
In addition, if you do not tell cdmn anything it will assume everything. This is also true if only invalidvalues have been supplied for any resource. Say you want to view gauges for eth0 and eth1 but actually the interfacenames are enp3s0 und enp3s1. After validation this would result in an empty list which tocdmn is the same as if thisresource had not been configured. Thereforecdmn would fall back to its default setting: and show everything there is.
On the other hand,cdmn will not show anything where nothing is to be shown. For example, if you tellcdmn to shownetwork gauges but your network cable is not plugged in, gauges for this interface will not be shown. If allinterfaces are down the network caption will not show up, at all.
It might happen that your distribution does not offer version 9.22 of rxvt, even not via backports or other repositories.In this case you can still compile rxvt yourself. I recommend to first install the available version of yourdistribution anyway to pull in all its dependencies. Then uninstall it directly afterwards (but keep the dependencies).Now you can build rxvt yourself. This should take less than 5 minutes. Here is what you need to do on Debian:
First you will need to install some development packages to compile rxvt with all the necessary features.
sudo apt-get install libxft-dev libperl-dev checkinstall
Get the source fromhttp://dist.schmorp.de/rxvt-unicode/ and extract it to aplace of your liking. Navigate into the just extracted folder and run the following commands:
patch src/rxvtperl.xs /path/to/cdmn/resources/rxvtperl.xs.patch ./configure --enable-everything --enable-256-color make sudo checkinstall
After that a package with the namerxvt-unicode
will be installed and you should be able to callurxvt
.
Here are som example colors you can use forURxvt.cdmn.gauges.colors
or any of theoverwrites.
Colors | Example |
---|---|
22,46 | |
58,226 | |
18,27 | |
54,200 | |
23,87 | |
52,196 |
If you prefer the led style you might want to have more indicators.
Colors | Example |
---|---|
52,88,124,160,196 | |
22,28,34,40,46 | |
17,18,19,20,21 | |
236,241,246,251,231 |
As described in the section onvisual styles the first color always defines thebackground color.
This extension is with relevance to its current stagebleeding edge alpha.If you followed the installation instructions above it should run on any Debian-based distribution, though.
Check the projects backlog to see what I am currently working on andwhat is planned for the future.
Fork it, make a Pull Request, create Issues with suggestions, bugs or questions ... You are always welcome tocontribute!
Like cdmn? Follow me and/or the repository on GitHub.
GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007
About
perl extension for urxvt