diff --git a/config.def.h b/config.def.h index 2d824d1..947facb 100644 --- a/config.def.h +++ b/config.def.h @@ -1,38 +1,40 @@ /* See LICENSE file for copyright and license details. */ /* appearance */ -static const unsigned int borderpx = 1; /* border pixel of windows */ +static const unsigned int borderpx = 2; /* border pixel of windows */ static const unsigned int snap = 32; /* snap pixel */ static const unsigned int systraypinning = 0; /* 0: sloppy systray follows selected monitor, >0: pin systray to monitor X */ static const unsigned int systrayspacing = 2; /* systray spacing */ static const int systraypinningfailfirst = 1; /* 1: if pinning fails, display systray on the first monitor, False: display systray on the last monitor*/ -static const int showsystray = 1; /* 0 means no systray */ +static const int showsystray = 1; /* 0 means no systray */ static const int showbar = 1; /* 0 means no bar */ static const int topbar = 1; /* 0 means bottom bar */ static const char *fonts[] = { "monospace:size=10" }; static const char dmenufont[] = "monospace:size=10"; +static const char col_dom0[] = "#3874D8"; +static const char col_white[] = "#FFFFFF"; static const char col_gray1[] = "#222222"; static const char col_gray2[] = "#444444"; static const char col_gray3[] = "#bbbbbb"; static const char col_gray4[] = "#eeeeee"; static const char col_cyan[] = "#005577"; -static const char *colors[][3] = { - /* fg bg border */ - [SchemeNorm] = { col_gray3, col_gray1, col_gray2 }, - [SchemeSel] = { col_gray4, col_cyan, col_cyan }, +/* Dom0 Colors, tagbar and status bar */ +static const char *colors[][2] = { + /* fg bg */ + [SchemeNorm] = { col_gray3, col_gray1 }, + [SchemeSel] = { col_white, col_dom0 }, }; /* tagging */ -static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; +static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "Q" }; static const Rule rules[] = { /* xprop(1): * WM_CLASS(STRING) = instance, class * WM_NAME(STRING) = title */ - /* class instance title tags mask isfloating monitor */ - { "Gimp", NULL, NULL, 0, 1, -1 }, - { "Firefox", NULL, NULL, 1 << 8, 0, -1 }, + /* class instance title tags mask isfloating monitor */ + { NULL, NULL, "Qubes VM Manager" , 1 << 8, 1, -1} }; /* layout(s) */ @@ -48,7 +50,7 @@ static const Layout layouts[] = { }; /* key definitions */ -#define MODKEY Mod1Mask +#define MODKEY Mod4Mask #define TAGKEYS(KEY,TAG) \ { MODKEY, KEY, view, {.ui = 1 << TAG} }, \ { MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \ @@ -59,13 +61,15 @@ static const Layout layouts[] = { #define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } } /* commands */ -static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */ -static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL }; -static const char *termcmd[] = { "st", NULL }; +static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */ +static const char *dmenu_dom0[] = { "dmenu_run", "dom0", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_dom0, "-sf", col_white, NULL }; +static const char *dmenu_vms[] = { "dmenu_run", "vms", "-a", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_dom0, "-sf", col_white, NULL }; +static const char *termcmd[] = { "urxvt", NULL }; static Key keys[] = { /* modifier key function argument */ - { MODKEY, XK_p, spawn, {.v = dmenucmd } }, + { MODKEY, XK_p, spawn, {.v = dmenu_dom0 } }, + { MODKEY|ShiftMask, XK_p, spawn, {.v = dmenu_vms} }, { MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } }, { MODKEY, XK_b, togglebar, {0} }, { MODKEY, XK_j, focusstack, {.i = +1 } }, diff --git a/dwm.c b/dwm.c index bb5929b..1943256 100644 --- a/dwm.c +++ b/dwm.c @@ -104,6 +104,8 @@ typedef struct Monitor Monitor; typedef struct Client Client; struct Client { char name[256]; + unsigned long vmcolor; + char *vmname; float mina, maxa; int x, y, w, h; int oldx, oldy, oldw, oldh; @@ -232,6 +234,8 @@ static void setlayout(const Arg *arg); static void setmfact(const Arg *arg); static void setup(void); static void seturgent(Client *c, int urg); +static void setvmcolor(Client *c); +static void setvmname(Client *c); static void showhide(Client *c); static void sigchld(int unused); static void spawn(const Arg *arg); @@ -824,8 +828,15 @@ drawbar(Monitor *m) if ((w = m->ww - sw - stw - x) > bh) { if (m->sel) { + unsigned long backPixel = scheme[SchemeSel][ColBg].pixel; + scheme[SchemeSel][ColBg].pixel = m->sel->vmcolor; drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]); - drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0); + int size = strlen(m->sel->vmname) + strlen(m->sel->name) + 4; + char *content = ecalloc(size, 1); + snprintf(content, size, "[%s] %s", m->sel->vmname, m->sel->name); + drw_text(drw, x, 0, w, bh, lrpad / 2, content, 0); + scheme[SchemeSel][ColBg].pixel = backPixel; + free(content); if (m->sel->isfloating) drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0); } else { @@ -892,7 +903,7 @@ focus(Client *c) detachstack(c); attachstack(c); grabbuttons(c, 1); - XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel); + XSetWindowBorder(dpy, c->win, c->vmcolor); setfocus(c); } else { XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); @@ -1145,6 +1156,8 @@ manage(Window w, XWindowAttributes *wa) c->h = c->oldh = wa->height; c->oldbw = wa->border_width; + setvmname(c); + setvmcolor(c); updatetitle(c); if (XGetTransientForHint(dpy, w, &trans) && (t = wintoclient(trans))) { c->mon = t->mon; @@ -1166,7 +1179,7 @@ manage(Window w, XWindowAttributes *wa) wc.border_width = c->bw; XConfigureWindow(dpy, w, CWBorderWidth, &wc); - XSetWindowBorder(dpy, w, scheme[SchemeNorm][ColBorder].pixel); + XSetWindowBorder(dpy, w, c->vmcolor); configure(c); /* propagates border_width, if size doesn't change */ updatewindowtype(c); updatesizehints(c); @@ -1754,7 +1767,7 @@ setup(void) /* init appearance */ scheme = ecalloc(LENGTH(colors), sizeof(Clr *)); for (i = 0; i < LENGTH(colors); i++) - scheme[i] = drw_scm_create(drw, colors[i], 3); + scheme[i] = drw_scm_create(drw, colors[i], 2); /* init system tray */ updatesystray(); /* init bars */ @@ -1797,6 +1810,67 @@ seturgent(Client *c, int urg) XFree(wmh); } +void +setvmcolor(Client *c) +{ + Atom id = XInternAtom(dpy, "_QUBES_LABEL_COLOR", True); + + if (id == None) { + XftColor xft; + drw_clr_create(drw, &xft, col_dom0); + c->vmcolor = xft.pixel; + } else { + Atom actual_type; + int actual_format; + unsigned long nitems; + unsigned long nbytes; + unsigned long *value = NULL; + + XGetWindowProperty(dpy, c->win, id, 0, 1, False, XA_CARDINAL, + &actual_type, &actual_format, &nitems, &nbytes, (unsigned char **) &value); + + if (nitems) { + c->vmcolor = value[0]; + } else { + XftColor xft; + drw_clr_create(drw, &xft, col_dom0); + c->vmcolor = xft.pixel; + } + XFree(value); + } +} + +void +setvmname(Client *c) +{ + Atom id = XInternAtom(dpy, "_QUBES_VMNAME", True); + + if (id == None) { + c->vmname = ecalloc(5, 1); + strcpy(c->vmname, "Dom0"); + } else { + Atom actual_type; + int actual_format; + unsigned long nitems; + unsigned long nbytes; + char *value = NULL; + + XGetWindowProperty(dpy, c->win, id, 0, ~(0L), False, XA_STRING, + &actual_type, &actual_format, &nitems, &nbytes, (unsigned char **) &value); + + if (nitems) { + c->vmname = ecalloc(nitems + 1, 1); + strncpy(c->vmname, value, nitems); + c->vmname[nitems] = '\0'; + } else { + c->vmname = ecalloc(5, 1); + strcpy(c->vmname, "Dom0"); + } + + XFree(value); + } +} + void showhide(Client *c) { @@ -1826,7 +1900,7 @@ sigchld(int unused) void spawn(const Arg *arg) { - if (arg->v == dmenucmd) + if (arg->v == dmenu_dom0 || arg->v == dmenu_vms) dmenumon[0] = '0' + selmon->num; if (fork() == 0) { if (dpy) @@ -1950,7 +2024,7 @@ unfocus(Client *c, int setfocus) if (!c) return; grabbuttons(c, 0); - XSetWindowBorder(dpy, c->win, scheme[SchemeNorm][ColBorder].pixel); + XSetWindowBorder(dpy, c->win, c->vmcolor); if (setfocus) { XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); XDeleteProperty(dpy, root, netatom[NetActiveWindow]);