[Solved] Automatic Keyboard wake from Suspend/Sleep (How to deactivate)

Questions about applications and software
Forum rules
Before you post please read how to get help
Post Reply
Laugh2
Level 4
Level 4
Posts: 236
Joined: Fri Aug 16, 2013 4:01 am

[Solved] Automatic Keyboard wake from Suspend/Sleep (How to deactivate)

Post by Laugh2 »

Touching a key after putting LM18 to suspend/sleep wakes the machine again. How can this be stopped/disabled?

This behaviour is undesirable as I move the keyboard off the desk when not required - the result is that any touch of a key while moving the keyboard away or accidentally during off desk storage wakes the computer again.

Any ideas how to stop this happening?
Last edited by Laugh2 on Fri Feb 17, 2017 5:06 pm, edited 2 times in total.
magnus7
Level 4
Level 4
Posts: 332
Joined: Sat Jan 30, 2016 8:46 pm

Re: Automatic Keyboard wake from Suspend/Sleep

Post by magnus7 »

In terminal:

Code: Select all

cat /proc/acpi/wakeup
You can see which devices are currently enabled to resume from suspend.
If your keyboard is plugged into USB find all USB ports. Look for something like USB2, EHC3, HXC1. Use lspci command in terminal to verify their names.
Open /etc/rc.local file as "root". Above last line add this line for every USB port (change EHC3 to the names of your USB ports):

Code: Select all

echo "EHC3" > /proc/acpi/wakeup
It should disable waking up for USB on every startup.
Laugh2
Level 4
Level 4
Posts: 236
Joined: Fri Aug 16, 2013 4:01 am

[Solved] Re: Automatic Keyboard wake from Suspend/Sleep

Post by Laugh2 »

Thank you, Magnus7.

Your post put me on the right track. Although I wasn't immediately successful I searched again but using some of your keywords i.e. "ubuntu deactivate wake", and found two relevant postings:

https://askubuntu.com/questions/252743/ ... sable-this
http://askubuntu.com/questions/746865/m ... disable-it

In short:

Entering "lspci" returned:

Code: Select all

00:00.0 Host bridge: Intel Corporation 4 Series Chipset DRAM Controller (rev 03)
00:01.0 PCI bridge: Intel Corporation 4 Series Chipset PCI Express Root Port (rev 03)
00:03.0 Communication controller: Intel Corporation 4 Series Chipset HECI Controller (rev 03)
00:03.2 IDE interface: Intel Corporation 4 Series Chipset PT IDER Controller (rev 03)
00:03.3 Serial controller: Intel Corporation 4 Series Chipset Serial KT Controller (rev 03)
00:19.0 Ethernet controller: Intel Corporation 82567LM-3 Gigabit Network Connection (rev 02)
00:1a.0 USB controller: Intel Corporation 82801JD/DO (ICH10 Family) USB UHCI Controller #4 (rev 02)
00:1a.1 USB controller: Intel Corporation 82801JD/DO (ICH10 Family) USB UHCI Controller #5 (rev 02)
00:1a.2 USB controller: Intel Corporation 82801JD/DO (ICH10 Family) USB UHCI Controller #6 (rev 02)
00:1a.7 USB controller: Intel Corporation 82801JD/DO (ICH10 Family) USB2 EHCI Controller #2 (rev 02)
00:1b.0 Audio device: Intel Corporation 82801JD/DO (ICH10 Family) HD Audio Controller (rev 02)
00:1c.0 PCI bridge: Intel Corporation 82801JD/DO (ICH10 Family) PCI Express Port 1 (rev 02)
00:1c.4 PCI bridge: Intel Corporation 82801JD/DO (ICH10 Family) PCI Express Port 5 (rev 02)
00:1d.0 USB controller: Intel Corporation 82801JD/DO (ICH10 Family) USB UHCI Controller #1 (rev 02)
00:1d.1 USB controller: Intel Corporation 82801JD/DO (ICH10 Family) USB UHCI Controller #2 (rev 02)
00:1d.2 USB controller: Intel Corporation 82801JD/DO (ICH10 Family) USB UHCI Controller #3 (rev 02)
00:1d.7 USB controller: Intel Corporation 82801JD/DO (ICH10 Family) USB2 EHCI Controller #1 (rev 02)
00:1e.0 PCI bridge: Intel Corporation 82801 PCI Bridge (rev a2)
00:1f.0 ISA bridge: Intel Corporation 82801JDO (ICH10DO) LPC Interface Controller (rev 02)
00:1f.2 SATA controller: Intel Corporation 82801JD/DO (ICH10 Family) SATA AHCI Controller (rev 02)
01:00.0 VGA compatible controller: NVIDIA Corporation GF106GL [Quadro 2000] (rev a1)
01:00.1 Audio device: NVIDIA Corporation GF106 High Definition Audio Controller (rev a1)
Entering "cat /proc/acpi/wakeup | sort" returned (ignore here "enable" and "disabled" because here it shows the "afterwards" state):

