
{"id":38777,"date":"2022-04-16T17:17:45","date_gmt":"2022-04-16T17:17:45","guid":{"rendered":"https:\/\/ubuntuhandbook.org\/?p=38777"},"modified":"2023-03-27T11:20:40","modified_gmt":"2023-03-27T11:20:40","slug":"disable-automatic-airplane-mode-ubuntu","status":"publish","type":"post","link":"https:\/\/ubuntuhandbook.org\/index.php\/2022\/04\/disable-automatic-airplane-mode-ubuntu\/","title":{"rendered":"Disable Automatic Airplane Mode in Ubuntu 22.04 HP Laptop"},"content":{"rendered":"<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/02\/hplip-logo.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-thumbnail wp-image-37671\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/02\/hplip-logo-250x250.png\" alt=\"\" width=\"250\" height=\"250\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/02\/hplip-logo-250x250.png 250w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/02\/hplip-logo-300x300.png 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/02\/hplip-logo-600x600.png 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/02\/hplip-logo-768x768.png 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/02\/hplip-logo.png 1200w\" sizes=\"auto, (max-width: 250px) 100vw, 250px\" \/><\/a><\/p>\n<p>For laptop user, there could be a quite annoying issue that the &#8216;Airplane Mode&#8217; automatically turns on when lid closed, or when the screen is tilted sideways.<\/p>\n<p>For HP laptops running Ubuntu, Fedora, or other Linux using systemd, there&#8217;s a workaround by mapping the HP e057 and e058 scancodes to 240 (no-op key). So it won&#8217;t automatically turn on Airplane Mode, while the option in &#8216;Wi-Fi&#8217; settings and fn + F12 key combination still function.<\/p>\n<p>NOTE: This tutorial is tested and works in my Ubuntu 22.04 on HP 246 laptop. It may or may not work in your machine.<\/p>\n<h3>1. Create service to remap the scancode:<\/h3>\n<p>1.) Firstly, press <b>Ctrl+Alt+T<\/b> on keyboard to open terminal. When it opens, run command to create a service file and edit via Gedit text editor:<\/p>\n<pre>sudo gedit \/etc\/systemd\/system\/hp-keycodes.service<\/pre>\n<p>Depends on your desktop environment, replace <code>gedit<\/code> in command with your system text editor (e.g., <code>gnome-text-editor<\/code> for Ubuntu 22.10+\/Fedora workstation), or use <code>nano<\/code> command line editor that works in most Linux. When file opens, paste below lines and save it.<\/p>\n<blockquote><p>[Unit]<br \/>\nDescription=HP setkeycodes fix<\/p>\n<p>[Service]<br \/>\nType=oneshot<br \/>\nRestart=no<br \/>\nRemainAfterExit=no<br \/>\nExecStart=\/usr\/bin\/setkeycodes e057 240 e058 240<\/p>\n<p>[Install]<br \/>\nWantedBy=rescue.target<br \/>\nWantedBy=multi-user.target<br \/>\nWantedBy=graphical.target<\/p><\/blockquote>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/map-hp057.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-38778\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/map-hp057-600x261.jpg\" alt=\"\" width=\"600\" height=\"261\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/map-hp057-600x261.jpg 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/map-hp057-300x130.jpg 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/map-hp057-768x334.jpg 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/map-hp057.jpg 930w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>As mentioned, this service will map e057 and e058 scancodes to no operation keycode 240.<\/p>\n<h3>2. Enable the service<\/h3>\n<p>2.) After saving the file (for nano, press <b>Ctrl+X<\/b>, type <b>y<\/b> and hit Enter), reload and enable the service by running commands below one by one:<\/p>\n<pre>sudo systemctl daemon-reload<\/pre>\n<pre>sudo systemctl enable hp-keycodes.service<\/pre>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/enable-hpfix.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-38779\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/enable-hpfix-600x213.webp\" alt=\"\" width=\"600\" height=\"213\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/enable-hpfix-600x213.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/enable-hpfix-300x106.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/enable-hpfix-768x273.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/enable-hpfix.webp 786w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>And finally restart your computer and check the result!<\/p>\n<h3>Undo the changes:<\/h3>\n<p>If the method does not work for you, simply run the command in terminal (Ctrl+Alt+T) to disable the service:<\/p>\n<pre>sudo systemctl disable hp-keycodes.service<\/pre>\n<p>Next remove the file:<\/p>\n<pre>sudo rm \/etc\/systemd\/system\/hp-keycodes.service<\/pre>\n<p>Finally restart your machine to apply change.<\/p>","protected":false},"excerpt":{"rendered":"<p>For laptop user, there could be a quite annoying issue that the &#8216;Airplane Mode&#8217; automatically turns on when lid closed, or when the screen is tilted sideways. For HP laptops running Ubuntu, Fedora, or other Linux using systemd, there&#8217;s a workaround by mapping the HP e057 and e058 scancodes to 240 (no-op key). So it [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":37671,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[2062],"class_list":["post-38777","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-howtos","tag-airplane"],"_links":{"self":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/38777","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/comments?post=38777"}],"version-history":[{"count":0,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/38777\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/media\/37671"}],"wp:attachment":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/media?parent=38777"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/categories?post=38777"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/tags?post=38777"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}