After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 661643 - media-keys: Add support for XF86Bluetooth/WLAN/UWB
media-keys: Add support for XF86Bluetooth/WLAN/UWB
Status: RESOLVED FIXED
Product: gnome-settings-daemon
Classification: Core
Component: media-keys
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gnome-settings-daemon-maint
gnome-settings-daemon-maint
: 693223 697184 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2011-10-13 10:16 UTC by Gary Ching-Pang Lin
Modified: 2017-04-03 09:46 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
WLAN key pressed (238.21 KB, image/png)
2011-10-13 10:16 UTC, Gary Ching-Pang Lin
  Details
Save and restore cairo context before propagate_draw() (846 bytes, patch)
2011-10-13 10:19 UTC, Gary Ching-Pang Lin
rejected Details | Review
Allow gsd-osd-window to receive events and stop the hide timeout (3.37 KB, patch)
2011-10-13 10:20 UTC, Gary Ching-Pang Lin
needs-work Details | Review
Add support for XF86Bluetooth/WLAN/UWB (58.67 KB, patch)
2011-10-13 10:24 UTC, Gary Ching-Pang Lin
needs-work Details | Review
media-keys: Add support for Killswitch media keys (10.41 KB, patch)
2016-01-08 03:50 UTC, Bastien Nocera
none Details | Review
media-keys: Add support for Killswitch media keys (10.52 KB, patch)
2016-01-09 16:05 UTC, Bastien Nocera
committed Details | Review

Description Gary Ching-Pang Lin 2011-10-13 10:16:12 UTC
Created attachment 198921 [details]
WLAN key pressed

I made some patches for g-s-d to catch XF86Bluetooth/WLAN/UWB and show a UI to enable/disable wireless devices (see the attached screenshot).

The UI inherits gsd-osd-window and is similar to the media-keys-window except it 1) draws more than one icon and 2) catches the mouse press, enter, and leave events for interactive works. Also, the UI hides after a few seconds if no cursor hovers over it.

The idea is to pop up the UI when the BT/WLAN/UWB key is pressed and the user can click the icon to toggle the devices with the help of urfkill[*].

If possible, I would like to extend the UI for the video switch key, so that the user can choose the display mode immediately without going through every mode. It obviously needs some works in the randr plugin.

[*] http://www.freedesktop.org/wiki/Software/urfkill
Comment 1 Gary Ching-Pang Lin 2011-10-13 10:19:29 UTC
Created attachment 198922 [details] [review]
Save and restore cairo context before propagate_draw()

Since gsd-osd-window didn't save and restore the cairo context before gtk_container_propagate_draw(), the window background wouldn't be blended properly with the children.
Comment 2 Gary Ching-Pang Lin 2011-10-13 10:20:06 UTC
Created attachment 198923 [details] [review]
Allow gsd-osd-window to receive events and stop the hide timeout
Comment 3 Gary Ching-Pang Lin 2011-10-13 10:24:50 UTC
Created attachment 198924 [details] [review]
Add support for XF86Bluetooth/WLAN/UWB

This patch checks the existence of urfkill and enable related codes.

It also introduces several extra icons since I didn't find proper ones (either low resolution or just not fit).
Comment 4 James M. Leddy 2012-09-26 16:08:55 UTC
Hello, Would someone please comment on this bug? This is functionality for people that want to be able to disable only bluetooth with hotkeys.
Comment 5 Bastien Nocera 2013-01-13 01:33:00 UTC
Review of attachment 198922 [details] [review]:

GsdOsdWindow doesn't use GTK+ anymore.
Comment 6 Bastien Nocera 2013-01-13 01:35:59 UTC
Review of attachment 198923 [details] [review]:

This should be 2 separate patches.

The portion to ignore the events is probably fine.

I don't like the meddling with the hide timeout though.
Comment 7 Bastien Nocera 2013-01-13 01:44:42 UTC
Review of attachment 198924 [details] [review]:

I'll take a patch that implements the rfkill for WLAN/Bluetooth/UWB right now, and let's discuss a patch for a generic killswitch key later on.

::: configure.ac
@@ +381,3 @@
+dnl ==============================================
+
+have_urfkill=false

I don't want to use urfkill.

Please use the RfkillGlib code in gnome-bluetooth:
http://git.gnome.org/browse/gnome-bluetooth/tree/lib/rfkill-glib.h
instead.

::: data/org.gnome.settings-daemon.plugins.media-keys.gschema.xml.in.in
@@ +146,3 @@
       <_description>Binding for the magnifier to zoom out</_description>
     </key>
