[Xfce4-commits] <xfce4-settings:master> Process xmodmap file at startup and on layout change (Bug #5094).

Jérôme Guelfucci noreply at xfce.org
Sat Oct 23 14:38:01 CEST 2010


Updating branch refs/heads/master
         to e124e7e741aa994fbd52eac9f02c6e0e27732844 (commit)
       from b95f457e7418579d1e6ed89b648054a6012b76b2 (commit)

commit e124e7e741aa994fbd52eac9f02c6e0e27732844
Author: Jérôme Guelfucci <jeromeg at xfce.org>
Date:   Sat Oct 23 14:35:09 2010 +0200

    Process xmodmap file at startup and on layout change (Bug #5094).

 xfce4-settings-helper/keyboard-layout.c |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/xfce4-settings-helper/keyboard-layout.c b/xfce4-settings-helper/keyboard-layout.c
index e49f677..6c21b0a 100644
--- a/xfce4-settings-helper/keyboard-layout.c
+++ b/xfce4-settings-helper/keyboard-layout.c
@@ -45,6 +45,7 @@
 #include "keyboard-layout.h"
 
 static void xfce_keyboard_layout_helper_finalize                  (GObject                       *object);
+static void xfce_keyboard_layout_helper_process_xmodmap           (void);
 static void xfce_keyboard_layout_helper_set_model                 (XfceKeyboardLayoutHelper      *helper);
 static void xfce_keyboard_layout_helper_set_layout                (XfceKeyboardLayoutHelper      *helper);
 static void xfce_keyboard_layout_helper_set_variant               (XfceKeyboardLayoutHelper      *helper);
@@ -108,6 +109,8 @@ xfce_keyboard_layout_helper_init (XfceKeyboardLayoutHelper *helper)
     xfce_keyboard_layout_helper_set_model (helper);
     xfce_keyboard_layout_helper_set_layout (helper);
     xfce_keyboard_layout_helper_set_variant (helper);
+
+    xfce_keyboard_layout_helper_process_xmodmap ();
 }
 
 static void
@@ -123,6 +126,30 @@ xfce_keyboard_layout_helper_finalize (GObject *object)
 }
 
 static void
+xfce_keyboard_layout_helper_process_xmodmap (void)
+{
+    const gchar *xmodmap_path;
+
+    xmodmap_path = g_build_filename (xfce_get_homedir (), ".Xmodmap", NULL);
+
+    if (g_file_test (xmodmap_path, G_FILE_TEST_EXISTS))
+    {
+        /* There is a .Xmodmap file, try to use it */
+        const gchar *xmodmap_command;
+        GError      *error = NULL;
+
+        xmodmap_command = g_strconcat ("xmodmap ", xmodmap_path, NULL);
+
+        /* Launch the xmodmap command and only print errors when in debugging mode */
+        if (!g_spawn_command_line_async (xmodmap_command, &error))
+        {
+            DBG ("Xmodmap call failed: %s", error->message);
+            g_error_free (error);
+        }
+    }
+}
+
+static void
 xfce_keyboard_layout_helper_set_model (XfceKeyboardLayoutHelper *helper)
 {
 #ifdef HAVE_LIBXKLAVIER
@@ -208,4 +235,6 @@ xfce_keyboard_layout_helper_channel_property_changed (XfconfChannel      *channe
     {
         xfce_keyboard_layout_helper_set_variant (helper);
     }
+
+    xfce_keyboard_layout_helper_process_xmodmap ();
 }



More information about the Xfce4-commits mailing list