HDipstick: How to get 'Fore' and 'Back' to be the same size

batt

The image above is of my HDipstick which has the following colors set:

BackColor {rgb:B7/B7/B7}
ForeColor {rgb:FF/FF/FF}
ShadowColor {rgb:00/00/00}
HilightColor {rgb:00/00/00}

It also has this range and value:

 MinValue 0
 MaxValue 100
 Value 98

I have tried changing the values of the hilight/shadow, but I can’t get the background and foreground to touch. There is a black space between them, I would like gone.

Also, height of the background seems taller then the foreground. How can I make them even?

Is this Module FvwmButtons or FvwmIconMan?
Your image shows three colors… #000000, #b7b7b7 and #00ff00

It’s a FvwmScript inside FvwmButtons.

The FvwmButtons has the following set:

*ButtonPanel: Back black
*ButtonPanel: Frame 0
*ButtonPanel: Padding 0 0

Edit your image what it is supposed to look like, for me to understand your question.

batt

From where does the green color (#00ff00) come?

The green color comes from the ForeColor defined in the FvwmScript file.

Here is my FvwmScript (BatteryMonitor):

WindowTitle {BatteryMonitor}
WindowSize  100 20
BackColor {rgb:B7/B7/B7}
ForeColor {rgb:FF/FF/FF}
ShadowColor {rgb:00/00/00}
HilightColor {rgb:00/00/00}

Init
 Begin
  Set $Status = (GetOutput {exec /programs/qw_get_battery_status} 1 -1)

  If $Status < 16 Then
   ChangeForeColor 1 {red}
  Else
  Begin
   If $Status < 50 Then
    ChangeForeColor 1 {yellow}
   Else
   Begin
    If $Status < 85 Then
     ChangeForeColor 1 {cyan}
    Else
      ChangeForeColor 1 {green}
   End
  End

  ChangeValue 1 $Status
 End

PeriodicTasks
 Begin 
  If (RemainderOfDiv (GetTime) 60)==0 Then
  Begin
   Set $Status = (GetOutput {exec /programs/qw_get_battery_status} 1 -1)

   If $Status < 16 Then
    ChangeForeColor 1 {red}
   Else
   Begin
    If $Status < 50 Then
     ChangeForeColor 1 {yellow}
    Else
    Begin
     If $Status < 85 Then
      ChangeForeColor 1 {cyan}
     Else
       ChangeForeColor 1 {green}
    End
   End

  ChangeValue 1 $Status
  End
 End

Widget 1
Property
 Position 0 0
 Size 100 20
 Type HDipstick
 MinValue 0
 MaxValue 100
 Value 0
End

*EDIT:
I should state, the program /programs/qw_get_battery_status outputs a value between 0 - 100, based on the power remaining in the battery.

I assume this comes from “*ButtonPanel: Back black”. Try “Back #b7b7b7”. With FvwmButtons you may not get the widget to look as wanted but shape it by experimenting with different colors.

So the gap that exists in the widget HDipstick will be solved by changing my entire ‘ButtonPanel’ background? Not possible.

What about the difference in the foreground color height vs the background color height? Anyway to make them even, so it doesn’t look hacked together?

Test the script without FvwmButtons. Copy into a filename: BatteryMonitor.scp, and run it in FvwmConsole.
FvwmScript $[FVWM_USERDIR]/BatteryMonitor.scp

To remove titlebar…
Style Battery* NoTitle

I’m not understanding you, so you think the problem is solved by not using it in FvwmButtons, but by using FvwmConsole?

THis doesn’t make sense in my mind as I will be putting it back in FvwmButtons if it works. If it only works with FvwmConsole, then Ill look at making my own.

Just seems weird to me that when the foreground decreases, part of the background shows more than what’s behind the foreground. But I guess that explains why no one seems to use it.

Anyway, thanks for trying to help.

I don’t know if I should mark this as solved, since it can’t be done.

I didn’t ask you to start using FvwmConsole but to make one test. When I tested it, it looks fine. If it is ok for you, then run FvwmScript [FVWM_USERDIR]/BatteryMonitor.scp from a menu list. Or from a FvwmButton without putting the script inside a button. Or from one icon. There are many options how to run the scripts.

Tried it, still looks the same.

batt2

You are right. Now I pointed it to my battery status.
Set $Status = (GetOutput {exec cat /sys/class/power_supply/BAT0/capacity} 1 -1)

It is a widget issue. Most likely designed like that. Not sure if the backend source could fix it.
I tried to minimize the visual effect by changing the script colors.

BackColor {red}
ForeColor {rgb:FF/FF/FF}
ShadowColor {rgb:aa/aa/aa}
HilightColor {rgb:aa/aa/aa}

batteryMonitor

To look correctly, it seems only green does it.

ShadowColor {green}
HilightColor {green}

Battery 89%
batteryMonitor-green
84%
batteryMonitor-cyan

I appreciate your efforts, but It looks like the widget wasn’t originally built well. That “fix” won’t work with what I’m imagining.

I feel I have wasted too much time on this and will now just create my own.

Ty for trying though.

As a side note, I have been viewing a lot of lost configurations through the wayback machine. I came across a screenshot with the following shown:
bars

Can’t find any config file for it, and was wondering if someone here might know where it’s from or how to create it.

The caption beside the screenshot says:

Submitted by Shawn Anderson. After seeing An Thi-Nguyen Le’s screenshots(they are very nice BTW), I thought I would send one also :-). It is fvwm 2.3.28.

Ok, I created a c program that displays a colour status bar. The program take two or three arguments.

First argument is the number of columns to use for the display.
Second argument is the file to watch. It should only contain the percentage to be displayed…
The third, and optional argument is the time delay between updating, in seconds. The default is 60.

