Tinkering w/ Haze WM

Under development: PCMCIA, wireless, etc.
Message
Author
goingnuts
Posts: 932
Joined: Sun 07 Dec 2008, 13:33
Contact:

#21 Post by goingnuts »

I tried to change to a simple printf function in the hope that errors would end up in xerrors.log - but they do not - why?

Code: Select all

void DrawErrMsgOnMenu( char *str1, char *str2 )
{
	//char *str;
	static int call=0;
	//int wait_s;

	call++;
	/*str = calloc( strlen(str1)+strlen(str2)+1, 1 );
	sprintf( str, "%s%s", str1, str2 );*/
	printf("hazewm error: %s%s\n", str1, str2);
	if( call<5 )	XBell( dpy, 30 );
	/*DrawStringMenuBar( str );
	wait_s = 3000000-call/5*500000;
	wait_s = wait_s>0? wait_s : 300000;
	sleep_a_little( wait_s );
	free( str );*/
}
Found a decent clock - ofclock - integrates nicely with hazewm. Although xclock have more settings I really just want to know the time...
ofclock wont swallow with jwm. Added that and some mouseclick action/control with below patch:

Code: Select all

--- ./ofclock.c.01	1999-01-23 11:49:14.000000000 +0000
+++ ./ofclock.c	2013-10-06 10:37:40.000000000 +0000
@@ -1,5 +1,6 @@
 /* digital clock for X  by Li Wei Jih & Olivier Fourdan */
 
+#include <stdlib.h>
 #include <stdio.h>
 #include <time.h>
 #include <string.h>
@@ -51,6 +52,7 @@
 #include "digits/fr.xbm"
 #include "digits/sa.xbm"
 
+char leftcommand[7] = "xcal &";
 char copyright[]= "digital clock for X by Li Wei Jih & Olivier Fourdan";
 char appname[255]= "clock";
 Pixmap dclock_pixmap, dclock_nosec_pixmap, digit_pixmap[11],
@@ -442,6 +444,17 @@
                                0, foreground, background);
 
   defdecor (*display, *window, (MWM_DECOR_MINIMIZE | MWM_DECOR_TITLE /* | MWM_DECOR_BORDER */));
+  
+  // Set classhint
+  XClassHint classHint;
+  classHint.res_name  = appname;
+  classHint.res_class = appname;
+  XSetClassHint(*display, *window, &classHint);
+  
+  // Set windowname
+  XStoreName(*display, *window, appname);
+  XSetIconName(*display, *window, appname);
+  
   loadpixmap(*display, *window);	/* load pixmaps */
 
   *gc= XCreateGC(*display, *window, 0, 0);
@@ -487,13 +500,23 @@
         showtime(display, window, gc,  timearray);
         break;
       case ButtonPress:
-          XRaiseWindow(display, window);
-          org_x= event.xbutton.x;	/* gets mouse position */
-          org_y= event.xbutton.y;	/* before moves clock */
-        break;
-      case MotionNotify:		/* moves clock */
-        XMoveWindow(display, window, 
-                    event.xmotion.x_root- org_x, event.xmotion.y_root- org_y);
+        if(event.xbutton.button == 1) {
+			//printf("left button pressed\n");
+ 			system(leftcommand);
+		}
+		if(event.xbutton.button == 2) {
+			//printf("middle button pressed\n");
+ 			no_second= !no_second;
+            changesize(display, window);
+            showtime(display, window, gc, timearray);
+		}
+		if(event.xbutton.button == 3) {
+			//printf("right button pressed\n");
+		 	hr12= !hr12;
+            getdigitstr(timearray);
+            showtime(display, window, gc, timearray);	
+ 		}
+                 
         break;
       case VisibilityNotify:
         switch (event.xvisibility.state)
Last edited by goingnuts on Sun 06 Oct 2013, 08:32, edited 1 time in total.

User avatar
Keef
Posts: 987
Joined: Thu 20 Dec 2007, 22:12
Location: Staffordshire

