Must create a service to run sudo command at start-up?

A simple service is not that hard. And once you know how to create one, you will know how to deal with possible other similar needs.

For example, the service file:

[Unit]
Description=Disable mouse wakeup

[Service]
Type=oneshot
ExecStart=/usr/bin/mouse-wakeup-disable

and the timer file:

[Unit]
Description=Disable mouse wakeup

[Timer]
OnStartupSec=30sec

[Install]
WantedBy=timers.target

and the executable /usr/bin/mouse-wakeup-disable:

#!/bin/bash

Main() {
    local ids=(1-1.2.1   2-1.2.1)   # these depend on your system!
    local id
    local file

    for id in "${ids[@]}" ; do
        file=/sys/bus/usb/devices/$id/power/wakeup
        if [ -r $file ] ; then
            echo "disabled" > $file
        fi
    done
}

Main "$@"

2 Likes