mate-desktop / mate-settings-daemon

MATE settings daemon
https://mate-desktop.org
GNU General Public License v2.0
43 stars 48 forks source link

media-keys: Add support for Killswitch media keys #245

Closed zhangxianwei8 closed 5 years ago

zhangxianwei8 commented 6 years ago

Add support for the XF86Bluetooth and XF86WLAN media keys. The first one will toggle Bluetooth on/off, as the Bluetooth panel does, the latter one will toggle the global software killswitch.

The reasoning XF86WLAN media key toggling the global software killswitch is that:

Ported from gnome-settings-daemon: from https://github.com/GNOME/gnome-settings-daemon/commit/3fa0f7260a6864dfe67bdbd82b22b168e1e66457

This feature requires rfkill plugin support. See: rfkill: Add RFKill support plugin on Linux systems from https://github.com/GNOME/gnome-settings-daemon/commit/444af32e343a79ca3db0f957bf73687a0f0df9ec

How to test: Need a laptop with airplane/wifi or bluetooth hotkey, press the key to switch airplane or bluetooth on/off: 2018-10-18 05-28-43

2018-10-18 05-38-15

PS: there is no regular icons in mate-icon-theme, so I use symbolic icons instead.

zhangxianwei8 commented 6 years ago

This new feature is very useful for users to give a visual feed back to control a wireless device on/off. So I hope you can merge it:)

raveit65 commented 6 years ago

Any chance to fix this deprecations?

rfkill-glib.c: In function 'cc_rfkill_glib_send_event_finish':
rfkill-glib.c:77:2: warning: 'g_simple_async_result_get_source_tag' is deprecated [-Wdeprecated-declarations]
  g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == cc_rfkill_glib_send_event);
  ^~~~~~~~~~~~~~
In file included from /usr/include/glib-2.0/gio/gio.h:117,
                 from rfkill-glib.c:36:
/usr/include/glib-2.0/gio/gsimpleasyncresult.h:99:21: note: declared here
 gpointer            g_simple_async_result_get_source_tag   (GSimpleAsyncResult      *simple);
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rfkill-glib.c:79:2: warning: 'g_simple_async_result_propagate_error' is deprecated [-Wdeprecated-declarations]
  if (g_simple_async_result_propagate_error (simple, error))
  ^~
In file included from /usr/include/glib-2.0/gio/gio.h:117,
                 from rfkill-glib.c:36:
