Re: How to deal with Tk apps?
Ian Zimmerman <[email protected]>
| Newsgroups | gmane.comp.window-managers.openbox |
|---|---|
| Message-ID | <[email protected]> |
On 2015-12-02 19:15 -0800, I wrote: > Running obxprop on the main window of a Tk program seems to typically > result in something like the following :-( > > [1+0]~$ obxprop | grep '^_OB_' > _OB_APP_TYPE(UTF8_STRING) = "normal" > _OB_APP_TITLE(UTF8_STRING) = "main" > _OB_APP_GROUP_CLASS(UTF8_STRING) = > _OB_APP_GROUP_NAME(UTF8_STRING) = > _OB_APP_CLASS(UTF8_STRING) = "Toplevel" > _OB_APP_NAME(UTF8_STRING) = "main" > _OB_APP_ROLE(UTF8_STRING) = > > This seems to dash any hope of using the openbox per-app settings. So, > is there any way to make it appear on a particular desktop, at least? I have cooked up an openbox patch (attached) to help work around this annoying situation. The idea is that openbox writes the X window ID to a file (you configure the file name) as it starts to manage the window. You can then write a script that starts the original program, then picks up the window ID and calls xdotool on it. The script should probably be careful about the modification time of the file - it should ignore it and error out if the file is more than a few seconds old. I can post the script I wrote to handle this but be warned of my grotty shell scripting style :-P I can of course also make a pull request, if there is interest in such. -- Please *no* private copies of mailing list or newsgroup messages. Rule 420: All persons more than eight miles high to leave the court. _______________________________________________ openbox mailing list [email protected] http://icculus.org/mailman/listinfo/openbox
openbox-log-winid.patch
(text/x-diff, 2.7 KB)
diff --git a/data/rc.xsd b/data/rc.xsd
index bad1492..216a130 100644
--- a/data/rc.xsd
+++ b/data/rc.xsd
@@ -257,6 +257,7 @@
<xsd:element minOccurs="0" name="skip_taskbar" type="ob:bool"/>
<xsd:element minOccurs="0" name="fullscreen" type="ob:bool"/>
<xsd:element minOccurs="0" name="maximized" type="ob:maximization"/>
+ <xsd:element minOccurs="0" name="id_file" type="xsd:string"/>
</xsd:all>
<!-- at least one of these must be present -->
<xsd:attribute name="role" type="xsd:string"/>
diff --git a/openbox/client.c b/openbox/client.c
index c2c458c..0a9070f 100644
--- a/openbox/client.c
+++ b/openbox/client.c
@@ -45,6 +45,8 @@
#include "obt/xqueue.h"
#include "obt/prop.h"
+#include <stdio.h> /* fopen, fprintf, fclose */
+
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
@@ -958,6 +960,15 @@ static ObAppSettings *client_get_settings_state(ObClient *self)
if (match) {
ob_debug("Window matching: %s", app->name);
+ if (app->id_file) {
+ FILE* id_stdio = fopen(app->id_file, "w");
+ if (!id_stdio)
+ ob_debug("unable to fopen(%s)", app->id_file);
+ else {
+ fprintf(id_stdio, "0x%x\n", (unsigned)(self->window));
+ fclose(id_stdio);
+ }
+ }
/* copy the settings to our struct, overriding the existing
settings if they are not defaults */
diff --git a/openbox/config.c b/openbox/config.c
index 4f8cfe5..dafd9b1 100644
--- a/openbox/config.c
+++ b/openbox/config.c
@@ -219,6 +219,9 @@ static void parse_single_per_app_settings(xmlNodePtr app,
xmlNodePtr n, c;
gboolean x_pos_given = FALSE;
+ if ((n = obt_xml_find_node(app->children, "id_file")))
+ settings->id_file = obt_xml_node_string(n);
+
if ((n = obt_xml_find_node(app->children, "decor")))
if (!obt_xml_node_contains(n, "default"))
settings->decor = obt_xml_node_bool(n);
@@ -1232,6 +1235,7 @@ void config_shutdown(void)
if (itd->class) g_pattern_spec_free(itd->class);
if (itd->group_name) g_pattern_spec_free(itd->group_name);
if (itd->group_class) g_pattern_spec_free(itd->group_class);
+ if (itd->id_file) g_free(itd->id_file);
g_slice_free(ObAppSettings, it->data);
}
g_slist_free(config_per_app_settings);
diff --git a/openbox/config.h b/openbox/config.h
index b9f9ed2..a1ba1c4 100644
--- a/openbox/config.h
+++ b/openbox/config.h
@@ -68,6 +68,7 @@ struct _ObAppSettings
gint fullscreen;
gint layer;
+ gchar* id_file;
};
/*! Should new windows be focused */