diff options
Diffstat (limited to '_posts/posts/2020-08-15-systemd-disable-wake-onmouse.md')
| -rw-r--r-- | _posts/posts/2020-08-15-systemd-disable-wake-onmouse.md | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/_posts/posts/2020-08-15-systemd-disable-wake-onmouse.md b/_posts/posts/2020-08-15-systemd-disable-wake-onmouse.md new file mode 100644 index 0000000..8122322 --- /dev/null +++ b/_posts/posts/2020-08-15-systemd-disable-wake-onmouse.md | |||
| @@ -0,0 +1,74 @@ | |||
| 1 | --- | ||
| 2 | title: Disable mouse wake from suspend with systemd service | ||
| 3 | permalink: /disable-mouse-wake-from-suspend-with-systemd-service.html | ||
| 4 | date: 2020-08-15T12:00:00+02:00 | ||
| 5 | layout: post | ||
| 6 | type: post | ||
| 7 | draft: false | ||
| 8 | --- | ||
| 9 | |||
| 10 | I recently bought [ThinkPad | ||
| 11 | X220](https://www.laptopmag.com/reviews/laptops/lenovo-thinkpad-x220) just as a | ||
| 12 | joke on eBay to test Linux distributions and play around with things and not | ||
| 13 | destroy my main machine. Little to my knowledge I felt in love with it. Man, | ||
| 14 | they really made awesome machines back then. | ||
| 15 | |||
| 16 | After changing disk that came with it to SSD and installing Ubuntu to test if | ||
| 17 | everything works I noticed that even after a single touch of my external mouse | ||
| 18 | the system would wake up from sleep even though the lid was shut down. | ||
| 19 | |||
| 20 | I wouldn't even noticed it if laptop didn't have [LED | ||
| 21 | sleep indicator](https://support.lenovo.com/lk/en/solutions/~/media/Images/ContentImages/p/pd025386_x1_status_03.ashx?w=426&h=262). | ||
| 22 | I already had a bad experience with Linux and it's power management. I had a | ||
| 23 | [Dell Inspiron 7537](https://www.pcmag.com/reviews/dell-inspiron-15-7537) laptop | ||
| 24 | with a touchscreen and while traveling it decided to wake up and started cooking | ||
| 25 | in my backpack to the point that the digitizer responsible for touch actually | ||
| 26 | glue off and the whole screen got wrecked. So, I am a bit touchy about this. | ||
| 27 | |||
| 28 | I went on solution hunting and to my surprise there is no easy way to disable | ||
| 29 | specific devices to perform wake up. Why is this not under the power management | ||
| 30 | tab in setting is really strange. | ||
| 31 | |||
| 32 | After googling for a solution I found [this nice article describing the | ||
| 33 | solution](https://codetrips.com/2020/03/18/ubuntu-disable-mouse-wake-from-suspend/) | ||
| 34 | that worked for me. The only problem with this solution was that he added his | ||
| 35 | solution to `.bashrc` and this triggers `sudo` that asks for a password each | ||
| 36 | time new terminal is opened, which get annoying quickly since I open a lot of | ||
| 37 | terminals all the time. | ||
| 38 | |||
| 39 | I followed his instructions and got to solution `sudo sh -c "echo 'disabled' > | ||
| 40 | /sys/bus/usb/devices/2-1.1/power/wakeup"`. | ||
| 41 | |||
| 42 | I created a system service file `sudo nano | ||
| 43 | /etc/systemd/system/disable-mouse-wakeup.service` and removed `sudo` and | ||
| 44 | replaced `sh` with `/usr/bin/sh` and pasted all that in `ExecStart`. | ||
| 45 | |||
| 46 | ```ini | ||
| 47 | [Unit] | ||
| 48 | Description=Disables wakeup on mouse event | ||
| 49 | After=network.target | ||
| 50 | StartLimitIntervalSec=0 | ||
| 51 | |||
| 52 | [Service] | ||
| 53 | Type=simple | ||
| 54 | Restart=always | ||
| 55 | RestartSec=1 | ||
| 56 | User=root | ||
| 57 | ExecStart=/usr/bin/sh -c "echo 'disabled' > /sys/bus/usb/devices/2-1.1/power/wakeup" | ||
| 58 | |||
| 59 | [Install] | ||
| 60 | WantedBy=multi-user.target | ||
| 61 | ``` | ||
| 62 | |||
| 63 | After that I enabled, started and checked status of service. | ||
| 64 | |||
| 65 | ```sh | ||
| 66 | sudo systemctl enable disable-mouse-wakeup.service | ||
| 67 | sudo systemctl start disable-mouse-wakeup.service | ||
| 68 | sudo systemctl status disable-mouse-wakeup.service | ||
| 69 | ``` | ||
| 70 | |||
| 71 | This will permanently disable that device from wakeing up you computer on boot. | ||
| 72 | If you have many devices you would like to surpress from waking up your machine | ||
| 73 | I would create a shell script and call that instead of direclty doing it in | ||
| 74 | service file. | ||