+    <key name="activate-killswitch-chooser" type="b">

I'd rather the shortcut be only hard-coded for now.

::: plugins/media-keys/wlan-blocked.svg
@@ +1,1 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>

SVG should be symbolic icons, shipped by gnome-icon-theme-symbolic.
Comment 8 Cosimo Cecchi 2013-02-05 19:53:04 UTC
*** Bug 693223 has been marked as a duplicate of this bug. ***
Comment 9 Bastien Nocera 2013-04-03 16:31:54 UTC
*** Bug 697184 has been marked as a duplicate of this bug. ***
Comment 10 Christian Stadelmann 2015-11-19 15:05:44 UTC
In case anyone is interested, on a Samsung laptop the WLAN key has
number 246 (according to `xinput test-xi2`)
number 238 according to debug output when starting application with WAYLAND_DEBUG=1 under wayland.
Comment 11 Bastien Nocera 2016-01-08 03:50:22 UTC
Created attachment 318449 [details] [review]
media-keys: Add support for Killswitch media keys

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

The reasoning behind those 2 keys toggling the global software
killswitch is that:
- we don't have a killswitch for only WiFi
- there are very very few laptops with a UWB killswitch button, if
  anyone actually remembers what UWB actually is
- there are no XF86 keys for the global killswitch, so they usually get
  mislabeled as the WLAN killswitch
Comment 12 Bastien Nocera 2016-01-09 16:05:49 UTC
Created attachment 318587 [details] [review]
media-keys: Add support for Killswitch media keys

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

The reasoning behind those 2 keys toggling the global software
killswitch is that:
- we don't have a killswitch for only WiFi
- there are very very few laptops with a UWB killswitch button, if
  anyone actually remembers what UWB actually is
- there are no XF86 keys for the global killswitch, so they usually get
  mislabeled as the WLAN killswitch
Comment 13 Bastien Nocera 2016-01-09 16:07:32 UTC
Finally fixed in master for GNOME 3.20!

Attachment 318587 [details] pushed as 3fa0f72 - media-keys: Add support for Killswitch media keys
Comment 14 mahrud 2016-06-27 16:10:55 UTC
This patch broke my XF86WLAN button on Lenovo Thinkpad Yoga 12 running Fedora 24 with g-s-d 3.20.1.

More specifically, the key turns WiFi off, but it never turns it back on again. Note that previously the key worked fine, but I'm not sure if the key on this laptop turns WiFi hardware off or not. How can I check that?

If WiFi is ON the key works as expected, but when on Airplane mode the key acts as if it's pressed twice I believe.
Comment 15 Benjamin Berg 2017-03-31 14:00:37 UTC
The issue is that the kernel *will* process the following EVDEV key events:
 - KEY_WLAN
 - KEY_BLUETOOTH
 - KEY_UWB
 - KEY_WIMAX
 - KEY_RFKILL

Now, we can could an ioctl to prevent the kernel from handling these events (or grab the evdev input device but that is overly evil). The issue is that we would need to turn this off again as soon as our session is not active anymore.

So, I think the best option is to assume that the kernel will do the action for us and that GNOME should only trigger the OSD display to show if the key is seen. Note that there is a risk of the rfkill and evdev events coming in in any order, so we need to be sure that the OSD correctly shows the last rfkill state if the OSD is triggered before the update.

The interesting question is whether there are still corner cases where gnome-settings-daemon *should* trigger the rfkill action itself (e.g. non-linux system, ancient kernels older than 6 years or so).

Right now what happens is when you press the RFKILL key while in airplane mode:
 * RFKILL is turned off by the kernel
 * GSD notices this and sets the state to OFF
 * GNOME shell delivers the action key
 * GSD turns on RFKILL again
Comment 16 Benjamin Berg 2017-03-31 16:06:22 UTC
(In reply to mahrud from comment #14)

See bug #760517 to solve the above issue.
Comment 17 Bastien Nocera 2017-04-03 09:46:40 UTC
(In reply to mahrud from comment #14)
> This patch broke my XF86WLAN button on Lenovo Thinkpad Yoga 12 running
> Fedora 24 with g-s-d 3.20.1.
> 
> More specifically, the key turns WiFi off, but it never turns it back on
> again. Note that previously the key worked fine, but I'm not sure if the key
> on this laptop turns WiFi hardware off or not. How can I check that?
> 
> If WiFi is ON the key works as expected, but when on Airplane mode the key
> acts as if it's pressed twice I believe.

In the future, please do as Benjamin did, and file a new bug. Especially, if the bug has been closed for a period of time. But *do* reference the original bug. Thanks.