From d9a405e9b3b0e9bfe5686c6df456138b443d1e35 Mon Sep 17 00:00:00 2001
From: Mikael Magnusson <mikachu@gmail.com>
Date: Mon, 7 Sep 2015 00:24:03 +0200
Subject: [PATCH] Add 'last' as a desktop target for if/foreach

---
 openbox/actions/if.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/openbox/actions/if.c b/openbox/actions/if.c
index a9c4094..c76fb71 100644
--- a/openbox/actions/if.c
+++ b/openbox/actions/if.c
@@ -68,6 +68,7 @@ typedef struct {
     gboolean omnipresent_off;
     gboolean desktop_current;
     gboolean desktop_other;
+    gboolean desktop_last;
     guint    desktop_number;
     guint    screendesktop_number;
     guint    client_monitor;
@@ -192,8 +193,10 @@ static void setup_query(Options* o, xmlNodePtr node, QueryTarget target) {
         if ((s = obt_xml_node_string(n))) {
             if (!g_ascii_strcasecmp(s, "current"))
                 q->desktop_current = TRUE;
-            if (!g_ascii_strcasecmp(s, "other"))
+            else if (!g_ascii_strcasecmp(s, "other"))
                 q->desktop_other = TRUE;
+            else if (!g_ascii_strcasecmp(s, "last"))
+                q->desktop_last = TRUE;
             else
                 q->desktop_number = atoi(s);
             g_free(s);
@@ -392,6 +395,8 @@ static gboolean run_func_if(ObActionsData *data, gpointer options)
             is_true &= is_on_current_desktop;
         if (q->desktop_other)
             is_true &= !is_on_current_desktop;
+        if (q->desktop_last)
+            is_true &= query_target->desktop == screen_last_desktop;
 
         if (q->desktop_number) {
             gboolean is_on_desktop =
-- 
1.9.1

