LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (https://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   Mouse Awakens Laptop from Suspend (https://www.linuxquestions.org/questions/linux-hardware-18/mouse-awakens-laptop-from-suspend-4175735383/)

will41 03-27-2024 04:59 PM

Mouse Awakens Laptop from Suspend
 
I have a Lenovo C940 with 16gb ram, 1tb ssd, running Fedora 39 Cinnamon desktop which is up to date. I am also using a wireless Logitech mouse with the dongle plugged into a type "A" usb port (there is only one type "A" port). This all works great except when the C940 is in suspend mode, the slightest movement of the mouse will awaken it. I have discovered that the following will prevent this from occurring:
Code:

sudo echo "XHC" > /proc/acpi/wakeup
However, this only works for the current session and at next boot it has to be run again. Is it possible to use the GUI "Startup Applications" to run a script containing this command? The issue there might be that to run it I need to be su. Will sudo and the subsequent password work in script? I'm not sure I want to do that even if it will. The other question is how to get the script into the "Startup Applications" list? I see no way to do that unless I edit one of the items already there.

jefro 03-27-2024 06:07 PM

Does bios have any wake on settings?

will41 03-27-2024 07:13 PM

Doesn't appear so. The only usb related settings:
Enable/disable boot for usb = enabled
usb to lan device pxe boot =disabled
Always on usb = disabled

Lurchicus 04-06-2024 01:33 PM

I'm not sure if this applies, but I also have a wireless Logitech mouse and dongle and it also wakes up my system if I move it (a really old XPS laptop running Debian 12). In my case, the mouse has a small switch on the bottom that turns the power to the mouse on and off (and if it's off, no amount of moving or clicking will wake up the system). Turn the switch back on, and any movement wakes the machine. The mouse is a "Logi" model M650 L. It uses a single replaceable AA battery (not rechargable by the way).

Hope this helps

Dan (aka Lurchicus)

will41 04-07-2024 09:40 AM

Yes. That does work as long as I remember to switch off the mouse before closing the lid. The command in post #1 works just fine until a reboot then it has to be run again. I'm wondering how to put that command into the list of "startup application" in the "menu" "system settings" (cinnamon desktop). Thanks.

rokytnji 04-07-2024 05:55 PM

Don't run Mint and not sure if this is what you want

video link

will41 04-08-2024 06:28 PM

Thanks. I'll check those out.
The first thing I notice is that the video references Linux Mint. Also, this video shows only how to add an existing application to the startup menu in Linux Mint (I'm using Fedora) but it appears to work the same in this case.
However my issue is, I think, that I need to add a custom command as su (not sudo). I ran across an old comment that said clicking on Startup Applications > + > Choose Application > Add Application the system will show every application available. So, if I add an executable file somewhere will it show up and be selectable here? That seems easy enough. However, I'm not sure how to deal with the fact that I need to be su to run the command. Also, where should the executable file be stored?

Maybe there is a better way to do it?

I searched the other 5 suggestions that rokytnji offered and found nothing that appears pertinent.

will41 04-11-2024 02:13 PM

I've found statements indicating that it is easy to add the command into the /etc/rc.local file which will run it at startup. These are the instructions I found:

Running a program automatically on Linux startup via rc.local

rc.local is a legacy script from the System V init system, executed before displaying a login screen for the desktop environment or terminal login prompt. It is typically a Bash shell script capable of running any commands.

To configure your rc.local script, follow these steps:

As the root user, open or create the /etc/rc.local file using your preferred editor if it doesn't exist.


Code:

$ sudo vi /etc/rc.local

    Add placeholder code to the file.

    #!/bin/bash

    exit 0

It must start with interpreter (/bin/bash) and ends with an exit code (0 is for success)
Insert commands and logic as needed.


Code:

#!/bin/bash

    /sbin/ip addr | grep inet\ | tail -n1 | awk '{ print $2 }' > /etc/issue
    echo "" >> /etc/issue

    exit 0

Set the file to executable.

Code:

$ sudo chmod a+x /etc/rc.local
The file will be executed as the root user during system boot

Here is the resulting rc.local file:

Code:

#!/bin/bash
echo "XHC" > /proc/acpi/wakeup
exit 0

I was logged in as su when creating the file and it is set to be executable. However, it does not work. Any suggestions?


All times are GMT -5. The time now is 04:57 AM.