#22 Post by Keef »

This is a bad case of 'coding-by-Google' but this succeeds in writing to a file:

Code: Select all

void DrawErrMsgOnMenu( char *str1, char *str2 )
{
   FILE *file;
   file = fopen("haze_err.txt","a");
   char *str;
   static int call=0;
   int wait_s;

   call++;
   str = calloc( strlen(str1)+strlen(str2)+1, 1 );
 //  sprintf( str, "%s%s", str1, str2 );
   fprintf(file, "hazewm error: %s%s\n", str1, str2 );
   fclose(file);
 //  if( call<5 )   XBell( dpy, 30 );
/*   DrawStringMenuBar( str );
   wait_s = 1000000-call/5*500000;
   wait_s = wait_s>0? wait_s : 100000;
   sleep_a_little( wait_s );*/ 
   free( str );
  
}
Had no luck at all with printf (always a blank file), but eventually found a reference to fprintf and that works.
The file ends up in root/

EDIT:

Code: Select all

file = fopen("/tmp/xerrs.log","a+");
will work, I just hadn't tried it yet...

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#23 Post by technosaurus »

A little known tidbit about printf - it prints to stdout which is buffered (stderr is not IIRC), so if you didn't add a '\n', it would just keep buffering until it got one. This is useful for instance if you need to use '\b' to overwrite something, but mostly to reduce unnecessary i/o.
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

goingnuts
Posts: 932
Joined: Sun 07 Dec 2008, 13:33
Contact:

#24 Post by goingnuts »

Keef: Thanks - good hints. Now it can be reduced to

Code: Select all

void DrawErrMsgOnMenu( char *str1, char *str2 )
{fprintf(stderr, "hazewm error: %s%s\n", str1, str2);}
and errors ends up in xerrs.log. Removed the Xbell as well - I do not hear the bells - do you?
20131010: Attached 4 patches - one fix missing fonts, one sends errors to stdout (and not to menubar) - one remove some warnings and the last adds icewm systemsounds.
For the system sounds to work compile with " -DCONFIG_GUIEVENTS" and you also needs a configured "icesound" or my replacement "newsound"...
Attachments
haze-0.2_warnings.diff.gz
(2.02 KiB) Downloaded 413 times
haze-0.2_errors_to_stderr.diff.gz
(618 Bytes) Downloaded 420 times
haze-0.2_font.diff.gz
(505 Bytes) Downloaded 426 times
haze-0.2_icewm_systemsounds.diff.gz
(4.78 KiB) Downloaded 432 times

goingnuts
Posts: 932
Joined: Sun 07 Dec 2008, 13:33
Contact:

#25 Post by goingnuts »

A "collage" of hazewm-0.2 with above patches and configured with systemsounds can be downloaded here. Also a small collection of applications included (animate, montage, xdesktopwaves, calctool, identify, newsound, tcmixer, xli, combine, import, ofclock, wavplay, xmountains, convert, mcb_imagemagick, pmfree, wavrec, xsetroot, defaultaudioplayer, minimp3, pupslock,xautolock, xtp, display, mogrify, setterm, xcal, xvidcap).
Used some of technosaurus tango32xpm icons, revised the pm_haze_xdg.sh script to use desktopfiles found in /usr/share/haze/applications.

Its for fun - and a nice sandbox for test of applications that NEED root window visible (if you as user need to view what it does...)
Attachments
haze_collage.png
(189.55 KiB) Downloaded 617 times

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#26 Post by technosaurus »

@goingnuts, I'm guessing you built static against tinyx11, since I don't see it in top (it uses less resource than the shared build of bash)
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
Keef
Posts: 987
Joined: Thu 20 Dec 2007, 22:12
Location: Staffordshire

#27 Post by Keef »

Good work as ever, goingnuts. I bet samira was wondering if a pet would ever appear.

On my starthaze, I added

Code: Select all

