gchar *path;
gboolean retval;
- path = g_strdup_printf("/tmp/ibus-%s", ibus_get_user_name ());
+ path = ibus_get_socket_folder ();
mkdir (path, 0700);
chmod (path, 0700);
if not __username:
__username = os.getenv ("USERNAME")
-IBUS_ADDR = "unix:path=/tmp/ibus-%s/ibus-%s-%s" % (__username, __hostname, __display_number)
+__session_id = os.getenv ("IBUS_SESSION_ID")
+
+IBUS_ADDR = "unix:path=/tmp/ibus-%s%s/ibus-%s-%s" % (__username,
+ "-" + __session_id if __session_id else "",
+ __hostname,
+ __display_number)
# IBUS_ADDR = "tcp:host=localhost,port=7799"
IBUS_IFACE_IBUS = "org.freedesktop.IBus"
ibus_bus_connect (bus);
- path = g_strdup_printf ("/tmp/ibus-%s/", ibus_get_user_name ());
+ path = ibus_get_socket_folder ();
file = g_file_new_for_path (path);
priv->monitor = g_file_monitor_directory (file, 0, NULL, NULL);
return username;
}
+const gchar *
+ibus_get_session_id (void)
+{
+ return g_getenv("IBUS_SESSION_ID");
+}
+
+const gchar *
+ibus_get_socket_folder (void)
+{
+ static gchar *folder = NULL;
+
+ if (folder == NULL) {
+ const gchar *session = ibus_get_session_id ();
+ if (session && session[0] != '\0') {
+ folder = g_strdup_printf ("/tmp/ibus-%s-%s",
+ ibus_get_user_name (), session);
+ }
+ else {
+ folder = g_strdup_printf ("/tmp/ibus-%s",
+ ibus_get_user_name ());
+ }
+ }
+ return folder;
+}
+
const gchar *
ibus_get_socket_path (void)
{
const gchar *ibus_get_address (void);
const gchar *ibus_get_user_name (void);
const gchar *ibus_get_socket_path (void);
+const gchar *ibus_get_socket_folder (void);
const gchar *ibus_keyval_name (guint keyval);
guint ibus_keyval_from_name (const gchar *keyval_name);