LinkedIn Sourceforge

Vincent's Blog

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

Tint2 snippet for Battery

Posted on 2018-03-30 19:25:00 from Vincent in OpenBSD Desktop Tint2

As discussed in this blog, I'll detail battery 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 battery.

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

In the following screenshots, the NFS icon is the 4rd one:





Details

Source code is available here

This battery snippet for Tint2 allows me to quickly see the level of my battery discharging and charging.

Automatic installation

There is no pre-requisites for this script. It just use standard tools and commands.

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 4
execp = new
execp_command = ~/.config/tint2/check_battery.sh
execp_interval = 3
execp_has_icon = 1
execp_cache_icon = 1
execp_continuous = 0
execp_markup = 1
execp_tooltip = Battery status
execp_lclick_command = xterm -hold -geometry 65x4 -e "apm"
execp_rclick_command =  ~/.config/tint2/toggle_screenbrightness.sh
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 = 30
execp_icon_h = 0

In my case the Battery icon is located on the 4rd 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_battery.sh ~/.config/tint2
cp toggle_screenbrightness.sh ~/.config/tint2
cp -r icons/* ~/.config/tint2/icons/
chmod +x ~/.config/tint2/check_battery.sh
chmod +x ~/.config/tint2/toggle_screenbrightness.sh

Parameters to adapt

There is no parameter to adapt. The script should find all elements on is own

What does the battery snippet ?

The check_battery.sh script checking the apm results return the associated icon

Possible inter-actions

by right clicking on the battery icon you can play with the screen brightness.
The toggle_screenbrightness.h script allow you to modify the screen brightness between low, medium, high.

I've developed this because on my DELL E5450 the ACPI parameters are not correct for what concerns the brightness buttons. This is a workaround that allow me to easily reduce the screen brightness when I'm in a dark room or increase it when I'm outside with my laptop.

Please note that this script write a file /tmp/.brightness to store the current displayed value.

You can also left click on the battery to see the output of the apm command. This allow me to see how much time I can continue to work with my battery.



30, 30
displayed: 4814



What is the first letter of the word Moon?