Code: Select all

COM1	  S4	*disabled  pnp:00:03
COM2	  S4	*disabled
Device	S-state	  Status   Sysfs node
EUS1	  S3	*disabled  pci:0000:00:1d.7
EUS2	  S3	*disabled  pci:0000:00:1a.7
HUB	  S4	*disabled  pci:0000:00:1e.0
IGBE	  S4	*disabled  pci:0000:00:19.0
PBTN	  S4	*disabled  platform:PNP0C0C:00
PCI0	  S4	*disabled  no-bus:pci0000:00
PCX1	  S4	*disabled  pci:0000:00:1c.0
PCX2	  S4	*disabled
PCX5	  S4	*disabled  pci:0000:00:1c.4
PCX6	  S4	*disabled
PEG1	  S4	*disabled  pci:0000:00:01.0
PEG2	  S4	*disabled
USB1	  S3	*enabled   pci:0000:00:1d.0
USB2	  S3	*enabled   pci:0000:00:1d.1
USB3	  S3	*enabled   pci:0000:00:1d.2
USB4	  S3	*enabled   pci:0000:00:1a.0
USB5	  S3	*enabled   pci:0000:00:1a.1
USB6	  S3	*enabled   pci:0000:00:1a.2
As mentioned in the first of the two URLs mentioned above, I had to enter all relevant devices into /etc/rc.local before deactivation would work. This was done as su by adding "echo "XXXX" > /proc/acpi/wakeup" to the file /etc/rc.local. If anyone is trying this, use the device codes listed in the left-hand column returned by cat /proc/acpi/wakeup | sort instead of XXXX. There is a bit of trial-and-error to find all the necessary codes (missing just one might result in not being successful).

The final version of /etc/rc.local became:

Code: Select all

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

echo "EHCI Controller #1" > /proc/acpi/wakeup
echo "EHCI Controller #2" > /proc/acpi/wakeup
echo "EUS1" > /proc/acpi/wakeup
echo "EUS2" > /proc/acpi/wakeup
echo "IGBE" > /proc/acpi/wakeup
echo "PBTN" > /proc/acpi/wakeup

