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