Some things need to be said…
First, this is a text based status bar. The number of columns can be increased to a ridiculous amount. The idea is that you can change the xterm display font the larger or smaller, and the number of columns to get the proper fit for what you want.

Here it is:

#include <errno.h>
#include <libgen.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <termios.h>
#include <unistd.h>

// Declare defines.
#define BUFFER_SIZE         10
#define CLEAR_SCREEN         puts("\e[2J\e[?25l")
#define COLOUR_BLUE          "\x1b[48;5;19m"
#define COLOUR_GREEN         "\x1b[48;5;34m"
#define COLOUR_GREY          "\x1b[48;5;236m"
#define COLOUR_RED           "\x1b[48;5;160m"
#define COLOUR_YELLOW        "\x1b[48;5;184m"
#define PROGRAM_NAME_SIZE   50
#define RESET                "\e[0m"

// Declare global variables.
char program_name[PROGRAM_NAME_SIZE + 1] = {0};

// Declare function prototypes.
void display_colour_bar (int columns, char *file, int seconds);

int main (int argc, char *argv[])
{
// Declare variables.
	FILE *fp = NULL;

// Get program name for error reporting.
	strcpy(program_name, basename(argv[0]));

// Check arguments.  Must be at least 2 arguments with an optional 3rd.
	if(argc != 3 && argc != 4)
	{
		fprintf(stderr, "Usage: %s NUMBER_OF_COLUMNS FILE_TO_WATCH [SECONDS_BETWEEN_UPDATE]\n", program_name);
		exit(EXIT_FAILURE);
	}

// #1) Must be greater than 0.
	if(atoi(argv[1]) < 1)
	{
		fprintf(stderr, "Usage: %s " COLOUR_RED "NUMBER_OF_COLUMNS" RESET " FILE_TO_WATCH [SECONDS_BETWEEN_UPDATE]\n", program_name);
		exit(EXIT_FAILURE);
	}

// #2) Must be positive, including 0, but not exceeding 100.
// #2) File to monitor.  Must be a readable file.
//	if((argv[2][0] != '0' && atoi(argv[2]) < 1) || atoi(argv[2]) > 100)
	if((fp = fopen(argv[2], "rb")) == NULL)
	{
//		fprintf(stderr, "Usage: %s NUMBER_OF_COLUMNS " COLOUR_RED "PERCENT_INTEGER" RESET "[SECONDS_BETWEEN_UPDATE]\n", program_name);
		fprintf(stderr, "Usage: %s NUMBER_OF_COLUMNS " COLOUR_RED "FILE_TO_WATCH" RESET "[SECONDS_BETWEEN_UPDATE]\n", program_name);
		exit(EXIT_FAILURE);
	}

// Check past, close the file for now.
	fclose (fp);

// #3) (Optional) Time delay between updating, in seconds.  Must be greater than 0.
	if(argc == 4 && atoi(argv[3]) < 1)
	{
		fprintf(stderr, "Usage: %s NUMBER_OF_COLUMNS FILE_TO_WATCH " COLOUR_RED "[SECONDS_BETWEEN_UPDATE]" RESET "\n", program_name);
		exit(EXIT_FAILURE);
	}

// Run process.
//	display_colour_bar(atoi(argv[1]), atoi(argv[2]), argc == 4 ? atoi(argv[3]) : 60);
	display_colour_bar(atoi(argv[1]), argv[2], argc == 4 ? atoi(argv[3]) : 60);

// Exit cleanly.
	exit(EXIT_SUCCESS);
}

void display_colour_bar (int columns, char *file, int seconds)
{
// Declare variables.
	char buffer[BUFFER_SIZE + 1] = {0};
	FILE *fp = NULL;
	struct termios settings = {0};
	int x = {0};

// Clear screen and make cursor invisible.
	CLEAR_SCREEN;
// Get terminal attributes.
	tcgetattr(STDIN_FILENO, &settings);
// Set terminal to not echo.  This is needed to stop typing from showing up on xterm window.
	settings.c_lflag &= ~(ECHO);
	tcsetattr(STDIN_FILENO, TCSANOW, &settings);

// Loop forever.
	for(;;)
	{
// Open the file for reading.
		if((fp = fopen(file, "rb")) == NULL)
		{
			fprintf(stderr, "%s: %s error: fopen failed (%s) (%s)\n", program_name, __func__, strerror(errno), file);
			exit(EXIT_FAILURE);
		}

// Get data.
		fgets(buffer, BUFFER_SIZE, fp);
// Close the file.
		fclose(fp);
// Reset cursor and clear the line.
		printf("\e[1;0f\e[K");

// Set foreground colour.
		switch(atoi(buffer))
		{
			case 0 ... 15:
		 		printf(COLOUR_RED);
				break;
			case 16 ... 49:
		 		printf(COLOUR_YELLOW);
				break;
			case 50 ... 84:
		 		printf(COLOUR_GREEN);
				break;
			default:
		 		printf(COLOUR_BLUE);
		}

// Start displaying the status bar.
		for(x = 0; x < (columns * atoi(buffer)) / 100; x++)
			printf(" ");

// Set background colour.
		printf(COLOUR_GREY);

// Finish the status bar.
		for(; x < columns; x++)
			printf(" ");

// Reset the colours.
		printf(RESET);
// Flush out to screen.
		fflush(stdout);
// Wait for next iteration.
		sleep(seconds);
	}
}

Save it as colour_status_bar.c and compile with:

gcc -o colour_status_bar colour_status_bar.c

There will most likely be an update to this, like customizable colours from the command line. If others are interested, let me know and I will post any updates.