Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import std.stdio, std.string, std.algorithm, std.array, xcb.xcb;
- import core.stdc.stdlib;
- enum WIDTH = 1920;
- enum HEIGHT = 25;
- union rgba_t {
- struct { ubyte b, g, r, a; }
- uint v;
- }
- /*
- Most of this is copied from lemonbar
- */
- void main() {
- xcb_connection_t* connection = xcb_connect(null, null);
- const xcb_setup_t* setup = xcb_get_setup(connection);
- xcb_screen_iterator_t iter = xcb_setup_roots_iterator(setup);
- xcb_screen_t* screen = iter.data;
- xcb_window_t window = xcb_generate_id(connection);
- rgba_t bgc = {0xff, 0, 0, 0x0};
- xcb_pixmap_t pixmap = xcb_generate_id(connection);
- xcb_gcontext_t gc;
- ubyte depth = 32;
- uint thing = 1;
- xcb_create_window(connection,
- XCB_COPY_FROM_PARENT,
- window,
- screen.root,
- 0, 0,
- WIDTH, HEIGHT,
- 0,
- XCB_WINDOW_CLASS_INPUT_OUTPUT,
- screen.root_visual,
- XCB_CW_OVERRIDE_REDIRECT,
- &thing);
- xcb_create_pixmap(connection, depth, pixmap, window, WIDTH, HEIGHT);
- uint[] stuff2 = [bgc.v];
- xcb_create_gc(connection, gc, pixmap, XCB_GC_FOREGROUND, stuff2.ptr);
- setAtoms(connection, window);
- xcb_map_window(connection, window);
- uint[] stuff3 = [0, 0];
- xcb_configure_window(connection, window, XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, stuff3.ptr);
- xcb_flush(connection);
- readln;
- xcb_disconnect(connection);
- }
- enum NetWM {
- WINDOW_TYPE = 0,
- WINDOW_TYPE_DOCK,
- DESKTOP,
- STRUT_PARTIAL,
- STRUT,
- STATE,
- STATE_STICKY,
- STATE_ABOVE
- };
- static immutable ATOM_NAMES = [
- "_NET_WM_WINDOW_TYPE",
- "_NET_WM_WINDOW_TYPE_DOCK",
- "_NET_WM_DESKTOP",
- "_NET_WM_STRUT_PARTIAL",
- "_NET_WM_STRUT",
- "_NET_WM_STATE",
- "_NET_WM_STATE_STICKY",
- "_NET_WM_STATE_ABOVE"
- ];
- void setAtoms(xcb_connection_t* connection, xcb_window_t window) {
- xcb_intern_atom_cookie_t[ATOM_NAMES.length] atomCookies;
- xcb_atom_t[ATOM_NAMES.length] atomList;
- foreach (i; 0..ATOM_NAMES.length) {
- atomCookies[i] = xcb_intern_atom(connection, 0, cast(ushort)(ATOM_NAMES[i].length), ATOM_NAMES[i].toStringz);
- }
- foreach (i; 0..ATOM_NAMES.length) {
- auto atomReply = xcb_intern_atom_reply(connection, atomCookies[i], null);
- if (!atomReply) return;
- atomList[i] = atomReply.atom;
- free(atomReply);
- }
- int[12] strut = [0, 0, HEIGHT, 0, 0, 0, 0, 0, 0, WIDTH, 0, 0];
- uint thing = -1;
- xcb_change_property(connection, XCB_PROP_MODE_REPLACE, window, atomList[NetWM.WINDOW_TYPE], XCB_ATOM_ATOM, 32, 1, &atomList[NetWM.WINDOW_TYPE_DOCK]);
- xcb_change_property(connection, XCB_PROP_MODE_APPEND, window, atomList[NetWM.STATE], XCB_ATOM_ATOM, 32, 2, &atomList[NetWM.STATE_STICKY]);
- xcb_change_property(connection, XCB_PROP_MODE_REPLACE, window, atomList[NetWM.DESKTOP], XCB_ATOM_CARDINAL, 32, 1, &thing);
- xcb_change_property(connection, XCB_PROP_MODE_REPLACE, window, atomList[NetWM.STRUT_PARTIAL], XCB_ATOM_CARDINAL, 32, 12, &strut);
- xcb_change_property(connection, XCB_PROP_MODE_REPLACE, window, atomList[NetWM.STRUT], XCB_ATOM_CARDINAL, 32, 4, &strut);
- xcb_change_property(connection, XCB_PROP_MODE_REPLACE, window, XCB_ATOM_WM_NAME, XCB_ATOM_STRING, 8, 5, "mybar".toStringz);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement