Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

perl extension for urxvt

License

NotificationsYou must be signed in to change notification settings

Jeansen/cdmn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CII Best Practices

cdmn

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!

Curious? Run the demo!

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

Installation

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: cdmnto 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.

Using cdmn with wireless NICs

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

Default keysyms

KeysymFunction
Meta-lShow/Hide left labels
Meta-oShow/Hide captions in overlay mode
Meta-hShow/Hide captions in normal mode
Toggle between overlay to normal mode
Meta-pShow/Hide sidebar
Meta-kShow next pane
Meta-jShow previous pane
Ctrl-kScroll up in current pane
Ctrl-jScroll 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.

How to use cdmn

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-kto 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 ;-)

How to customize cdmn

Following is a list of gauges you can customize to your liking:

Gauge nameDescription
diskDisk utilization
cpuCPU utilization
memoryAvailable/Used memory
networkNetwork utilization
cpu_tempCPU temperature
batteryBattery status
mountUsed/remaining space for mount points
hidppBattery status of HID++ devices (Mice, Keyboard, ...)

Labels

Labels can be defined with the following resources. Each label defines the text you would like to see next to thecorresponding gauges:

ResourceDefault
URxvt.cdmn.label.diskDISK
URxvt.cdmn.label.cpuCPU
URxvt.cdmn.label.memoryMEM
URxvt.cdmn.label.networkNET
URxvt.cdmn.label.cpu_tempTEMP
URxvt.cdmn.label.batteryBAT
URxvt.cdmn.label.mountMOUNT
URxvt.cdmn.label.hidppHID
URxvt.cdmn.label.swapSWAP

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.

ResourceFunctionDefault (Other)
URxvt.cdmn.label.fgForeground color for all labels.-2 (0-155)
URxvt.cdmn.label.bgBackground color for all labels.-1 (0-155)
URxvt.cdmn.caption.bgGlobal 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:

ResourceFunctionDefault (Other)
URxvt.cdmn.label.boldBold labelsfalse (true)
URxvt.cdmn.label.positionLabels positionleft (right)

Layout

Starting with the layout, you can define the position, order, initial visibility and more with the following resources.

ResourceFunctionDefault
URxvt.cdmn.paddingHow much space (in characters) you would like to have between each caption (label + gauges).2
URxvt.label.paddingHow much space (in characters) you would like to have between a label and its gauges.1
URxvt.cdmn.xHorizontal position (by character) where values >= 0 will result in a left alignment and negative numbers in a right alignment.-1
URxvt.cdmn.yVertical position (by row) where 0 will be the first line and -1 the last.0
URxvt.cdmn.gauges.orderList of gauges to show and their order. This list must contain existing labels.CPU,DISK,MEM,NETWORK
URxvt.cdmn.showingInitially show gauges.1
URxvt.cdmn.showing.labelsInitially 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 provideURxvt.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 areURxvt.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

Visual styles

Eachavailable gauge has the following settings that you can useto adapt its visual style.

ResourceFunctionDefault (Other)
URxvt.cdmn.<guage>.styleThe kind of gauges you prefer. Either a bar that can grow and shrink or simple flashing LED.bar (led)
URxvt.cdmn.<guage>.graph.widthWidth of graph in samplings, for example 5.not set
URxvt.cdmn.<guage>.graph.expandIf graph width should take up as much space as possible.not set
URxvt.cdmn.<guage>.detailHow much detail, e.g. a gauge for every logical core or just one gauge.true (false)
URxvt.cdmn.<guage>.invertInvert colors.true (false)
URxvt.cdmn.<guage>.colorsThe colors to be used apart from any global setting.true (false)
URxvt.cdmn.<guage>.inverseInverse 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.

ResourceFunctionDefault (Other)
URxvt.cdmn.visual.alignmentVertical or horizontal alignment.row (col)
URxvt.cdmn.style.bar.symbolsSymbols to use forURxvt.cdmn.<guage>.style: bar⎯,▁,▂,▃,▄,▅,▆,▇,█
URxvt.cdmn.style.led.symbolSymbol to use forURxvt.cdmn.<guage>.style: led

