You are not logged in.

#351 2012-08-16 19:33:23

moetunes
Member
From: A comfortable couch
Registered: 2010-10-09
Posts: 1,021

Re: dminiwm snapwm & bipolarbar

I think that looks fine. Works as it should do too.

Last edited by moetunes (2012-08-16 19:34:22)


You're just jealous because the voices only talk to me.

Offline

#352 2012-08-16 19:41:40

stlarch
Member
From: hell
Registered: 2010-12-25
Posts: 1,250

Re: dminiwm snapwm & bipolarbar

Ok, cool. I'll go ahead and update them.

Offline

#353 2012-08-18 20:48:03

moetunes
Member
From: A comfortable couch
Registered: 2010-10-09
Posts: 1,021

Re: dminiwm snapwm & bipolarbar

Some larrythewindowmanager news.

I wanted a simpler code base to hack on and improve reading configurations from conf files, so I removed about 700 lines from snapwm, called it a window manager and pushed it to git.
There's no bar, but there's an option in the rc.conf for turning on/off outputting desktop info to stdout for use in bipolarbar etc.
There's only vertical and fullscreen tiling modes, so it might be a better option for netbook users.
There's only two conf files, rc.conf and key.conf. rc.conf has a new option for setting an app to open on a specific desktop, see the sample.rc.conf file for clues.
Here's a pic :
tZjVocg

Currently the development roadmap is to try and reduce the memory used from reading conf files, I'm thinking using malloc might help there, and to seperate updating keys and everything else with different keyboard shortcuts.

Cheers


You're just jealous because the voices only talk to me.

Offline

#354 2012-08-19 12:55:32

synorgy
Member
From: $HOME
Registered: 2005-07-11
Posts: 272
Website

Re: dminiwm snapwm & bipolarbar

I've been using snapwm for about 2 months now and I'm rather loving the whole concept. I do have one small nitpick: I can't seem to get "special" characters to work in my status bar.

For instance, I've hacked together a font containing icons (tamzenicons) and have set snapwm to use this font, using the full font string from xlsfonts. I've changed the layout indicators in rc.conf to use the characters/icons in my font, and these work just fine.

However, I've got a small C program that loops every few seconds to set my status bar and this makes use of some iconic characters as well. None of the iconic characters I output to the status bar are shown. I've looked at the drawstatus() function and, despite not being a C programmer (or not much of one, anyway), this looks like it should work. I've proven to myself that it's certain characters in the status bar by setting the characters I use in the statusbar as the desktop indicator characters, and they work there. Anyone have any suggestions?


"Unix is basically a simple operating system, but you have to be a genius to understand the simplicity." (Dennis Ritchie)

Offline

#355 2012-08-19 13:31:47

stlarch
Member
From: hell
Registered: 2010-12-25
Posts: 1,250

Re: dminiwm snapwm & bipolarbar

@synorgy, how are you doing it? Are you copy and pasting the symbol into your script? Can you maybe give a link to the font, and I'll try it out?

Offline

#356 2012-08-19 13:53:48

synorgy
Member
From: $HOME
Registered: 2005-07-11
Posts: 272
Website

Re: dminiwm snapwm & bipolarbar

I'm using vim to edit either the source file for my status bar setter or the rc.conf file. Inputting the character in vim is C-v+u+{char code}.  I've also used "echo -e '\x{code}' | xargs xsetroot", which gave me exactly the same results. The font is hosted here (Might want to wget it, since it comes up as a text file, at least for me).

C0 - CA are the characters I'm having trouble with in the statusbar (though it also seems that the degree symbol isn't being output either - and that's at B0.)


EDIT: After some light testing - it seems that the last functional character I can print in the statusbar is 7E. This falls in line with the end of ASCII - which is at 7F. Maybe that's part of the problem?

Last edited by synorgy (2012-08-19 13:57:01)


"Unix is basically a simple operating system, but you have to be a genius to understand the simplicity." (Dennis Ritchie)

Offline

#357 2012-08-19 15:40:19

stlarch
Member
From: hell
Registered: 2010-12-25
Posts: 1,250

Re: dminiwm snapwm & bipolarbar

I took a look at your font and noticed a few things that might be a little problematic. I have to leave now but I'll test it more when I get home later.

Offline

#358 2012-08-19 19:33:55

moetunes
Member
From: A comfortable couch
Registered: 2010-10-09
Posts: 1,021

Re: dminiwm snapwm & bipolarbar

@synorgy, it's always good to here someone's enjoying the wm. Have you tried a font like terminusmod to check that your status program presents the font right? If that works ok maybe stlarch will find something with your font...

