Hatena::ブログ(Diary)

linuxとかテストとか RSSフィード

この日記のはてなブックマーク数

2011-09-11 misc memo

Misc memo. disable/enable touchpad via xinput, sent a patch to rhbz 732182.

| 00:37

This is a simple script to Disable/Enable touchpad from terminal via xinput.

#!/bin/bash

val=0

if [ "$#" = "1" ]; then
    val=$1
fi

touchpad_device="FSPPS/2 Sentelic FingerSensingPad"

device_num=`xinput list | grep "$touchpad_device" | cut -d'=' -f2 | awk '{ print $1 }'`
xinput set-prop $device_num "Device Enabled" $val

if [ $val = 0 ]; then
    echo "TouchPad Disabled"
else
    echo "TouchPad Enabled"
fi

exit 0

Bug 732182 looks timing bug. The bug arose strcmp(3) in refresh_task_list() at line 149. The refresh_task_list() is called from timer handler so if this function is called while gtk objects are releasing, it would be dangerous I think.

148:    sprintf (tooltip, _("Memory: %d MB of %d MB used"), memory_used / 1024, sys_stat->mem_total / 1024);
149:    if(strcmp(tooltip,gtk_progress_bar_get_text(GTK_PROGRESS_BAR(mem_usage_progress_bar))))

So I reckon it is safe to remove timer event in on_quit().

diff -uNrp lxtask-0.1.3.orig/src/callbacks.c lxtask-0.1.3.new/src/callbacks.c
--- lxtask-0.1.3.orig/src/callbacks.c   2011-09-10 23:28:00.052455181 +0900
+++ lxtask-0.1.3.new/src/callbacks.c    2011-09-10 23:34:32.426446605 +0900
@@ -26,6 +26,8 @@
 
 #include "callbacks.h"
 
+extern guint rID;
+
 void on_button3_toggled_event(GtkButton *button, GdkEventButton *event)
 {
     full_view = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
@@ -137,6 +139,7 @@ void on_show_cached_as_free_toggled (Gtk
 
 void on_quit(void)
 {
+    g_source_remove(rID);
     save_config();
     free(config_file);
 
トラックバック - http://d.hatena.ne.jp/masami256/20110911/1315669052