Saturday, May 11, 2024
 Popular · Latest · Hot · Upcoming
3
rated 0 times [  3] [ 0]  / answers: 1 / hits: 5377  / 2 Years ago, fri, july 29, 2022, 8:36:43

I want to create a shortcut key that toggles Airplane Mode On/Off, but do not know what command to use.



To create a shortcut I go to Settings> Keyboard> Shortcuts and then specify a command to be run whenever a given accelerator (shortcut key) is activated.



What command should be specified here to toggle Airplane Mode via a shortcut key?



Note that a while ago I asked a similar question, but the answer that I got back then can not be applied here, since a shortcut key command can not change between "on" and "off", but should truly toggle the Airplane Mode not just activate or deactivate it.


More From » 13.10

 Answers
7

You can use the following simple bash script:



#!/bin/bash

wifi="$(nmcli nm wifi | awk 'FNR == 2 {print $1}')"

if [ "$wifi" = "enabled" ]; then
nmcli nm wifi off
else
nmcli nm wifi on
fi


Don't forget to make it executable:



chmod +x /path/to/script


Then add your custom shortcut to this script (it's up to you what shortcut want to choose - it should be something simple for you, like Alt+F5):



add custom shortcut


[#28621] Saturday, July 30, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
eatack

Total Points: 245
Total Questions: 120
Total Answers: 113

Location: Estonia
Member since Wed, Jun 8, 2022
2 Years ago
eatack questions
Sun, Mar 6, 22, 20:44, 2 Years ago
Tue, Feb 8, 22, 20:50, 2 Years ago
Sat, May 20, 23, 13:30, 1 Year ago
;