@stlarch, how's the first grandson doing?


You're just jealous because the voices only talk to me.

Offline

#359 2012-08-19 19:52:40

stlarch
Member
From: hell
Registered: 2010-12-25
Posts: 1,250

Re: dminiwm snapwm & bipolarbar

Ha! Still waiting. I'm pretty much bouncing off the walls. It's driving me nuts. Anyway, I did notice a few things about your font synorgy, like the spacing got changed to 12x8 instead of 12x7 (I don't know if you meant to do that or not), and a couple other things that shouldn't really make a difference I don't think. I changed all of that and I still wasn't getting any output on the right side of the bar (status part). So I tested it with some of my fonts that are the same size, 7x12, and they don't work either? I tried termsyn, ohsnap, and sunaku's Tamzen and none work. All of the other sizes work, and they all work in bipolarbar, so I can only assume it's something with snapwm. It doesn't seem to like that size. I'm not sure what else to do. Just to clarify, other 12's work, like terminusmod, which is 12x6, but just not any 12x7 that I've tested it with.

Last edited by stlarch (2012-08-19 19:53:57)

Offline

#360 2012-08-19 20:50:11

moetunes
Member
From: A comfortable couch
Registered: 2010-10-09
Posts: 1,021

Re: dminiwm snapwm & bipolarbar

Nice job checking in bipolarbar stlarch, the function that finds the fonts is the same in it and snapwm, so there shouldn't be a difference. I changed the font in snapwm to termsyn and the icons that come from terminusmod changed to accented characters as expected, everything showed up. I'll install ohsnap and see how it goes.


You're just jealous because the voices only talk to me.

Offline

#361 2012-08-19 21:22:09

moetunes
Member
From: A comfortable couch
Registered: 2010-10-09
Posts: 1,021

Re: dminiwm snapwm & bipolarbar

Termsyn and ohsnap work fine here at size 12. ohsnap.icons works great.

tZjV2ZQ

That doesn't mean there isn't a problem, just that's it's hard for me to sort out since it works here.


You're just jealous because the voices only talk to me.

Offline

#362 2012-08-19 21:53:57

stlarch
Member
From: hell
Registered: 2010-12-25
Posts: 1,250

Re: dminiwm snapwm & bipolarbar

You know what, I'm an idiot. I really should stop drinking. It was because of the window name length. I had it set right up to the edge of my script, and obviously, the extra space (7 versus 6 for each letter) must have pushed it off the edge. Doooh. Sorry about that. Everything seems fine now I think. And synorgy, I redid your font if you want to try it. It seems to be working fine here now. Like I said, I changed the spacing to 12x7, and added an empty space at 00A0, and renamed 00A0 - 00FF. It's here, http://ompldr.org/vZjV3OQ .

Last edited by stlarch (2012-08-19 21:56:37)

Offline

#363 2012-08-19 21:56:56

moetunes
Member
From: A comfortable couch
Registered: 2010-10-09
Posts: 1,021

Re: dminiwm snapwm & bipolarbar

So it's all good then? Great. I'll stop trying to fix it then wink

Cheers smile


You're just jealous because the voices only talk to me.

Offline

#364 2012-08-19 22:02:49

stlarch
Member
From: hell
Registered: 2010-12-25
Posts: 1,250

Re: dminiwm snapwm & bipolarbar

Yeah, I think so. Sorry.

Offline

#365 2012-08-19 22:28:44

synorgy
Member
From: $HOME
Registered: 2005-07-11
Posts: 272
Website

Re: dminiwm snapwm & bipolarbar

This is really strange. I've changed the version you posted (and thanks for the fixes - never realized I borked the font as I did), but I'm still getting nothing. I'll look more into it and keep you all up to date (if I ever get an answer)


"Unix is basically a simple operating system, but you have to be a genius to understand the simplicity." (Dennis Ritchie)

Offline

#366 2012-08-21 08:32:09

moetunes
Member
From: A comfortable couch
Registered: 2010-10-09
Posts: 1,021

Re: dminiwm snapwm & bipolarbar

@synorgy, did you end up with your font showing in the bar?
Once I had converted the .bdf to .pcf I had to follow this, especially the mkfontdir bit.

Here's a pic:
tZjZmeA
HTH

Cheers


You're just jealous because the voices only talk to me.

Offline

#367 2012-08-21 14:08:19

synorgy
Member
From: $HOME
Registered: 2005-07-11
Posts: 272
Website

Re: dminiwm snapwm & bipolarbar

I think I've figured it out...sort of.
If I do something like this:

    $ echo -e "\xC2" | xargs xsetroot -name

I get nothing.

However this works:

    $ xsetroot -name "{char}"

I'm also getting the same problems with my C status setter program (the relevant function below). printf'ing the string works just fine, but passing it into the function leads to the "special" (read: non-ascii) characters getting stripped upon display.

void setstatus(char *str) {
    XStoreName(dpy, DefaultRootWindow(dpy),str);
    XSync(dpy, False);
}

xprop -root gives me the proper string as the root name (including the special character/s) after setting the rootname via my C program, so I'm *REALLY* confused as to what the problem could be hmm

I see how I was wrong in the first "echo" test, but I'm not sure what I can do differently to get this to work in my status bar program. Suggestions?


"Unix is basically a simple operating system, but you have to be a genius to understand the simplicity." (Dennis Ritchie)

Offline

#368 2012-08-21 20:51:31

moetunes
Member
From: A comfortable couch
Registered: 2010-10-09
Posts: 1,021

Re: dminiwm snapwm & bipolarbar

The XmbDraw functions don't interpret codes for glyphs (e.g. '\xC2' , '0xC2'), they just show a space. The terminal where you show xprop -root does alot more with fonts and strings which is why the glyphs show up there.
So it will come down to how you present the non ascii glyphs in your call to XStoreName. Without seeing your code I can guess a solution would be to sprintf(nuther_str, str) and send nuther_str to setstatus.
If you can't get it working paste your code and I'll see what I can come up with. It might give me a clue as to how I can make this part of the wm a bit friendlier.

Cheers


You're just jealous because the voices only talk to me.

Offline

#369 2012-08-22 00:53:11

synorgy
Member
From: $HOME
Registered: 2005-07-11
Posts: 272
Website

Re: dminiwm snapwm & bipolarbar

@moe - if you'd like to take a look over what I've got, I'd greatly appreciate it. The glyphs are already "hardcoded" into the source (this seems to be the solution to gave in another thread I found while researching your above suggestions).

As the file is ~300 sloc - partially due to my poor c-fu - you can look over the file here.


PS: There're a *TON* of holes in the logic, I know. Also: I do VERY close to zero error checking tongue


"Unix is basically a simple operating system, but you have to be a genius to understand the simplicity." (Dennis Ritchie)

Offline

#370 2012-08-22 23:05:18

moetunes
Member
From: A comfortable couch
Registered: 2010-10-09
Posts: 1,021

Re: dminiwm snapwm & bipolarbar

@synorgy, I couldn't build your program here as it was so I had a bit of a play and changed the approach to suit my style. I changed the char()'s to voids and added some global variables for printing and changed some stuff to try and speed it up a little. I'm going to play with it some more to try and lighten it up some but this shows in the bar fine :

#define _BSD_SOURCE

#include <X11/Xlib.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <strings.h>
#include <sys/time.h>
#include <time.h>
#include <sys/times.h>
#include <sys/vtimes.h>
#include <sys/types.h>
#include <sys/wait.h>

#define CPUFILE "/proc/stat"
#define MEMFILE "/proc/meminfo"
#define BATTFILE "/sys/class/power_supply/BAT0/uevent"
#define TEMPFILE1 "/sys/bus/platform/devices/coretemp.0/temp2_input"
#define TEMPFILE2 "/sys/bus/platform/devices/coretemp.0/temp4_input"
#define TZ_NY "Australia/Brisbane"

static void get_cpu_perc();
static void get_mem_perc();
static void get_batt_perc();
static void get_temps();
static void mktimes();

static Display *dpy;

// We don't need new values for everything everytime so
// store values in variables to be printed
static char cpu_ret[20];
static char mem_ret[10];
static char batt_ret[20];
static char temps_ret[10];
static char time_ret[10];

//Needed in get_cpu_perc()
static int i4,i5,i6;
static double ti;

double time_so_far() {
    struct timeval tp;

    if (gettimeofday(&tp, (struct timezone *) NULL) == -1)
        perror("gettimeofday");
    return ((double) (tp.tv_sec)) +
        (((double) tp.tv_usec) * 0.000001 );
}

void get_cpu_perc() {
	FILE *f1;
	double tf;
	
	char c[10];
	int i1,i2,i3;

	memset(cpu_ret, '\0', 10);
	tf = time_so_far();
	f1 = fopen(CPUFILE, "r");
	fscanf(f1, "%s\t%d\t%d\t%d\n", c, &i1, &i2, &i3);
	fclose(f1);

	int t = (i1+i2+i3)-(i4+i5+i6);
	sprintf(cpu_ret, "%.1f%%", (t / ((tf-ti) * 100)) * 100);
    i4=i1; i5=i2; i6=i3; ti=tf;
    return;
}

void get_mem_perc() {
    FILE* file = fopen(MEMFILE, "r");
    long Active, Total;
    int Perc;

	memset(mem_ret, '\0', 10);
    if (file != NULL) {
        char line[100];
        while(fgets(line, sizeof line, file) != NULL) {
            if (strncmp(line, "Active:",7) == 0) {
                sscanf(line, "Active: %d kB", &Active);
            } else if (strncmp(line, "MemTotal:", 9) == 0) {
                sscanf(line, "MemTotal: %d kB", &Total);
            }
        }
    }
    fclose(file);

    if ((Active > 0) && (Total > 0)) {
        Perc = (Active*100) / Total;
        sprintf(mem_ret, "%d%%", Perc);
    } else sprintf(mem_ret, "???");
    return;
}

void get_batt_perc() {
    FILE *Batt;
    char  buffer[80];
    char *battstatus, *chargenow, *lastfull;
    unsigned int perc;
    long nowcharge, fullcharge;

    Batt = fopen( BATTFILE, "rb" ) ;
    if ( Batt == NULL ) {
        fprintf(stderr, "\t\033[0;31mCouldn't find %s\033[0m \n", BATTFILE);
        return;
    } else {
        while(fgets(buffer,sizeof buffer,Batt) != NULL) {
            if(strstr(buffer,"POWER_SUPPLY_STATUS=") != NULL) {
                battstatus = strndup(strstr(buffer, "=")+1, strlen(strstr(buffer, "=")+1)-1);
                //strncpy(battstatus, strstr(buffer, "=")+1, strlen(strstr(buffer, "=")+1)-1);
            } else if(strstr(buffer,"POWER_SUPPLY_CHARGE_FULL=") != NULL) {
                lastfull = strstr(buffer, "=");
                fullcharge = atoi(lastfull+1);
            } else if(strstr(buffer,"POWER_SUPPLY_CHARGE_NOW=") != NULL) {
                chargenow = strstr(buffer, "=");
                nowcharge = atoi(chargenow+1);
            }
        }
        fclose(Batt);
        perc = (nowcharge*100)/fullcharge;
        sprintf(batt_ret, "%s &5%d%%", battstatus, perc);
    }

}

void get_temps() {
    FILE* file1 = fopen(TEMPFILE1, "r");
    FILE* file2 = fopen(TEMPFILE2, "r");
    //FILE* nv_p = popen("nvidia-settings -tq [gpu:0]/GpuCoreTemp", "r");

    int  temp1 = 0, temp2 = 0; // , nv_temp = 0;

	memset(temps_ret, '\0', 10);
    fscanf(file1, "%d", &temp1);
    fscanf(file2, "%d", &temp2);
    //if ( nv_p != NULL) 
      //  fscanf(nv_p, "%d", &nv_temp);

    //pclose(nv_p);
    fclose(file1);
    fclose(file2);

    //if (nv_temp != 0) {
      //  sprintf(temps_ret, "&0&2%d %d %d", temp1/1000, temp2/1000, nv_temp);
    //} else {
        sprintf(temps_ret, "%d %d", temp1/1000, temp2/1000);
    //}
    return;
}

void mktimes() {
	struct tm tm; 
	time_t	time_value = time(0);
	tm = *localtime(&time_value);
	
	int hours = tm.tm_hour;
	int minutes = tm.tm_min;
	int secs = tm.tm_sec;	

	sprintf(time_ret, "%d:%d:%d", hours, minutes, secs);
	return;
}

void
setstatus(char *str) {
	//printf("%s\n", str);
	XStoreName(dpy, DefaultRootWindow(dpy), str);
	XSync(dpy, False);
}

int
main(void) {
    char status[256];
    unsigned int count = 0;

	if (!(dpy = XOpenDisplay(NULL))) {
		fprintf(stderr, "dwmstatus: cannot open display.\n");
		return 1;
	}

	//setenv("TZ", TZ_NY, 1);
        // only get new values for somethings sometimes
	while(1) {
        if(count == 0 || count == 30) {
            get_batt_perc();
            count = 0;
        }
        get_mem_perc();
        if(count == 0 || count == 15) {
            get_temps();
        }
        get_cpu_perc();
        mktimes();

        sprintf(status, "%s &1 ± &4TEMPS&6 %s &1Î &4MEM&6 %s &1 µ &4CPU&6 %s&1 É &4TIME&6 %s ",
             batt_ret, temps_ret, mem_ret, cpu_ret, time_ret);
		setstatus(status);
        ++count;
		sleep(3);
	}
	XCloseDisplay(dpy);

	return 0;
} 
 

I don't use mpd here so that's not in there. I build it with

gcc status.c -o status_output -lX11

It's my usual hackery but hopefully it will give you some clues to have your program outputting the non ascii characters so snapwm can show them. This was a fun little distraction . wink

Cheers


You're just jealous because the voices only talk to me.

Offline

#371 2012-08-24 02:30:21

moetunes
Member
From: A comfortable couch
Registered: 2010-10-09
Posts: 1,021

Re: dminiwm snapwm & bipolarbar

I've been playing some more with getting system info to show in a bar.
I've refined my status program and added some options. I've changed the get_cpu_perc function to find and report on all cores, added a function to find the wifi's signal strength, changed the memory reported to be in MiB not a percent and simplified getting the info where I could.
I've added the status.c and the little programs I made along the way to sort different bits out to github. There's build instructions at the top of the .c files, some need different libaries included like the wireless needs -liw . They might be useful for someone to have a play with.
Anyway here's a pic of larrythewindowmanager and bipolarbar with the status info:

tZjd3bg

Cheers

Last edited by moetunes (2012-08-24 22:46:45)


You're just jealous because the voices only talk to me.

Offline

#372 2012-08-25 14:11:13

synorgy
Member
From: $HOME
Registered: 2005-07-11
Posts: 272
Website

Re: dminiwm snapwm & bipolarbar

Moe - Your changes worked just fine. I'll have to remember to sprintf into a modified string before handing it off. Thanks for the help!


"Unix is basically a simple operating system, but you have to be a genius to understand the simplicity." (Dennis Ritchie)

Offline

#373 2012-09-07 01:30:41

moetunes
Member
From: A comfortable couch
Registered: 2010-10-09
Posts: 1,021

Re: dminiwm snapwm & bipolarbar

It's been a while since I've made any noise here so I thought I'd drop a couple of notes today.

There's been a minor change and a fix pushed to snapwms' git. The way windows are ordered in stacking mode has changed so the last focused window is made current when a window is removed, and when a window is removed on an unfocused desktop the bar wasn't updating right so that's been fixed.

Mostly, in the little bits of free time I've had, I've been playing with getting different info to show in the bar. I added a file to git which can show the networks up/down speed and I found out it is much easier to change the colour depending on value in my own c program than it was in conky.
To give an example, the relevant lines in get_batt_perc() are:

c1 = (perc > 90) ? 5 : (perc > 30) ? 2 : 6;
sprintf(batt_ret, "%s &%d%d%%", battstatus, c1, perc);

which will set the colour for the percent left to &5 if it is above 90%, &2 if it is between 30% and 91% and &6 if it is 30% or less. I had never tried to do anything similar in conky as there seemed to be no obvious/simple way.
I'd seen that other people had been making their own c programs for showing system stats but had never bothered with my own as conky seemed to mostly do the job ok, but I've noticed reduced memory and cpu use using my own program compared to conky so thanks @ synorgy for bringing the subject up here smile

Cheers


You're just jealous because the voices only talk to me.

Offline

#374 2012-09-08 11:37:31

synorgy
Member
From: $HOME
Registered: 2005-07-11
Posts: 272
Website

Re: dminiwm snapwm & bipolarbar

@Moetunes - I'm glad you found the C status setter useful. I picked it up when I was using dwm (they actually have a small project for exactly that reason)

Today, I intend to see if there's some way that I can get changing of the background color working in the status bar. I know how it's done in dwm's status colors patch, but I've hardly looked over your source so you might have a significantly easier time about implementing it. I'll keep you all posted on progress big_smile


"Unix is basically a simple operating system, but you have to be a genius to understand the simplicity." (Dennis Ritchie)

Offline

#375 2012-09-08 11:48:52

moetunes
Member
From: A comfortable couch
Registered: 2010-10-09
Posts: 1,021

Re: dminiwm snapwm & bipolarbar

Have a look at the code for bipolarbar, the background colour changing stuff should more or less drop straight in. I have no idea how it's done in dwm but I'm pretty sure it won't be that compatible... wink


You're just jealous because the voices only talk to me.

Offline

Board footer

Powered by FluxBB