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