LinkedIn Sourceforge Twitter

Vincent's Blog

Pleasure in the job puts perfection in the work (Aristote)

Tint2 snippet for network

Posted on 2018-03-28 20:38:00 from Vincent in Open Bsd Tint2

As discussed in this blog, I'll detail my Network snippet for Tint2.


Context

I just remind you that this snippet for Tint2 allow me to display an icon on my status bar for all what concerns Network.

As presented in this blog, there are several statuses for this icon.

In the following screenshots, the Network icon is the 1st one:






Details

Source code is available here

This Network snippet for Tint2 allows me to quickly see if I'm connected and how. The icons are different if I'm connected by cable or via wifi. The icon is different based on the signal of the wifi.

Automatic installation

There is no pre-requisits for this script. It just use standard tools and commaands.

For the installation, I provide you a Makefile doing the tasks for you. Just do:

make install

This script will modify your ~./config/tint2/tint2rc file !!!!.

Manual installation

If you prefer, you can do the installation manually by doing the following:

Add the following elements in your ~/.config/tint2/tint2rc file

#-------------------------------------
# Executor 1
execp = new
execp_command = ~/.config/tint2/check_network.sh
execp_interval = 3
execp_has_icon = 1
execp_cache_icon = 1
execp_continuous = 0
execp_markup = 1
execp_tooltip = Check network connectivity
execp_lclick_command = ~/.config/tint2/check_network.sh -name
execp_rclick_command =
execp_mclick_command =
execp_uwheel_command =
execp_dwheel_command =
execp_font_color = #000000 100
execp_padding = 1 0
execp_background_id = 0
execp_centered = 0
execp_icon_w = 28
execp_icon_h = 0

In my case the Network icon is located on the 1st executor this explains the 1st line.

If you adapt the tint2rc file with an editor, do not forget to adapt the following element by Adding an "E" at the good place:

panel_items =

Finally perform some copies on ~/.config/tint2:

cp check_network.sh ~/.config/tint2
cp -r icons/* ~/.config/tint2/icons/
chmod +x ~/.config/tint2/check_network.sh

Parameters to adapt

There are no parameters to adapt. Normally the script will detect it self your cable and wifi interfaces.

I've not been able to test it on lot of machines, so it could fail on yours :(

What does the NFS snippet ?

The check_network.sh script will be executed every 3 seconds (cfr execp_interval) and will return the path to the appropriate icon.

First, by using the ifconfig command, it will detect which interfaces are available on your machine.

Then, it will check if you are using a cable or wifi connection

In case of Wifi, he will determine the level of the signal he receives.

On each of those tests, the associated icon will be different.

Possible inter-actions

By clicking on the button, IF YOU are connected on wifi, it will display the name of the wifi used in a small xterm box.

Useful when you have several wifi available



0, 0
displayed: 871



What is the first letter of the word Python?