From 95b857a77ced04b9a2037efe017b21e59857b704 Mon Sep 17 00:00:00 2001 From: Derek Stevens Date: Thu, 6 Aug 2020 23:50:28 -0400 Subject: [PATCH] added notifications for virtual desktop switching --- config.h | 2 +- key.c | 15 +++++++++++---- menu.c | 12 ++++++++++++ 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/config.h b/config.h index 8100644..be7257b 100755 --- a/config.h +++ b/config.h @@ -10,7 +10,7 @@ #define MENUFGCOL 0x797979 #define MENUBGCOL 0x000000 #define SMENUFGCOL 0x000000 -#define SMENUBGCOL 0x797979 +#define SMENUBGCOL 0x1f9b92 #define SHORTCUTMOD Mod4Mask #define MODBITS (1<<6) diff --git a/key.c b/key.c index 8d3672b..40c0e8b 100755 --- a/key.c +++ b/key.c @@ -178,11 +178,18 @@ keypress(XKeyEvent *e) /* switch virts */ if (e->keycode == rightcode && (e->state&SHORTCUTMOD) == (MODBITS)) - if (numvirtuals > 1 && virt < numvirtuals - 1) - switch_to(virt + 1); + if (numvirtuals > 1) + if (virt < numvirtuals - 1) + switch_to(virt + 1); + else + switch_to(0); + if (e->keycode == leftcode && (e->state&SHORTCUTMOD) == (MODBITS)) - if (numvirtuals >1 && virt > 0) - switch_to(virt - 1); + if (numvirtuals >1) + if (virt > 0) + switch_to(virt - 1); + else + switch_to(numvirtuals - 1); XAllowEvents(dpy, SyncKeyboard, e->time); } diff --git a/menu.c b/menu.c index ae9592a..290b8f9 100755 --- a/menu.c +++ b/menu.c @@ -410,6 +410,7 @@ switch_to_c(int n, Client *c) void switch_to(int n) { + static char virtmsg[32]; if(n == virt) return; currents[virt] = current; @@ -422,6 +423,17 @@ switch_to(int n) switch_to_c(n, clients); 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