Map key to a script in Ubuntu 18.04.1

I'm on Ubuntu 18.04.1 Bionic Beaver using an HP Pavilion laptop. My laptop has a key for toggling airplane mode. Using xev, I found out that it has keycode 255. I've saved the following code at /bin/airplane_mode and set it as executable:

#!/bin/bash
if [ "$(nmcli r wifi)" = "enabled" ]
then nmcli r wifi off
else nmcli r wifi on
fi

Now, how can I set it up such that this file is run whenever I press that key? Any help would be appreciated.

2 Reset to default

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like