2018-05-12 16:03:00 +00:00
|
|
|
/*
|
2010-01-07 03:45:19 +00:00
|
|
|
*
|
|
|
|
* Conky, a system monitor, based on torsmo
|
|
|
|
*
|
|
|
|
* Please see COPYING for details
|
|
|
|
*
|
2018-05-12 16:03:00 +00:00
|
|
|
* Copyright (c) 2005-2018 Brenden Matthews, Philip Kovacs, et. al.
|
2010-01-07 03:45:19 +00:00
|
|
|
* (see AUTHORS)
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
2009-07-28 21:44:22 +00:00
|
|
|
|
2010-01-07 02:38:12 +00:00
|
|
|
#ifdef BUILD_X11
|
2008-06-14 18:41:12 +00:00
|
|
|
#ifndef X11_H_
|
|
|
|
#define X11_H_
|
|
|
|
|
|
|
|
#include <X11/Xatom.h>
|
2018-05-12 16:03:00 +00:00
|
|
|
#include <X11/Xlib.h>
|
2008-06-14 18:41:12 +00:00
|
|
|
|
2010-01-07 02:38:12 +00:00
|
|
|
#ifdef BUILD_XFT
|
2008-06-14 18:41:12 +00:00
|
|
|
#include <X11/Xft/Xft.h>
|
|
|
|
#endif
|
|
|
|
|
2010-01-07 02:38:12 +00:00
|
|
|
#ifdef BUILD_XDBE
|
2008-06-14 18:41:12 +00:00
|
|
|
#include <X11/extensions/Xdbe.h>
|
|
|
|
#endif
|
|
|
|
|
2010-03-11 10:28:12 +00:00
|
|
|
#include "colours.h"
|
2018-05-12 16:03:00 +00:00
|
|
|
#include "setting.hh"
|
2010-02-24 19:51:33 +00:00
|
|
|
|
2008-06-14 18:41:12 +00:00
|
|
|
#define ATOM(a) XInternAtom(display, #a, False)
|
|
|
|
|
|
|
|
#ifdef OWN_WINDOW
|
2010-02-26 17:48:57 +00:00
|
|
|
enum window_type {
|
2018-05-12 16:03:00 +00:00
|
|
|
TYPE_NORMAL = 0,
|
|
|
|
TYPE_DOCK,
|
|
|
|
TYPE_PANEL,
|
|
|
|
TYPE_DESKTOP,
|
|
|
|
TYPE_OVERRIDE
|
2008-06-14 18:41:12 +00:00
|
|
|
};
|
|
|
|
|
2010-03-02 19:30:15 +00:00
|
|
|
enum window_hints {
|
2018-05-12 16:03:00 +00:00
|
|
|
HINT_UNDECORATED = 0,
|
|
|
|
HINT_BELOW,
|
|
|
|
HINT_ABOVE,
|
|
|
|
HINT_STICKY,
|
|
|
|
HINT_SKIP_TASKBAR,
|
|
|
|
HINT_SKIP_PAGER
|
2008-06-14 18:41:12 +00:00
|
|
|
};
|
|
|
|
|
2018-05-12 16:03:00 +00:00
|
|
|
#define SET_HINT(mask, hint) (mask |= (1 << (hint)))
|
|
|
|
#define TEST_HINT(mask, hint) (mask & (1 << (hint)))
|
2008-06-14 18:41:12 +00:00
|
|
|
#endif
|
|
|
|
|
2009-08-07 07:24:24 +00:00
|
|
|
struct conky_window {
|
2018-05-12 16:03:00 +00:00
|
|
|
Window root, window, desktop;
|
|
|
|
Drawable drawable;
|
|
|
|
Visual *visual;
|
|
|
|
Colormap colourmap;
|
|
|
|
GC gc;
|
2009-07-08 08:09:06 +00:00
|
|
|
|
2010-01-07 02:38:12 +00:00
|
|
|
#ifdef BUILD_XDBE
|
2018-05-12 16:03:00 +00:00
|
|
|
XdbeBackBuffer back_buffer;
|
2012-04-11 16:06:47 +00:00
|
|
|
#else
|
2018-05-12 16:03:00 +00:00
|
|
|
Pixmap back_buffer;
|
2008-06-14 18:41:12 +00:00
|
|
|
#endif
|
2010-01-07 02:38:12 +00:00
|
|
|
#ifdef BUILD_XFT
|
2018-05-12 16:03:00 +00:00
|
|
|
XftDraw *xftdraw;
|
2008-06-14 18:41:12 +00:00
|
|
|
#endif
|
|
|
|
|
2018-05-12 16:03:00 +00:00
|
|
|
int width;
|
|
|
|
int height;
|
2008-06-14 18:41:12 +00:00
|
|
|
#ifdef OWN_WINDOW
|
2018-05-12 16:03:00 +00:00
|
|
|
int x;
|
|
|
|
int y;
|
2008-06-14 18:41:12 +00:00
|
|
|
#endif
|
2009-08-07 07:24:24 +00:00
|
|
|
};
|
2008-06-14 18:41:12 +00:00
|
|
|
|
2010-01-07 02:38:12 +00:00
|
|
|
#if defined(BUILD_ARGB) && defined(OWN_WINDOW)
|
2010-02-26 17:29:46 +00:00
|
|
|
/* true if use_argb_visual=true and argb visual was found*/
|
|
|
|
extern bool have_argb_visual;
|
2010-02-03 21:36:04 +00:00
|
|
|
#endif
|
2010-01-01 23:01:51 +00:00
|
|
|
|
2008-06-14 18:41:12 +00:00
|
|
|
extern Display *display;
|
|
|
|
extern int display_width;
|
|
|
|
extern int display_height;
|
|
|
|
extern int screen;
|
|
|
|
|
|
|
|
extern int workarea[4];
|
|
|
|
|
2009-08-07 07:24:24 +00:00
|
|
|
extern struct conky_window window;
|
2009-11-21 14:45:00 +00:00
|
|
|
extern char window_created;
|
2009-08-07 07:24:24 +00:00
|
|
|
|
2009-05-20 03:34:43 +00:00
|
|
|
void destroy_window(void);
|
2008-06-14 18:41:12 +00:00
|
|
|
void create_gc(void);
|
2010-02-27 21:28:33 +00:00
|
|
|
void set_transparent_background(Window win);
|
2018-05-12 23:26:31 +00:00
|
|
|
void get_x11_desktop_info(Display *current_display, Atom atom);
|
2009-06-13 21:36:28 +00:00
|
|
|
void set_struts(int);
|
2008-06-14 18:41:12 +00:00
|
|
|
|
2018-08-07 23:22:23 +00:00
|
|
|
void print_monitor(struct text_object *, char *, unsigned int);
|
|
|
|
void print_monitor_number(struct text_object *, char *, unsigned int);
|
|
|
|
void print_desktop(struct text_object *, char *, unsigned int);
|
|
|
|
void print_desktop_number(struct text_object *, char *, unsigned int);
|
|
|
|
void print_desktop_name(struct text_object *, char *, unsigned int);
|
2009-11-25 22:56:19 +00:00
|
|
|
|
2018-08-02 15:15:16 +00:00
|
|
|
/* Num lock, Scroll lock, Caps Lock */
|
2018-08-07 23:22:23 +00:00
|
|
|
void print_num_led(struct text_object *, char *, unsigned int);
|
|
|
|
void print_caps_led(struct text_object *, char *, unsigned int);
|
|
|
|
void print_scroll_led(struct text_object *, char *, unsigned int);
|
2018-08-02 15:15:16 +00:00
|
|
|
|
2018-08-04 20:26:40 +00:00
|
|
|
/* Keyboard layout and mouse speed in percentage */
|
2018-08-31 12:36:46 +00:00
|
|
|
void print_keyboard_layout(struct text_object *, char *, unsigned int);
|
2018-08-07 23:22:23 +00:00
|
|
|
void print_mouse_speed(struct text_object *, char *, unsigned int);
|
2018-08-04 20:26:40 +00:00
|
|
|
|
2010-01-07 02:38:12 +00:00
|
|
|
#ifdef BUILD_XDBE
|
2009-08-05 21:41:29 +00:00
|
|
|
void xdbe_swap_buffers(void);
|
2012-04-11 16:06:47 +00:00
|
|
|
#else
|
|
|
|
void xpmdb_swap_buffers(void);
|
2010-01-07 02:38:12 +00:00
|
|
|
#endif /* BUILD_XDBE */
|
2009-08-05 21:41:29 +00:00
|
|
|
|
2010-02-24 19:51:33 +00:00
|
|
|
/* alignments */
|
|
|
|
enum alignment {
|
2018-05-12 16:03:00 +00:00
|
|
|
TOP_LEFT,
|
|
|
|
TOP_RIGHT,
|
|
|
|
TOP_MIDDLE,
|
|
|
|
BOTTOM_LEFT,
|
|
|
|
BOTTOM_RIGHT,
|
|
|
|
BOTTOM_MIDDLE,
|
|
|
|
MIDDLE_LEFT,
|
|
|
|
MIDDLE_MIDDLE,
|
|
|
|
MIDDLE_RIGHT,
|
|
|
|
NONE
|
2010-02-24 19:51:33 +00:00
|
|
|
};
|
|
|
|
|
2018-05-12 16:03:00 +00:00
|
|
|
extern conky::simple_config_setting<alignment> text_alignment;
|
2010-03-10 19:01:26 +00:00
|
|
|
|
|
|
|
namespace priv {
|
2018-05-12 16:03:00 +00:00
|
|
|
class out_to_x_setting : public conky::simple_config_setting<bool> {
|
|
|
|
typedef conky::simple_config_setting<bool> Base;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void lua_setter(lua::state &l, bool init);
|
|
|
|
virtual void cleanup(lua::state &l);
|
|
|
|
|
|
|
|
public:
|
|
|
|
out_to_x_setting() : Base("out_to_x", true, false) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
class own_window_setting : public conky::simple_config_setting<bool> {
|
|
|
|
typedef conky::simple_config_setting<bool> Base;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void lua_setter(lua::state &l, bool init);
|
|
|
|
|
|
|
|
public:
|
|
|
|
own_window_setting() : Base("own_window", false, false) {}
|
|
|
|
};
|
|
|
|
|
2018-08-08 13:02:05 +00:00
|
|
|
#ifdef BUILD_XDBE
|
2018-05-12 16:03:00 +00:00
|
|
|
class use_xdbe_setting : public conky::simple_config_setting<bool> {
|
|
|
|
typedef conky::simple_config_setting<bool> Base;
|
|
|
|
|
|
|
|
bool set_up(lua::state &l);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void lua_setter(lua::state &l, bool init);
|
|
|
|
|
|
|
|
public:
|
|
|
|
use_xdbe_setting() : Base("double_buffer", false, false) {}
|
|
|
|
};
|
|
|
|
|
2018-08-08 13:02:05 +00:00
|
|
|
#else
|
2018-05-12 16:03:00 +00:00
|
|
|
class use_xpmdb_setting : public conky::simple_config_setting<bool> {
|
|
|
|
typedef conky::simple_config_setting<bool> Base;
|
|
|
|
|
|
|
|
bool set_up(lua::state &l);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void lua_setter(lua::state &l, bool init);
|
|
|
|
|
|
|
|
public:
|
|
|
|
use_xpmdb_setting() : Base("double_buffer", false, false) {}
|
|
|
|
};
|
2018-08-08 13:02:05 +00:00
|
|
|
#endif
|
2018-05-12 16:03:00 +00:00
|
|
|
|
|
|
|
struct colour_traits {
|
|
|
|
static const lua::Type type = lua::TSTRING;
|
|
|
|
typedef unsigned long Type;
|
|
|
|
|
|
|
|
static inline std::pair<Type, bool> convert(lua::state &l, int index,
|
|
|
|
const std::string &) {
|
|
|
|
return {get_x11_color(l.tostring(index)), true};
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class colour_setting
|
|
|
|
: public conky::simple_config_setting<unsigned long, colour_traits> {
|
|
|
|
typedef conky::simple_config_setting<unsigned long, colour_traits> Base;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void lua_setter(lua::state &l, bool init);
|
|
|
|
|
|
|
|
public:
|
|
|
|
colour_setting(const std::string &name_, unsigned long default_value_ = 0)
|
|
|
|
: Base(name_, default_value_, true) {}
|
|
|
|
};
|
|
|
|
} // namespace priv
|
|
|
|
|
|
|
|
extern priv::out_to_x_setting out_to_x;
|
2010-03-04 17:31:28 +00:00
|
|
|
extern conky::simple_config_setting<std::string> display_name;
|
2018-08-16 22:40:34 +00:00
|
|
|
extern conky::simple_config_setting<int> head_index;
|
2018-05-12 16:03:00 +00:00
|
|
|
extern priv::colour_setting color[10];
|
|
|
|
extern priv::colour_setting default_color;
|
|
|
|
extern priv::colour_setting default_shade_color;
|
|
|
|
extern priv::colour_setting default_outline_color;
|
2010-02-24 19:51:33 +00:00
|
|
|
|
2018-05-12 16:03:00 +00:00
|
|
|
extern conky::range_config_setting<int> border_inner_margin;
|
|
|
|
extern conky::range_config_setting<int> border_outer_margin;
|
|
|
|
extern conky::range_config_setting<int> border_width;
|
2010-04-22 19:59:12 +00:00
|
|
|
|
2010-04-21 17:33:39 +00:00
|
|
|
#ifdef BUILD_XFT
|
2018-05-12 16:03:00 +00:00
|
|
|
extern conky::simple_config_setting<bool> use_xft;
|
2010-04-21 17:33:39 +00:00
|
|
|
#endif
|
|
|
|
|
2010-02-26 13:37:34 +00:00
|
|
|
#ifdef OWN_WINDOW
|
2018-05-12 16:03:00 +00:00
|
|
|
extern conky::simple_config_setting<bool> set_transparent;
|
2010-03-02 18:29:51 +00:00
|
|
|
extern conky::simple_config_setting<std::string> own_window_class;
|
|
|
|
extern conky::simple_config_setting<std::string> own_window_title;
|
|
|
|
extern conky::simple_config_setting<window_type> own_window_type;
|
2010-02-28 14:51:01 +00:00
|
|
|
|
2010-03-02 19:30:15 +00:00
|
|
|
struct window_hints_traits {
|
2018-05-12 16:03:00 +00:00
|
|
|
static const lua::Type type = lua::TSTRING;
|
|
|
|
typedef uint16_t Type;
|
|
|
|
static std::pair<Type, bool> convert(lua::state &l, int index,
|
|
|
|
const std::string &name);
|
2010-03-02 19:30:15 +00:00
|
|
|
};
|
2018-05-12 16:03:00 +00:00
|
|
|
extern conky::simple_config_setting<uint16_t, window_hints_traits>
|
|
|
|
own_window_hints;
|
2010-03-02 19:30:15 +00:00
|
|
|
|
2010-02-26 17:29:46 +00:00
|
|
|
#ifdef BUILD_ARGB
|
2018-05-12 16:03:00 +00:00
|
|
|
extern conky::simple_config_setting<bool> use_argb_visual;
|
2010-02-27 21:28:33 +00:00
|
|
|
|
|
|
|
/* range of 0-255 for alpha */
|
2018-05-12 16:03:00 +00:00
|
|
|
extern conky::range_config_setting<int> own_window_argb_value;
|
2010-02-26 13:37:34 +00:00
|
|
|
#endif
|
2010-02-26 17:29:46 +00:00
|
|
|
#endif /*OWN_WINDOW*/
|
2018-05-12 16:03:00 +00:00
|
|
|
extern priv::own_window_setting own_window;
|
2010-02-26 13:37:34 +00:00
|
|
|
|
2010-04-23 19:54:40 +00:00
|
|
|
#ifdef BUILD_XDBE
|
2018-05-12 16:03:00 +00:00
|
|
|
extern priv::use_xdbe_setting use_xdbe;
|
2012-04-11 16:06:47 +00:00
|
|
|
#else
|
2018-05-12 16:03:00 +00:00
|
|
|
extern priv::use_xpmdb_setting use_xpmdb;
|
2010-04-23 19:54:40 +00:00
|
|
|
#endif
|
|
|
|
|
2008-06-14 18:41:12 +00:00
|
|
|
#endif /*X11_H_*/
|
2010-01-07 02:38:12 +00:00
|
|
|
#endif /* BUILD_X11 */
|