/usr/include/glib-2.0/gio/gsimpleasyncresult.h:119:21: note: declared here
 gboolean            g_simple_async_result_propagate_error  (GSimpleAsyncResult      *simple,
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rfkill-glib.c:82:2: warning: 'g_simple_async_result_get_op_res_gssize' is deprecated [-Wdeprecated-declarations]
  return (g_simple_async_result_get_op_res_gssize (simple) >= 0);
  ^~~~~~
In file included from /usr/include/glib-2.0/gio/gio.h:117,
                 from rfkill-glib.c:36:
/usr/include/glib-2.0/gio/gsimpleasyncresult.h:85:21: note: declared here
 gssize              g_simple_async_result_get_op_res_gssize   (GSimpleAsyncResult      *simple);
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rfkill-glib.c: In function 'write_done_cb':
rfkill-glib.c:96:3: warning: 'g_simple_async_result_take_error' is deprecated [-Wdeprecated-declarations]
   g_simple_async_result_take_error (simple, error);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/glib-2.0/gio/gio.h:117,
                 from rfkill-glib.c:36:
/usr/include/glib-2.0/gio/gsimpleasyncresult.h:116:21: note: declared here
 void                g_simple_async_result_take_error       (GSimpleAsyncResult      *simple,
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rfkill-glib.c:98:3: warning: 'g_simple_async_result_set_op_res_gssize' is deprecated [-Wdeprecated-declarations]
   g_simple_async_result_set_op_res_gssize (simple, ret);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/glib-2.0/gio/gio.h:117,
                 from rfkill-glib.c:36:
/usr/include/glib-2.0/gio/gsimpleasyncresult.h:82:21: note: declared here
 void                g_simple_async_result_set_op_res_gssize   (GSimpleAsyncResult      *simple,
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rfkill-glib.c:100:2: warning: 'g_simple_async_result_complete_in_idle' is deprecated [-Wdeprecated-declarations]
  g_simple_async_result_complete_in_idle (simple);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/glib-2.0/gio/gio.h:117,
                 from rfkill-glib.c:36:
/usr/include/glib-2.0/gio/gsimpleasyncresult.h:106:21: note: declared here
 void                g_simple_async_result_complete_in_idle (GSimpleAsyncResult      *simple);
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rfkill-glib.c: In function 'cc_rfkill_glib_send_event':
rfkill-glib.c:116:2: warning: 'g_simple_async_result_new' is deprecated: Use 'g_task_new' instead [-Wdeprecated-declarations]
  simple = g_simple_async_result_new (G_OBJECT (rfkill),
  ^~~~~~
In file included from /usr/include/glib-2.0/gio/gio.h:117,
                 from rfkill-glib.c:36:
/usr/include/glib-2.0/gio/gsimpleasyncresult.h:51:21: note: declared here
 GSimpleAsyncResult *g_simple_async_result_new              (GObject                 *source_object,
                     ^~~~~~~~~~~~~~~~~~~~~~~~~
rfkill-glib.c: In function 'cc_rfkill_glib_send_change_all_event_finish':
rfkill-glib.c:135:2: warning: 'g_simple_async_result_get_source_tag' is deprecated [-Wdeprecated-declarations]
  g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == cc_rfkill_glib_send_change_all_event);
  ^~~~~~~~~~~~~~
In file included from /usr/include/glib-2.0/gio/gio.h:117,
                 from rfkill-glib.c:36:
/usr/include/glib-2.0/gio/gsimpleasyncresult.h:99:21: note: declared here
 gpointer            g_simple_async_result_get_source_tag   (GSimpleAsyncResult      *simple);
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rfkill-glib.c:137:2: warning: 'g_simple_async_result_propagate_error' is deprecated [-Wdeprecated-declarations]
  if (g_simple_async_result_propagate_error (simple, error))
  ^~
In file included from /usr/include/glib-2.0/gio/gio.h:117,
                 from rfkill-glib.c:36:
/usr/include/glib-2.0/gio/gsimpleasyncresult.h:119:21: note: declared here
 gboolean            g_simple_async_result_propagate_error  (GSimpleAsyncResult      *simple,
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rfkill-glib.c:140:2: warning: 'g_simple_async_result_get_op_res_gboolean' is deprecated [-Wdeprecated-declarations]
  return g_simple_async_result_get_op_res_gboolean (simple);
  ^~~~~~
In file included from /usr/include/glib-2.0/gio/gio.h:117,
                 from rfkill-glib.c:36:
/usr/include/glib-2.0/gio/gsimpleasyncresult.h:91:21: note: declared here
 gboolean            g_simple_async_result_get_op_res_gboolean (GSimpleAsyncResult      *simple);
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rfkill-glib.c: In function 'write_change_all_again_done_cb':
rfkill-glib.c:156:3: warning: 'g_simple_async_result_take_error' is deprecated [-Wdeprecated-declarations]
   g_simple_async_result_take_error (rfkill->priv->simple, error);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/glib-2.0/gio/gio.h:117,
                 from rfkill-glib.c:36:
/usr/include/glib-2.0/gio/gsimpleasyncresult.h:116:21: note: declared here
 void                g_simple_async_result_take_error       (GSimpleAsyncResult      *simple,
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rfkill-glib.c:158:3: warning: 'g_simple_async_result_set_op_res_gboolean' is deprecated [-Wdeprecated-declarations]
   g_simple_async_result_set_op_res_gboolean (rfkill->priv->simple, ret >= 0);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/glib-2.0/gio/gio.h:117,
                 from rfkill-glib.c:36:
/usr/include/glib-2.0/gio/gsimpleasyncresult.h:88:21: note: declared here
 void                g_simple_async_result_set_op_res_gboolean (GSimpleAsyncResult      *simple,
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rfkill-glib.c:160:2: warning: 'g_simple_async_result_complete_in_idle' is deprecated [-Wdeprecated-declarations]
  g_simple_async_result_complete_in_idle (rfkill->priv->simple);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/glib-2.0/gio/gio.h:117,
                 from rfkill-glib.c:36:
/usr/include/glib-2.0/gio/gsimpleasyncresult.h:106:21: note: declared here
 void                g_simple_async_result_complete_in_idle (GSimpleAsyncResult      *simple);
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rfkill-glib.c: In function 'write_change_all_timeout_cb':
rfkill-glib.c:172:2: warning: 'g_simple_async_result_set_error' is deprecated [-Wdeprecated-declarations]
  g_simple_async_result_set_error (rfkill->priv->simple,
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/glib-2.0/gio/gio.h:117,
                 from rfkill-glib.c:36:
/usr/include/glib-2.0/gio/gsimpleasyncresult.h:122:21: note: declared here
 void                g_simple_async_result_set_error        (GSimpleAsyncResult      *simple,
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rfkill-glib.c:176:2: warning: 'g_simple_async_result_complete_in_idle' is deprecated [-Wdeprecated-declarations]
  g_simple_async_result_complete_in_idle (rfkill->priv->simple);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/glib-2.0/gio/gio.h:117,
                 from rfkill-glib.c:36:
/usr/include/glib-2.0/gio/gsimpleasyncresult.h:106:21: note: declared here
 void                g_simple_async_result_complete_in_idle (GSimpleAsyncResult      *simple);
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rfkill-glib.c: In function 'write_change_all_done_cb':
rfkill-glib.c:199:3: warning: 'g_simple_async_result_take_error' is deprecated [-Wdeprecated-declarations]
   g_simple_async_result_take_error (rfkill->priv->simple, error);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/glib-2.0/gio/gio.h:117,
                 from rfkill-glib.c:36:
/usr/include/glib-2.0/gio/gsimpleasyncresult.h:116:21: note: declared here
 void                g_simple_async_result_take_error       (GSimpleAsyncResult      *simple,
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rfkill-glib.c:202:3: warning: 'g_simple_async_result_set_op_res_gboolean' is deprecated [-Wdeprecated-declarations]
   g_simple_async_result_set_op_res_gboolean (rfkill->priv->simple, ret >= 0);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/glib-2.0/gio/gio.h:117,
                 from rfkill-glib.c:36:
/usr/include/glib-2.0/gio/gsimpleasyncresult.h:88:21: note: declared here
 void                g_simple_async_result_set_op_res_gboolean (GSimpleAsyncResult      *simple,
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rfkill-glib.c:213:2: warning: 'g_simple_async_result_complete_in_idle' is deprecated [-Wdeprecated-declarations]
  g_simple_async_result_complete_in_idle (rfkill->priv->simple);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/glib-2.0/gio/gio.h:117,
                 from rfkill-glib.c:36:
/usr/include/glib-2.0/gio/gsimpleasyncresult.h:106:21: note: declared here
 void                g_simple_async_result_complete_in_idle (GSimpleAsyncResult      *simple);
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rfkill-glib.c: In function 'cc_rfkill_glib_send_change_all_event':
rfkill-glib.c:233:2: warning: 'g_simple_async_result_new' is deprecated: Use 'g_task_new' instead [-Wdeprecated-declarations]
  simple = g_simple_async_result_new (G_OBJECT (rfkill),
  ^~~~~~
In file included from /usr/include/glib-2.0/gio/gio.h:117,
                 from rfkill-glib.c:36:
/usr/include/glib-2.0/gio/gsimpleasyncresult.h:51:21: note: declared here
 GSimpleAsyncResult *g_simple_async_result_new              (GObject                 *source_object,
                     ^~~~~~~~~~~~~~~~~~~~~~~~~
raveit65 commented 6 years ago

Ok, the wifi media key works fine in a first test. But my notebook doesn't have an internal bluetooth modul, and this doesn't work with an usb-bluetooth dongle. So, i can't test this. @vkareh @flexiondotorg @sc0w Can you help out?

lukefromdc commented 6 years ago

I too do not have a laptop with any functional media keys or any bluetooth devices at all

zhangxianwei8 commented 5 years ago

Already fixed build warings. @raveit65

lukefromdc commented 5 years ago

Does anyone here have bluetooth devices to test that part of the code?

vkareh commented 5 years ago

I do, I'll take a look at this