echo "xsetroot -cursor_name top_left_arrow" > $HOME/.xinitrc
to get rid of the cross-hair cursor. Just nicked it from the standard xinitrc.

goingnuts
Posts: 932
Joined: Sun 07 Dec 2008, 13:33
Contact:

#28 Post by goingnuts »

technosaurus wrote:@goingnuts, I'm guessing you built static against tinyx11, since I don't see it in top (it uses less resource than the shared build of bash)
That is right - top reports 376 for the static linked hazewm. Source holds a lot of code dedicated to style system8 which is never used - wonder if resource usage would be minimized if cleaned out. It would be nice to have keyboard-control of the menus as well + full screen support but I haven't been able to get that working.
Keef: Good point - I changed that to

Code: Select all

echo "xsetroot -cursor_name left_ptr" > $HOME/.xinitrc
to give me same cursor on root window as over menus.

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#29 Post by technosaurus »

goingnuts wrote:Source holds a lot of code dedicated to style system8 which is never used - wonder if resource usage would be minimized if cleaned out. It would be nice to have keyboard-control of the menus as well + full screen support but I haven't been able to get that working.
I don't even know what "style system8" is, I would just comment it out rather than remove it outright. Keyboard control in wm can be difficult to do right, IIRC tinywm is the most concise example I've seen (it does alt+click to drag).

I know the number of menu items is limited by size, but since haze can handle submenus, it may be useful to adapt my jwm_menu_create with the submenus part required, possibly using some tango icon defaults for submenus.
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

goingnuts
Posts: 932
Joined: Sun 07 Dec 2008, 13:33
Contact:

#30 Post by goingnuts »

system8 is a style left over from mvlwm but not functional in hazewm anymore (behavior, decoration etc.) - might try to comment them out as you suggest - just to see influence on bin-size and resource usage.

Found a graphic view of a lot of wm and the relations here: http://www.gilesorr.com/wm/bloodlines.svg

Are there any general/common/standard rules for the categories/subcategories in the menus?

If anyone running the "hazewm-collage" leaves the desktop without activity for more than 10 minutes the xautolock triggers pupslock and screen is locked. To release it just type user/admin password.

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#31 Post by technosaurus »

Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
samira
Posts: 43
Joined: Sun 01 Sep 2013, 09:20

Tinkering w/ Haze WM

#32 Post by samira »

Hey everyone,
I managed to get a .tar.gz file with the haze binaries.. Tried it out, was ok at first. Then i noticed the fonts look funny in italics. Any way to change the fonts? Because in the hazerc the font options are rather cryptic.
And by the way, anyone notice the close button on the left is slightly to the right?

User avatar
samira
Posts: 43
Joined: Sun 01 Sep 2013, 09:20

Tinkering w/ Haze WM

#33 Post by samira »

P/S: any idea where the color of the menu bar is specified in the sources? I'd like to change it to grey (dark or light), white or silverish..

User avatar
Keef
Posts: 987
Joined: Thu 20 Dec 2007, 22:12
Location: Staffordshire

#34 Post by Keef »

To find a usable font on your system, use xfsontsel. 'select' copies the line to the clipboard, so you can paste it to hazerc.
I'd like to change the menu background too, but no joy yet.

goingnuts
Posts: 932
Joined: Sun 07 Dec 2008, 13:33
Contact:

#35 Post by goingnuts »

Close button intended right can be left aligned by deleting "sticky"-flag from menu.
Menubar color and height are hard coded. Attached patch add option

Code: Select all

DECORATIONS_INACTIVE_BG	gray

MENUBARHEIGHT  32

## Number of Desktop
to set the menu bar height to whatever size you want. Thats handy as one can reuse the 32-icons as miniicons:

Code: Select all

# Old mlvwm style definitons
Style
"calctool" MiniIcon accessories-calculator.xpm NoResizeR
which will replace the red X with the icon in menubar upper right.
Or you could set height to 48 and swallow some cool WindowMaker-style dockapps...

I have worked on the pm_haze_xdg.sh script to handle more categories but not quite set yet. Going towards a Gnome-panel-like solution where most menus are in sub menus of an "Application"-main-menu...

I try to keep the "hazewm-0.2-collage" updated for download here
Attachments
haze-0.2_menubarheight.diff.gz
2. version fixing no MENUBARHEIGHT present in hazerc-file
(1.86 KiB) Downloaded 428 times
haze_menu_test.png
(74.3 KiB) Downloaded 711 times
Last edited by goingnuts on Thu 17 Oct 2013, 14:25, edited 1 time in total.

User avatar
samira
Posts: 43
Joined: Sun 01 Sep 2013, 09:20

Tinkering w/ Haze Wm

#36 Post by samira »

Thanks everyone..
Been using mlvwm instead & see what i can do
instead, because Haze doesn't have themes. The
black menu bar with white fonts are a little
contrasting with each other. Any idea how to
turn it white or grey? Understand that if it's hard coded, where would be the best place to start for changing the menu bar colors? And i've tried the Colours option in .hazerc, however, my xserver quits. I can only run haze in it's default b&w theme.

goingnuts
Posts: 932
Joined: Sun 07 Dec 2008, 13:33
Contact:

#37 Post by goingnuts »

samira:hazewm is based on mlvwm - a lot of code change is just name changes (like "MlvwmWindow *ActiveWin;" -> "HAZEWMWindow *ActiveWin;"). So tinkering with mlvwm - implementing real code adds from hazewm - might be a proper way forward. Colors are set in InitGCs in main.c - my code for setting menu bar height via .hazerc can be extended to setting menu colors as well - but you can hard code new colors via changes in InitGCs (change the "GetColor( "#bbbbbb");" values...

User avatar
samira
Posts: 43
Joined: Sun 01 Sep 2013, 09:20

#38 Post by samira »

Thanks goingnuts,
I got the haze starter pack, and it works on v4.31.(though the standard package failed to run on v4.31).. But the menubar was like 1 px thin, so had to add the MENUBARHEIGHT parameter to fix the problem..

User avatar
samira
Posts: 43
Joined: Sun 01 Sep 2013, 09:20

Tinkering w/ Haze WM

#39 Post by samira »

goingnuts: you mentioned a way to change the menubar colour via .hazerc, what's the syntax? By the way, wouldn't we need to change the font colour if the menubar color is changed too?
goingnuts wrote:samira:hazewm is based on mlvwm - a lot of code change is just name changes (like "MlvwmWindow *ActiveWin;" -> "HAZEWMWindow *ActiveWin;"). So tinkering with mlvwm - implementing real code adds from hazewm - might be a proper way forward. Colors are set in InitGCs in main.c - my code for setting menu bar height via .hazerc can be extended to setting menu colors as well - but you can hard code new colors via changes in InitGCs (change the "GetColor( "#bbbbbb");" values...

goingnuts
Posts: 932
Joined: Sun 07 Dec 2008, 13:33
Contact:

#40 Post by goingnuts »

samira wrote:Thanks goingnuts,
I got the haze starter pack, and it works on v4.31.(though the standard package failed to run on v4.31).. But the menubar was like 1 px thin, so had to add the MENUBARHEIGHT parameter to fix the problem..
Thanks for reporting - in fact the starter-pack is expected to work on every known version and beyond...
The 1px menu is an error/bug - I have updated the menubarheight patch above to fix this - and updated the hazewm-starter-pet as well.
The standard package you mention - what is that?
The setting of menubar-color via rcfile is not coded yet - what I meant was that code similar to the code providing menubarheigt could be used to set the different colours.
And yes - font-color should be adjustable too - good point!

I tend to prefer further work to be done with offset in mlvwm and not hazewm.

mlvwm/hazewm is really low resource demand windowmanagers with quite extended properties. Hard to get memory usage above 400K for the static linked bin...

Post Reply