3

The 'Airplane Mode' key on my laptop is not working in ubuntu since I have dual booted my laptop on windows and Ubuntu. Wifi hardware is Realtek RTL8723BE. Please help.

2 Answers2

1

I also have had this problem with my HP laptop and Ubuntu 18.04. If you only need to only toggle wifi (but not bluetooth) on or off, you can use the following workaround.

Create a bash script with the following code and save it somewhere in your computer. I save mine as ~/.local/share/scripts/wifi-toggle.sh. If you need to create a folder, you can do it using mkdir /path/to/folder or using the file manager.

#!/bin/bash

wifi_status=`rfkill list wifi | grep "Soft" | cut -d " " -f 3`

icon_dir=/usr/share/icons/Adwaita/scalable/status

if [ $wifi_status == 'no' ]; then
    nmcli radio all off
    notify-send -i $icon_dir/network-wireless-offline-symbolic.svg --hint int:transient:1 "Wi-Fi turned off"
else
    nmcli radio all on
    notify-send -i $icon_dir/network-wireless-signal-excellent-symbolic.svg --hint int:transient:1 "Wi-Fi turned on"
fi

Give execution permissions to your script (I am assuming that the location you saved it is the same as mine; if not, use your location):

chmod +x ~/.local/share/scripts/wifi-toggle.sh

Then, open Gnome settings, go to Keyboard and add a new shortcut (I use Ctrl+F12) using the full path of your script as a command, i.e. /home/your_name/.local/share/scripts/wifi-toggle.sh, where your_name is your user's name.

Edit: This script can be used to turn full airplane mode on or off.

#!/bin/bash

wifi_status=`rfkill list wifi | grep "Soft" | cut -d " " -f 3`
bluetooth_status=`rfkill list bluetooth | grep "Soft" | cut -d " " -f 3`

icon_dir=/usr/share/icons/Adwaita/scalable/status

if [ $wifi_status == 'no' ] || [ $bluetooth_status == 'no' ]; then
    rfkill block all
    notify-send -i $icon_dir/airplane-mode-symbolic.svg --hint int:transient:1 "Airplane mode turned on"
else
    rfkill unblock all
    notify-send -i $icon_dir/network-wireless-signal-excellent-symbolic.svg --hint int:transient:1 "Airplane mode turned off"
fi

However, for me this would need to be run as sudo (I am now using Xubuntu 18.04, so I am not sure if this is the case for Ubuntu too). Save it as ~/.local/share/scripts/airplane-toggle.sh and change its permissions with chmod +x as before. Try running it from terminal with and without sudo. If it runs without sudo, then map it to a shortcut as before. If not, you can only run it with sudo through the terminal.

  • Thank you @user3140225 for the answer. But unfortunatelly this script is not working. Upon running i'm getting a notification that the wifi is turned off nut it's not getting turned on upon running script again. Also, I need to toggle complete Airplane mode off and on, not just wifi. Please suggest the solution. – soham_dhole Jul 30 '19 at 11:04
  • @SohamDhole please see my updated answer. – BeastOfCaerbannog Jul 30 '19 at 11:33
  • As for the first script I posted, it works fine for me, both for on and off. – BeastOfCaerbannog Jul 30 '19 at 11:41
  • Thanks for the suggestion, but still it's not working. I tried with and without sudo . All I can see is a notification mentioning 'Airplane mode turned on/off', but actually my Wi-Fi hardware is still in disabled state, – soham_dhole Jul 30 '19 at 13:00
  • What happens if you run rfkill block all and then rfkill unblock all (with and without sudo )? Also, it takes a bit more time fo the wifi to get turned on, so wait a few seconds to see if it will turn on. – BeastOfCaerbannog Jul 30 '19 at 13:05
  • As far as I can figure out, I think it's the issue with drivers of my hardware, commands like rfkill are not working. For detailed explainantion of my problem kindly see this [link] (https://askubuntu.com/questions/1162067/wifi-hardware-gets-disabled-when-laptop-lid-is-closed-or-pc-is-locked-for-more-t). – soham_dhole Jul 30 '19 at 13:05
  • It looks like your laptop has a hardware switch for the wifi, which blocks it, as stated by "Hard blocked: yes" in the end of the output. Can you turn this off? – BeastOfCaerbannog Jul 30 '19 at 13:08
  • There is a key (Fn+F12) on keyboard which is wifi switch. It works in Windows but not in ubuntu. The other shortcuts on keyboard for volume, media player and brightness work well in Ubuntu. Only the Airplane mode key doesn't work since the beginning. – soham_dhole Jul 30 '19 at 13:11
  • (Fn+F12) soft blocks the wifi. Your problem is the hard block. Perhaps the answers in this question can help you: https://askubuntu.com/questions/98702/how-to-unblock-something-listed-in-rfkill/578827#578827 – BeastOfCaerbannog Jul 30 '19 at 13:21
0

I had to disable the keyboard actions setting in BIOS to regain fn + F keys normal function. I'm using HP Pavillion DM4 Laptop.

Rob
  • 1