Visual styles - gauges colors

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.

Visual styles - refresh rate and sensitivity

Even further tweaking is possible with options such as the refresh rate and sensitivity.

ResourceFunctionDefault (Other)
URxvt.cdmn.refreshHow often to take samples in seconds. Decimal numbers are possible, for example 0.1 for every 100 milliseconds.1
URxvt.cdmn.sensitivityThreshold at which to show changes1

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.

Miscellaneous settings

Finally there are even more settings ...

ResourceFunctionDefault (Other)
URxvt.cdmn.disk.mountsonlyOnly show disk gauges for disks with at least one mount point.true (false)
URxvt.cdmn.allow-new-devicesAdd 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.

Custom keysyms

If you do not like the defaultkeysyms, you can change them:

ResourceDefaultFunction
URxvt.cdmn.Keysym.labels.showMeta-lShow/Hide labels
URxvt.cdmn.Keysym.overlay.toggleMeta-oShow/Hide cpations in overlay mode
URxvt.cdmn.Keysym.toggleMeta-hShow/Hide cpations in normal mode
Toggle between overlay to normal mode
URxvt.cdmn.Keysym.sidebar.toggleMeta-pShow/Hide sidebar
URxvt.cdmn.Keysym.sidebar.pane.nextMeta-kShow next pane
URxvt.cdmn.Keysym.sidebar.pane.prevMeta-jShow previous pane
URxvt.cdmn.Keysym.sidebar.scroll.upCtrl-kScroll up in current pane
URxvt.cdmn.Keysym.sidebar.scroll.downCtrl-jScroll down in current pane
URxvt.cdmn.Keysym.sidebar.shrinkCtrl-periodShrink the sidebar by one column
URxvt.cdmn.Keysym.sidebar.expandCtrl-commaExpand the sidebar by one column

How to customize the sidebar (so far)

Now, while still in development, there are already some things that work and that you can customize:

ResourceFunctionDefault (Other)Notes
URxvt.cdmn.sidebar.bgBackground colorTerminal background (0-255)
URxvt.cdmn.sidebar.fgForeground colorTerminal foreground (0-255)
URxvt.cdmn.sidebar.border.fgBorder colorTerminal foreground (0-255)
URxvt.cdmn.sidebar.widthHow much space to use for the sidebar in percentages50 (30-100)IfURxvt.cdmn.sidebar.position set toleft orright
URxvt.cdmn.sidebar.heightHow much space to use for the sidebar in percentages40 (30-100)IfURxvt.cdmn.sidebar.position set tobottom ortop
URxvt.cdmn.sidebar.positionSidebar positionright (top, bottom, left, center)
URxvt.cdmn.sidebar.header.positionHeader positiontop (bottom)
URxvt.cdmn.sidebar.label.positionLabel position for graphstop (bottom)
URxvt.cdmn.sidebar.label.detailIf the label should be the device name, real name or bothfull (simple, real)Fallback is 'simple' if set to real or full and the real name is not available
URxvt.cdmn.sidebar.graph.symbolsUse given symbols for depicting graphs'■, □' (ANY)Any character or list of two characters, e.g.:

█ ░
▪ ▫
▬ ▭
○ ●
URxvt.cdmn.sidebar.border.visibleShow border1 (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!

Context awareness

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.

Some words about robustness

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.

How to compile rxvt-unicode

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.

Example Colors

Here are som example colors you can use forURxvt.cdmn.gauges.colors or any of theoverwrites.

ColorsExample
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.

ColorsExample
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.

Please note

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.

What's next (without priority)

Check the projects backlog to see what I am currently working on andwhat is planned for the future.

Contributing

Fork it, make a Pull Request, create Issues with suggestions, bugs or questions ... You are always welcome tocontribute!

Self-Promotion

Like cdmn? Follow me and/or the repository on GitHub.

License

GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007

About

perl extension for urxvt

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp