mirror of
https://github.com/Llewellynvdm/conky.git
synced 2025-01-11 18:38:45 +00:00
added own_window_hints
git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky@543 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
parent
a72572328f
commit
1d6a4ddde9
5
README
5
README
@ -289,6 +289,11 @@ CONFIGURATION SETTINGS
|
||||
valid RGB name (see /usr/lib/X11/rgb.txt)
|
||||
|
||||
|
||||
own_window_hints undecorated,below,above,sticky,skip_taskbar,skip_pager
|
||||
If own_window is yes, you may use these window manager hints to
|
||||
affect the way conky displays
|
||||
|
||||
|
||||
out_to_console
|
||||
Print text to stdout.
|
||||
|
||||
|
@ -250,6 +250,15 @@
|
||||
<para></para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><command><option>own_window_hints</option></command>
|
||||
<option>undecorated,below,above,sticky,skip_taskbar,skip_pager</option>
|
||||
</term>
|
||||
<listitem>
|
||||
If own_window is yes, you may use these window manager hints to affect the way conky displays
|
||||
<para></para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><command><option>out_to_console</option></command>
|
||||
</term>
|
||||
|
@ -266,6 +266,10 @@ Boolean, set pseudo-transparency?
|
||||
\fBown_window_colour\fR \fBcolour\fR
|
||||
If own_window_transparent no, set a specified background colour (defaults to black). Takes either a hex value (#ffffff) or a valid RGB name (see /usr/lib/X11/rgb.txt)
|
||||
|
||||
.TP
|
||||
\fBown_window_hints\fR \fBundecorated,below,above,sticky,skip_taskbar,skip_pager\fR
|
||||
If own_window is yes, you may use these window manager hints to affect the way conky displays
|
||||
|
||||
.TP
|
||||
\fBout_to_console\fR
|
||||
Print text to stdout.
|
||||
|
@ -59,6 +59,9 @@ own_window_transparent yes
|
||||
# If own_window_transparent is set to no, you can set the background colour here
|
||||
own_window_colour hotpink
|
||||
|
||||
# If own_window is yes, these window manager hints may be used
|
||||
#own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
|
||||
|
||||
# Use double buffering (reduces flicker, may not work for everyone)
|
||||
double_buffer yes
|
||||
|
||||
@ -179,7 +182,7 @@ $stippled_hr
|
||||
${color #ddaa00}Port(s)${alignr}#Connections
|
||||
$color ALL: ${alignr}$color ${tcp_portmon 1 65535 count}
|
||||
$color mpd: ${alignr}$color ${tcp_portmon 6600 6600 count}
|
||||
$color sshd: ${alignr}$color ${tcp_portmon 9229 9229 count}
|
||||
$color sshd: ${alignr}$color ${tcp_portmon 22 22 count}
|
||||
$color torrent: ${alignr}$color ${tcp_portmon 6881 6999 count}
|
||||
${color #ddaa00}Remote Address ${alignr} Local Service/Port$color
|
||||
${tcp_portmon 1 65535 rhost 0} ${alignr} ${tcp_portmon 1 65535 lservice 0}
|
||||
|
41
src/conky.c
41
src/conky.c
@ -241,7 +241,6 @@ static int set_transparent = 0;
|
||||
#ifdef OWN_WINDOW
|
||||
static int own_window = 0;
|
||||
static int background_colour = 0;
|
||||
static char wm_class_name[256];
|
||||
/* fixed size/pos is set if wm/user changes them */
|
||||
static int fixed_size = 0, fixed_pos = 0;
|
||||
#endif
|
||||
@ -4831,7 +4830,7 @@ static void set_default_configurations(void)
|
||||
maximum_width = 0;
|
||||
#ifdef OWN_WINDOW
|
||||
own_window = 0;
|
||||
strcpy(wm_class_name, "conky");
|
||||
strcpy(window.wm_class_name, "conky");
|
||||
#endif
|
||||
stippled_borders = 0;
|
||||
border_margin = 3;
|
||||
@ -4943,7 +4942,11 @@ else if (strcasecmp(name, a) == 0 || strcasecmp(name, b) == 0)
|
||||
}
|
||||
CONF("on_bottom") {
|
||||
if(value)
|
||||
ERR("on_bottom is deprecated. use own_window_hints below");
|
||||
on_bottom = string_to_bool(value);
|
||||
if (on_bottom)
|
||||
SET_HINT(window.hints,HINT_BELOW);
|
||||
|
||||
else
|
||||
CONF_ERR;
|
||||
}
|
||||
@ -5230,8 +5233,8 @@ else if (strcasecmp(name, a) == 0 || strcasecmp(name, b) == 0)
|
||||
own_window = string_to_bool(value);
|
||||
}
|
||||
CONF("wm_class_name") {
|
||||
strncpy(wm_class_name, value, sizeof(wm_class_name)-1);
|
||||
wm_class_name[sizeof(wm_class_name)-1] = 0;
|
||||
memset(window.wm_class_name,0,sizeof(window.wm_class_name));
|
||||
strncpy(window.wm_class_name, value, sizeof(window.wm_class_name)-1);
|
||||
}
|
||||
CONF("own_window_transparent") {
|
||||
set_transparent = string_to_bool(value);
|
||||
@ -5243,6 +5246,35 @@ else if (strcasecmp(name, a) == 0 || strcasecmp(name, b) == 0)
|
||||
ERR("Invalid colour for own_winder_colour (try omitting the '#' for hex colours");
|
||||
}
|
||||
}
|
||||
CONF("own_window_hints") {
|
||||
if (value) {
|
||||
char *p_hint, *p_save;
|
||||
char delim[] = ", ";
|
||||
|
||||
/* tokenize the value into individual hints */
|
||||
if ((p_hint=strtok_r(value, delim, &p_save)) != NULL)
|
||||
do {
|
||||
/*fprintf(stderr, "hint [%s] parsed\n", p_hint);*/
|
||||
if (strncmp(p_hint,"undecorate",10) == 0)
|
||||
SET_HINT(window.hints,HINT_UNDECORATED);
|
||||
else if (strncmp(p_hint,"below",5) == 0)
|
||||
SET_HINT(window.hints,HINT_BELOW);
|
||||
else if (strncmp(p_hint,"above",5) == 0)
|
||||
SET_HINT(window.hints,HINT_ABOVE);
|
||||
else if (strncmp(p_hint,"sticky",6) == 0)
|
||||
SET_HINT(window.hints,HINT_STICKY);
|
||||
else if (strncmp(p_hint,"skip_taskbar",12) == 0)
|
||||
SET_HINT(window.hints,HINT_SKIP_TASKBAR);
|
||||
else if (strncmp(p_hint,"skip_pager",10) == 0)
|
||||
SET_HINT(window.hints,HINT_SKIP_PAGER);
|
||||
else
|
||||
CONF_ERR;
|
||||
|
||||
p_hint=strtok_r(NULL, delim, &p_save);
|
||||
}
|
||||
while (p_hint!=NULL);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
CONF("stippled_borders") {
|
||||
if (value)
|
||||
@ -5603,6 +5635,7 @@ int main(int argc, char **argv)
|
||||
(stderr,
|
||||
"Conky: forked to background, pid is %d\n",
|
||||
ret);
|
||||
fflush(stderr);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
14
src/conky.h
14
src/conky.h
@ -299,6 +299,18 @@ char tmpstring2[TEXT_BUFFER_SIZE];
|
||||
|
||||
#define ATOM(a) XInternAtom(display, #a, False)
|
||||
|
||||
#ifdef OWN_WINDOW
|
||||
enum _window_hints {
|
||||
HINT_UNDECORATED = 0,
|
||||
HINT_BELOW,
|
||||
HINT_ABOVE,
|
||||
HINT_STICKY,
|
||||
HINT_SKIP_TASKBAR,
|
||||
HINT_SKIP_PAGER
|
||||
};
|
||||
#define SET_HINT(mask,hint) (mask |= (1<<hint))
|
||||
#define TEST_HINT(mask,hint) (mask & (1<<hint))
|
||||
#endif
|
||||
struct conky_window {
|
||||
Window root,window;
|
||||
Drawable drawable;
|
||||
@ -313,8 +325,10 @@ struct conky_window {
|
||||
int width;
|
||||
int height;
|
||||
#ifdef OWN_WINDOW
|
||||
char wm_class_name[256];
|
||||
int x;
|
||||
int y;
|
||||
unsigned long hints;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
132
src/x11.c
132
src/x11.c
@ -119,6 +119,7 @@ static Window find_desktop_window()
|
||||
XFree(children);
|
||||
fprintf(stderr,
|
||||
"Conky: desktop window (%lx) found from __SWM_VROOT property\n", win);
|
||||
fflush(stderr);
|
||||
return win;
|
||||
}
|
||||
|
||||
@ -147,6 +148,7 @@ static Window find_desktop_window()
|
||||
else
|
||||
fprintf(stderr, "Conky: desktop window (%lx) is root window\n",win);
|
||||
|
||||
fflush(stderr);
|
||||
return win;
|
||||
}
|
||||
|
||||
@ -199,6 +201,7 @@ void init_window(int own_window, int w, int h, int set_trans, int back_colour, c
|
||||
|
||||
XClassHint classHint;
|
||||
XWMHints wmHint;
|
||||
Atom xa;
|
||||
char window_title[256];
|
||||
|
||||
window.root = find_desktop_window();
|
||||
@ -208,11 +211,13 @@ void init_window(int own_window, int w, int h, int set_trans, int back_colour, c
|
||||
CopyFromParent,
|
||||
InputOutput,
|
||||
CopyFromParent,
|
||||
CWBackPixel|CWOverrideRedirect, &attrs);
|
||||
CWBackPixel|CWOverrideRedirect,
|
||||
&attrs);
|
||||
|
||||
fprintf(stderr, "Conky: drawing to created window (%lx)\n", window.window);
|
||||
fflush(stderr);
|
||||
|
||||
classHint.res_name = "conky";
|
||||
classHint.res_name = window.wm_class_name;
|
||||
classHint.res_class = classHint.res_name;
|
||||
|
||||
wmHint.flags = InputHint | StateHint;
|
||||
@ -228,7 +233,128 @@ void init_window(int own_window, int w, int h, int set_trans, int back_colour, c
|
||||
/* Sets an empty WM_PROTOCOLS property */
|
||||
XSetWMProtocols(display,window.window,NULL,0);
|
||||
|
||||
XLowerWindow(display, window.window);
|
||||
|
||||
/* Set NORMAL window type for _NET_WM_WINDOW_TYPE. */
|
||||
xa = ATOM(_NET_WM_WINDOW_TYPE);
|
||||
if (xa != None) {
|
||||
Atom prop = ATOM(_NET_WM_WINDOW_TYPE_NORMAL);
|
||||
XChangeProperty(display, window.window, xa,
|
||||
XA_ATOM, 32,
|
||||
PropModeReplace,
|
||||
(unsigned char *) &prop,
|
||||
1);
|
||||
}
|
||||
|
||||
/* Set desired hints */
|
||||
|
||||
/* Window decorations */
|
||||
if (TEST_HINT(window.hints,HINT_UNDECORATED)) {
|
||||
fprintf(stderr, "Conky: hint - undecorated\n"); fflush(stderr);
|
||||
|
||||
xa = ATOM(_MOTIF_WM_HINTS);
|
||||
if (xa != None) {
|
||||
long prop[5] = { 2, 0, 0, 0, 0 };
|
||||
XChangeProperty(display, window.window, xa,
|
||||
xa, 32, PropModeReplace,
|
||||
(unsigned char *) prop, 5);
|
||||
}
|
||||
}
|
||||
|
||||
/* Below other windows */
|
||||
if (TEST_HINT(window.hints,HINT_BELOW)) {
|
||||
fprintf(stderr, "Conky: hint - below\n"); fflush(stderr);
|
||||
|
||||
xa = ATOM(_WIN_LAYER);
|
||||
if (xa != None) {
|
||||
long prop = 0;
|
||||
XChangeProperty(display, window.window, xa,
|
||||
XA_CARDINAL, 32,
|
||||
PropModeReplace,
|
||||
(unsigned char *) &prop, 1);
|
||||
}
|
||||
|
||||
xa = ATOM("_NET_WM_STATE");
|
||||
if (xa != None) {
|
||||
Atom xa_prop = ATOM(_NET_WM_STATE_BELOW);
|
||||
XChangeProperty(display, window.window, xa,
|
||||
XA_ATOM, 32,
|
||||
PropModeAppend,
|
||||
(unsigned char *) &xa_prop,
|
||||
1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Above other windows */
|
||||
if (TEST_HINT(window.hints,HINT_ABOVE)) {
|
||||
fprintf(stderr, "Conky: hint - above\n"); fflush(stderr);
|
||||
|
||||
xa = ATOM(_WIN_LAYER);
|
||||
if (xa != None) {
|
||||
long prop = 6;
|
||||
XChangeProperty(display, window.window, xa,
|
||||
XA_CARDINAL, 32,
|
||||
PropModeReplace,
|
||||
(unsigned char *) &prop, 1);
|
||||
}
|
||||
|
||||
xa = ATOM("_NET_WM_STATE");
|
||||
if (xa != None) {
|
||||
Atom xa_prop = ATOM(_NET_WM_STATE_ABOVE);
|
||||
XChangeProperty(display, window.window, xa,
|
||||
XA_ATOM, 32,
|
||||
PropModeAppend,
|
||||
(unsigned char *) &xa_prop,
|
||||
1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Sticky */
|
||||
if (TEST_HINT(window.hints,HINT_STICKY)) {
|
||||
fprintf(stderr, "Conky: hint - sticky\n"); fflush(stderr);
|
||||
|
||||
xa = ATOM("_NET_WM_STATE");
|
||||
if (xa != None) {
|
||||
Atom xa_prop = ATOM(_NET_WM_STATE_STICKY);
|
||||
XChangeProperty(display, window.window, xa,
|
||||
XA_ATOM, 32,
|
||||
PropModeAppend,
|
||||
(unsigned char *) &xa_prop,
|
||||
1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Skip taskbar */
|
||||
if (TEST_HINT(window.hints,HINT_SKIP_TASKBAR)) {
|
||||
fprintf(stderr, "Conky: hint - skip_taskbar\n"); fflush(stderr);
|
||||
|
||||
xa = ATOM("_NET_WM_STATE");
|
||||
if (xa != None) {
|
||||
Atom xa_prop = ATOM(_NET_WM_STATE_SKIP_TASKBAR);
|
||||
XChangeProperty(display, window.window, xa,
|
||||
XA_ATOM, 32,
|
||||
PropModeAppend,
|
||||
(unsigned char *) &xa_prop,
|
||||
1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Skip pager */
|
||||
if (TEST_HINT(window.hints,HINT_SKIP_PAGER)) {
|
||||
fprintf(stderr, "Conky: hint - skip_pager\n"); fflush(stderr);
|
||||
|
||||
xa = ATOM("_NET_WM_STATE");
|
||||
if (xa != None) {
|
||||
Atom xa_prop = ATOM(_NET_WM_STATE_SKIP_PAGER);
|
||||
XChangeProperty(display, window.window, xa,
|
||||
XA_ATOM, 32,
|
||||
PropModeAppend,
|
||||
(unsigned char *) &xa_prop,
|
||||
1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
XMapWindow(display, window.window);
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user