I got inspired to write this article because my laptop lid messed up and is misbehaving. Even when the lid is open OS assumes it is closed. It caused all kinds of problems. It was frustrating like the laptop would suspend or sleep randomly or screen would blink or go off randomly. (According to the settings associated of course)
If you are not sure if the above-mentioned problems are caused due to Laptop Lid failure then refer to this Laptop screen goes off or suspend randomly, find the cause article. That article will help you to determine if its the issue with drivers, screen or display itself or the lid.
In most cases, it is laptop lid sensor busted or button between lid and body broken. (Some laptops come with a magnetic sensor and some with a mechanical button to detect laptop lid closing) And also let me make this clear this is a guide for people who don’t want to waste money to repair the lid. You don’t have to touch hardware it’s all about software.
1. If you are a Windows user:
So if you use Windows as your operating system then what I would suggest is migrate to Linux. You asking why? Because windows don’t provide you the level of control Linux provides, which is absolutely necessary if you really wish to solve this issue without wasting any money.
If windows is a necessity for you then you can always run windows on a virtual box. I mean with Linux you can solve the lid problem permanently but not with windows. And on top of that, you save money on buying windows license if you start using Linux.
If you don’t wish to migrate to then follow along. The best you can do with windows is set the lid close action as do nothing(still doesn’t solve the problem for real). Yea I know what you are thinking. “If I set it to do nothing then problem solved” right? No, it won’t solve the problem. The screen will still flicker time to time even if you set it to do nothing.
Best solution with Windows on board:
Step 1: Press the windows button and search for the keyword “lid” and press enter.
Step 2: And set the action for ‘when the lid is closed’ to do nothing. (both while on power and on battery)
Windows won’t put your laptop to sleep but it will surely turn your display off as soon as it senses that lid is closed. So a lot of screen flickering anyways.
The best solution:
Switch to Linux and install windows on a virtual box. Or maybe dual boot Windows and Linux (Ubuntu maybe! it is a beginner friendly os) if your survival is impossible without Windows installed on the host machine. I mean you could use Ubuntu as your primary OS and use Windows when absolutely necessary.
2. If you are a Linux user:
Okay, if you switched from windows to Linux then good follow along. With Linux installed on your laptop you can live happily forever with a broken or faulty lid. Basically what you have to do is set ‘lid close action’ as neutral so that your laptop doesn’t suspend automatically or turn the screen off. And prevent laptop wake up when opening the lid so that your laptop doesn’t automatically wake up when suspended.
So what will all that setting change translate into? A laptop whose lid condition doesn’t matter. I mean nothing will depend upon lid closure or opening. Hence a perfectly usable laptop with a broken or faulty lid. You will have to do everything manually. By everything I mean the task of suspending the laptop and waking it up. Okay, lets cut to the chase.
How to set lid close action to do nothing or neutral:
I’m using Ubuntu throughout this tutorial. The process may be different for different distros. (This should work perfectly fine with any distro using Gnome desktop)
Step 1: Launch a new terminal by right-clicking on the desktop and clicking on ‘open terminal‘ and type in the following command.
$ sudo apt-get install gnome-tweaks
Step 2: After the installation process is completed type in ‘gnome-tweaks‘ without quotes and press enter. click on ‘Power‘ tab which is located on the upper left corner of the gnome tweaks tool.
Step 3: You will see an option saying ‘Suspend when laptop lid is closed’ turn it off then close the current window.
Since your laptop will no more suspend randomly you should be at peace by now. Now it will do nothing even if it senses that the lid is closed. The final step towards happiness now ;).
How to prevent laptop resume or wake up from suspend on lid open or disable lid sensor completely:
Launch terminal and type in following commands. Enter your password when prompted.
# you must be logged in as root, this command will log you in as a root user
$ sudo -i
you will see LID0 or LID written towards the end of the list and next to it you will see enabled written with a ‘*‘ sign.
$ echo " LID0" > /proc/acpi/wakeup
This command will toggle the lid setting on or off depending on the situation.
If LID0 is written on your ‘wakeup’ file too then its okay but if not then replace LID0 with LID or whatever name is written on your file. Most probably it will be LID0.
# check if the setting is changed from enabled to disabled or not.
$ cat /proc/acpi/wakeup
Making these changes permanent or persistent
For this purpose, I’m going to use cronjob. Cron will execute the above-mentioned command on every reboot. Hence making the changes permanent (kind of). Cronnob comes preinstalled on most of the Linux distros. The ones that I’m sure of are Kali and Ubuntu.
Okay, there isn’t much you need to do here. You pretty much just have to copy and paste a command.
Make sure you are logged in as root, sudo might not work here(If you previously logged out of root account for some reason then to log in as root type in ‘sudo -i’ without quotes).
$ crontab -e
choose nano as the editor if prompted(nano is pretty easy to use) or something else if you wish.
Now scroll down to to the end of the file and paste this command at the end of the file :
@reboot echo " LID0" > /proc/acpi/wakeup
Now press [ctrl key] and [x key] simultaneously next press [y key] to save changes and at last just press enter.
You are done now. cron will execute the command on every reboot for you.
How to remove the lid script(careful now!):
Only follow the instructions below if you repaired your lid, want to revert the changes made above and want to go back to normal settings.
Step 1: Log in to the terminal as root user and type in ‘crontab -e‘ without quotes.
Step 2: Scroll down to the end of the page and delete the command you pasted earlier.
Step 3: Press [ctrl key] and [x key] simultaneously next press [y key] to save changes and at last just press enter.
Now that the cron job is deleted.
I hope it was helpful. Feel free to drop comments down below if any difficulties, I will be happy to help.