exit 0
(Note: there may be a line or two which isn't actually required.)

This was successful for this machine :D. Yeah! Only the on/off/power button wakes the system now. I'll install this for all the devices and users I administer.

While I can understand the "automatic wake" feature might be useful, from internet postings it seems there are others (many?) who find it as unproductive as I do. Could the Mint team (or the Ubuntu team) perhaps add an easier way for users to decide if this feature is activated? Especially as it is the default setting.
Last edited by Laugh2 on Wed Feb 22, 2017 12:56 am, edited 4 times in total.
magnus7
Level 4
Level 4
Posts: 332
Joined: Sat Jan 30, 2016 8:46 pm

Re: [Solved] Re: Automatic Keyboard wake from Suspend/Sleep

Post by magnus7 »

Laugh2 wrote:Thank you, Magnus7.

Your post put me on the right track. Although I wasn't immediately successful I searched again but using some of your keywords i.e. "ubuntu deactivate wake", and found two relevant postings:
You're welcome, but I can't find what you did differently in comparison to my post, except:
cat /proc/acpi/wakeup and lspci commands don't need su.
Alphabetical sorting in cat /proc/acpi/wakeup | sort moves names of columns to the third row.
echo "EHCI Controller #1" > /proc/acpi/wakeup and echo "EHCI Controller #2" > /proc/acpi/wakeup won't work.
echo "IGBE" > /proc/acpi/wakeup and echo "PBTN" > /proc/acpi/wakeup are unnecessary. They are Ethernet and Power Button on keyboard.
Laugh2
Level 4
Level 4
Posts: 236
Joined: Fri Aug 16, 2013 4:01 am

Re: [Solved] Automatic Keyboard wake from Suspend/Sleep (How to deactivate)

Post by Laugh2 »

The only real difference was probably that I didn't know enough to put the correct "names" into the commands until I saw the left column resulting from cat /proc/acpi/wakeup | sort. Ie more my lack of knowledge than anything else. Without your post, though, I'd not have got there. Thanks!

(I removed the two mentions of "as su" from my previous post.)
magnus7
Level 4
Level 4
Posts: 332
Joined: Sat Jan 30, 2016 8:46 pm

Re: [Solved] Automatic Keyboard wake from Suspend/Sleep (How to deactivate)

Post by magnus7 »

Finding the names of USB ports is a matter of matching sysfs node numbers in two files.

lspci:
00:1a.7 USB controller: Intel Corporation 82801JD/DO (ICH10 Family) USB2 EHCI Controller #2 (rev 02)

wakeup:
EUS2 S3 *enabled pci:0000:00:1a.7
Last edited by magnus7 on Sat Jan 25, 2020 4:34 am, edited 1 time in total.
User avatar
Minterator
Level 5
Level 5
Posts: 596
Joined: Thu Jan 10, 2013 8:29 am

Re: [Solved] Automatic Keyboard wake from Suspend/Sleep (How to deactivate)

Post by Minterator »

I agree that's tricky business, and if you move the device to another USB port you gotta do it all over again and may enable additional devices too in other ports.

Ubuntu/Mint should have a gui for designating USB wake devices.

Here's another method with a GUI that at least names the devices and allows you enable/disable:
http://bernaerts.dyndns.org/linux/74-ub ... me-usb-hid
Mint 17.3 MATE, kernel 4.11.12
Laugh2
Level 4
Level 4
Posts: 236
Joined: Fri Aug 16, 2013 4:01 am

Re: [Solved] Automatic Keyboard wake from Suspend/Sleep (How to deactivate)

Post by Laugh2 »

Hi Minterator, thanks for your suggestion. It's interesting that someone went to all the effort of trying to enable this feature when some (many?) would rather see it off. But so is life, we've all got different circumstances, jobs, families, desk/workspaces, ...

The method described by your link apparently applies up to Linux Kernel 3.10 ie. LM15 incl. LM13. Current versions use a later Kernel though. (Perhaps "wake on USB" can be turned off with this method for later Kernel versions if it isn't already working?? I didn't try.) Thanks again for your suggestion.
magnus7
Level 4
Level 4
Posts: 332
Joined: Sat Jan 30, 2016 8:46 pm

Re: [Solved] Automatic Keyboard wake from Suspend/Sleep (How to deactivate)

Post by magnus7 »

GUI is not available yet, so for now a command will do the job.
If you want to disable waking up from suspend for all devices plugged into USB ports, run this command in terminal and restart the computer:

Code: Select all

/usr/bin/lspci | grep USB | cut -d " " -f 1 > ~/Desktop/t7s1 \
&& cat /proc/acpi/wakeup > ~/Desktop/t7s2 \
&& grep -f ~/Desktop/t7s1 ~/Desktop/t7s2 > ~/Desktop/t7s3 \
&& cat ~/Desktop/t7s3 | cut -c 1-4 > ~/Desktop/t7s4 \
&& sed -i -e 's/^/echo "/' ~/Desktop/t7s4 \
&& sed -i 's/$/" > \/proc\/acpi\/wakeup/' ~/Desktop/t7s4 \
&& sed -i '1s/^/#!\/bin\/sh -e\n/' ~/Desktop/t7s4 \
&& sed -i -e "\$aexit 0" ~/Desktop/t7s4 \
&& sudo cp -fr ~/Desktop/t7s4 /etc/rc.local \
&& rm -f ~/Desktop/t7s1 ~/Desktop/t7s2 ~/Desktop/t7s3 ~/Desktop/t7s4
User avatar
Minterator
Level 5
Level 5
Posts: 596
Joined: Thu Jan 10, 2013 8:29 am

Re: [Solved] Automatic Keyboard wake from Suspend/Sleep (How to deactivate)

Post by Minterator »

Laugh2 wrote:Hi Minterator, thanks for your suggestion. It's interesting that someone went to all the effort of trying to enable this feature when some (many?) would rather see it off. But so is life, we've all got different circumstances, jobs, families, desk/workspaces, ...

The method described by your link apparently applies up to Linux Kernel 3.10 ie. LM15 incl. LM13. Current versions use a later Kernel though. (Perhaps "wake on USB" can be turned off with this method for later Kernel versions if it isn't already working?? I didn't try.) Thanks again for your suggestion.
Newer kernels work too. There are some syntax changes in udev and rules directory is now in "/lib/udev/rules.d" though "/etc/udev/rules.d" works too.

To check which devices are enabled/disabled

Code: Select all

grep --color -E '|enabled'  /sys/bus/usb/devices/*/power/wakeup
Mint 17.3 MATE, kernel 4.11.12
User avatar
Minterator
Level 5
Level 5
Posts: 596
Joined: Thu Jan 10, 2013 8:29 am

Re: [Solved] Automatic Keyboard wake from Suspend/Sleep (How to deactivate)

Post by Minterator »

magnus7 wrote:GUI is not available yet, so for now a command will do the job.
If you want to disable waking up from suspend for all devices plugged into USB ports, run this command in terminal and restart the computer:

Code: Select all

/usr/bin/lspci | grep USB | cut -d " " -f 1 > ~/Desktop/t7s1 \
&& cat /proc/acpi/wakeup > ~/Desktop/t7s2 \
&& grep -f ~/Desktop/t7s1 ~/Desktop/t7s2 > ~/Desktop/t7s3 \
&& cat ~/Desktop/t7s3 | cut -c 1-4 > ~/Desktop/t7s4 \
&& sed -i -e 's/^/echo "/' ~/Desktop/t7s4 \
&& sed -i 's/$/" > \/proc\/acpi\/wakeup/' ~/Desktop/t7s4 \
&& sed -i '1s/^/#!\/bin\/sh -e\n/' ~/Desktop/t7s4 \
&& sed -i -e "\$aexit 0" ~/Desktop/t7s4 \
&& sudo cp -fr ~/Desktop/t7s4 /etc/rc.local \
&& rm -f ~/Desktop/t7s1 ~/Desktop/t7s2 ~/Desktop/t7s3 ~/Desktop/t7s4
^^This stuff is outdated and dangerous. To disable wakeup for ALL connected USB devices, simply run

Code: Select all

for f in /sys/bus/usb/devices/*/power/wakeup
do
	echo "disabled" > $f
done
then any UDEV rule(s) will re-enable them on insert/reboot.


..
Mint 17.3 MATE, kernel 4.11.12
magnus7
Level 4
Level 4
Posts: 332
Joined: Sat Jan 30, 2016 8:46 pm

Re: [Solved] Automatic Keyboard wake from Suspend/Sleep (How to deactivate)

Post by magnus7 »

Minterator wrote:^^This stuff is outdated and dangerous.
What is outdated? grep cut cat cp rm sed?
How dangerous is editing text files?
Last edited by magnus7 on Sat Jan 25, 2020 4:32 am, edited 1 time in total.
Laugh2
Level 4
Level 4
Posts: 236
Joined: Fri Aug 16, 2013 4:01 am

Re: [Solved] Automatic Keyboard wake from Suspend/Sleep (How to deactivate)

Post by Laugh2 »

magnus7 wrote:
Mon Feb 20, 2017 9:31 am
GUI is not available yet, so for now a command will do the job.
If you want to disable waking up from suspend for all devices plugged into USB ports, run this command in terminal and restart the computer:

Code: Select all

/usr/bin/lspci | grep USB | cut -d " " -f 1 > ~/Desktop/t7s1 \
&& cat /proc/acpi/wakeup > ~/Desktop/t7s2 \
&& grep -f ~/Desktop/t7s1 ~/Desktop/t7s2 > ~/Desktop/t7s3 \
&& cat ~/Desktop/t7s3 | cut -c 1-4 > ~/Desktop/t7s4 \
&& sed -i -e 's/^/echo "/' ~/Desktop/t7s4 \
&& sed -i 's/$/" > \/proc\/acpi\/wakeup/' ~/Desktop/t7s4 \
&& sed -i '1s/^/#!\/bin\/sh -e\n/' ~/Desktop/t7s4 \
&& sed -i -e "\$aexit 0" ~/Desktop/t7s4 \
&& sudo cp -fr ~/Desktop/t7s4 /etc/rc.local \
&& rm -f ~/Desktop/t7s1 ~/Desktop/t7s2 ~/Desktop/t7s3 ~/Desktop/t7s4
Having just installed LM19.3 this problem still exists (yes, it is a problem as it is a jolly nuisance which is not necessary), unless I have missed something.

I tried the two solutions offered above by magnus7 and Minterator but they didn't work for LM19.3 with all updates (and therefore Kernel Linux 5.3). Is there a method, which works still works e.g. a simple CLI command/GUI ? A simple check box in Screensaver or Power would suffice.
magnus7
Level 4
Level 4
Posts: 332
Joined: Sat Jan 30, 2016 8:46 pm

Re: [Solved] Automatic Keyboard wake from Suspend/Sleep (How to deactivate)

Post by magnus7 »

Run this revised command in terminal and restart the computer. It will create a systemd service which prevent USB devices from waking a computer up from suspend.

Code: Select all

lspci | grep USB | cut -d " " -f 1 > ~/t7s1 \
&& cat /proc/acpi/wakeup > ~/t7s2 && grep -f ~/t7s1 ~/t7s2 > ~/t7s3 \
&& cat ~/t7s3 | cut -c 1-4 > ~/t7s1 \
&& sed -i -e 's|^|echo "|' -e 's|$|" > /proc/acpi/wakeup|' ~/t7s1 \
&& tr -d '\t' < ~/t7s1 > ~/t7s2 && sed -i '1s|^|#!/bin/sh\n|' ~/t7s2 \
&& sudo cp -f ~/t7s2 /usr/local/bin/nowusb.sh \
&& sudo chmod +x /usr/local/bin/nowusb.sh && rm -f ~/t7s1 ~/t7s2 ~/t7s3 \
&& printf '%s\n' '[Unit]' 'Description=no-wakeup-usb' '[Service]' \
'ExecStart=/usr/local/bin/nowusb.sh' '[Install]' \
'WantedBy=multi-user.target' \
| sudo tee /etc/systemd/system/no_wakeup_usb.service \
&& sudo systemctl enable no_wakeup_usb.service
If you want to disable the service:

Code: Select all

sudo systemctl disable no_wakeup_usb.service
Enable the service again:

Code: Select all

sudo systemctl enable no_wakeup_usb.service
Last edited by magnus7 on Fri Oct 09, 2020 10:47 am, edited 3 times in total.
Laugh2
Level 4
Level 4
Posts: 236
Joined: Fri Aug 16, 2013 4:01 am

Re: [Solved] Automatic Keyboard wake from Suspend/Sleep (How to deactivate)

Post by Laugh2 »

Thank you, Magnus7. I've just noticed that I hadn't replied saying that your updated suggestion works for LM19.3. :-)
Laugh2
Level 4
Level 4
Posts: 236
Joined: Fri Aug 16, 2013 4:01 am

