summaryrefslogtreecommitdiff
path: root/qubes-dwm-6.2/dwm-qubes.diff
blob: 3939a5e9479af350ac79a5e7eff4dfde62f3d56c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
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]);