added notifications for virtual desktop switching

This commit is contained in:
Iris Lightshard 2020-08-06 23:50:28 -04:00
parent c409aaa045
commit 95b857a77c
Signed by: Iris Lightshard
GPG key ID: 3B7FBC22144E6398
3 changed files with 24 additions and 5 deletions

View file

@ -10,7 +10,7 @@
#define MENUFGCOL 0x797979 #define MENUFGCOL 0x797979
#define MENUBGCOL 0x000000 #define MENUBGCOL 0x000000
#define SMENUFGCOL 0x000000 #define SMENUFGCOL 0x000000
#define SMENUBGCOL 0x797979 #define SMENUBGCOL 0x1f9b92
#define SHORTCUTMOD Mod4Mask #define SHORTCUTMOD Mod4Mask
#define MODBITS (1<<6) #define MODBITS (1<<6)

11
key.c
View file

@ -178,11 +178,18 @@ keypress(XKeyEvent *e)
/* switch virts */ /* switch virts */
if (e->keycode == rightcode && (e->state&SHORTCUTMOD) == (MODBITS)) if (e->keycode == rightcode && (e->state&SHORTCUTMOD) == (MODBITS))
if (numvirtuals > 1 && virt < numvirtuals - 1) if (numvirtuals > 1)
if (virt < numvirtuals - 1)
switch_to(virt + 1); switch_to(virt + 1);
else
switch_to(0);
if (e->keycode == leftcode && (e->state&SHORTCUTMOD) == (MODBITS)) if (e->keycode == leftcode && (e->state&SHORTCUTMOD) == (MODBITS))
if (numvirtuals >1 && virt > 0) if (numvirtuals >1)
if (virt > 0)
switch_to(virt - 1); switch_to(virt - 1);
else
switch_to(numvirtuals - 1);
XAllowEvents(dpy, SyncKeyboard, e->time); XAllowEvents(dpy, SyncKeyboard, e->time);
} }

12
menu.c
View file

@ -410,6 +410,7 @@ switch_to_c(int n, Client *c)
void void
switch_to(int n) switch_to(int n)
{ {
static char virtmsg[32];
if(n == virt) if(n == virt)
return; return;
currents[virt] = current; currents[virt] = current;
@ -422,6 +423,17 @@ switch_to(int n)
switch_to_c(n, clients); switch_to_c(n, clients);
current = currents[virt]; current = currents[virt];
if(fork() == 0)
{
close(ConnectionNumber(dpy));
if(dpy != '\0')
putenv(dpy);
signal(SIGINT, SIG_DFL);
signal(SIGTERM, SIG_DFL);
signal(SIGHUP, SIG_DFL);
sprintf(virtmsg, "virtual: switched to %s", b2items[virt]);
execlp("notify-send", "notify-send", "-c virtual", virtmsg, (char*)0);
}
} }
void void