Re: [Solved] Automatic Keyboard wake from Suspend/Sleep (How to deactivate)

Post by Laugh2 »

Hi, unfortunately this annoying aspect of Linux Mint has persisted into LM20 MATE i.e. even slight movement of mouse or keyboard wake the machine from suspend.

Will Magnus7's last suggestion above also work for LM20?
magnus7
Level 4
Level 4
Posts: 332
Joined: Sat Jan 30, 2016 8:46 pm

Re: [Solved] Automatic Keyboard wake from Suspend/Sleep (How to deactivate)

Post by magnus7 »

Yes, it works for LM 20.
Laugh2
Level 4
Level 4
Posts: 236
Joined: Fri Aug 16, 2013 4:01 am

Re: [Solved] Automatic Keyboard wake from Suspend/Sleep (How to deactivate)

Post by Laugh2 »

Thank you again, Magnus7. :-) This also works perfectly in LM20.
Kseanfitz_1
Level 3
Level 3
Posts: 129
Joined: Mon Jun 15, 2020 2:32 pm
Location: USA love it or leave it!

Re: [Solved] Automatic Keyboard wake from Suspend/Sleep (How to deactivate)

Post by Kseanfitz_1 »

something that no one touched on is that it is that wake on events are often a feature included in the bios.
i have a uefi/csm bios and it has wake on lan, wake on usb-(mouse) and wake on keyboard.
I enabled my system for wake on key only as i have no lan and my cat will play with the mouse.
Welcome to the Linux Mint forums!
"One, is glad to be of service."
Laugh2
Level 4
Level 4
Posts: 236
Joined: Fri Aug 16, 2013 4:01 am

Re: [Solved] Automatic Keyboard wake from Suspend/Sleep (How to deactivate)

Post by Laugh2 »

Thank you, Kseanfitz_1.
Yes, your Bios/UEFI comment is relevant. However, I had disabled those options in the Bios/UEFI but it didn't solve the problem in my case.
Post Reply

Return to “Software & Applications”