On 2024-02-13 23:34, -pj via openSUSE Users wrote:
On 02-13-2024 05:59AM, Carlos E. R. wrote:
On 2024-02-13 00:13, -pj via openSUSE Users wrote:
...
you can create your own systemd service to do things. Mine (calls a script):
Telcontar:~ # cat /etc/systemd/system/helloworld.service [Unit] Description=Plays a welcome sound when target multi-user is reached After=multi-user.target # graphical.target - multi-user.target
[Service] Type=oneshot RemainAfterExit=true StandardOutput=tty ExecStart=-/root/ThingsNeededForBoot/helloworld
[Install] WantedBy=multi-user.target WantedBy=graphical.target Telcontar:~ #
Hi, thanks for this information. I believe I have been able to create a working systemd service that persists (after powercycle), on this machine to allow the HP PS/2 Keyboard to power off, when suspend is envoked. The following is what I have done:
I reviewed this article: https://www.suse.com/support/kb/doc/?id=000019672
Do you think the Type=simple (in article above) is adequate for this keyboard situation?
Do you think the Type=oneshot is better for this situation?
I don't know, I am not an expert on this :-)
Why is # graphical.target - multi-user.target not active in your example?
That is just a comment. I could use: After=multi-user.target or After=graphical.target I decided that multi-user.target was better for my purpose, it would work both on runlevels 3 or 5.
I then looked at your example provided above. I decided to implement your example above. Shown below is what I have done. >:| --------------------------------------------------------------------- Thinkcentre-M57p:/etc/systemd/system> ls -lah -rwxr-xr-x 1 root root 312 Feb 13 15:15 HP-PS2-Keyboard.service --------------------------------------------------------------------- Thinkcentre-M57p:/etc/systemd/system> locate HP-PS2-Keyboard.service /etc/systemd/system/HP-PS2-Keyboard.service /etc/systemd/system/graphical.target.wants/HP-PS2-Keyboard.service /etc/systemd/system/multi-user.target.wants/HP-PS2-Keyboard.service -------------------------------------------------------------------- Thinkcentre-M57p:/etc/systemd/system> cat HP-PS2-Keyboard.service [Unit] Description=Disable PS/2 style keyboard power when sleep state is envoked on this machine After=multi-user.target # graphical.target - multi-user.target
[Service] Type=oneshot RemainAfterExit=true StandardOutput=tty ExecStart=-/usr/sbin/HP-PS2-Keyboard.sh
[Install] WantedBy=multi-user.target WantedBy=graphical.target ----------------------------------------------------------------------
One comment. Better place your script in /usr/local/sbin/, that's the standard place for scripts done by the administrator of the machine. /usr/sbin is used by the distribution, and when upgrading/migrating the machine it is easier to just backup and copy the entire /usr/local/ structure.
Thinkcentre-M57p:/usr/sbin> locate HP-PS2-Keyboard.sh /usr/sbin/HP-PS2-Keyboard.sh ------------------------------------------------------------------------ Thinkcentre-M57p:/usr/sbin> ls -lah -rwxr-xr-x 1 root root 93 Feb 13 15:28 HP-PS2-Keyboard.sh <- Should this script file have to have a .sh extension? The other files in /usr/sbin do not have .sh extensions shown.
It is irrelevant, whatever you are happy with. If you always set the extension, it makes easier for you to locate scripts.
------------------------------------------------------------------------ Thinkcentre-M57p:/usr/sbin> cat HP-PS2-Keyboard.sh #!/bin/bash echo KBC0 >/proc/acpi/wakeup echo "the script works" >> /tmp/HP-PS2-Keyboard.txt
Trick: logger -t Mine -p local1.info "The script works." (local "one") Or logger -t Mine -p local1.info "Disabling wakeup in PS2 keyboard" and you will see that line printed in "journalctl" output.
----------------------------------------------------------------------- Thinkcentre-M57p:/tmp> ls -lah -rw-r--r-- 1 root root 17 Feb 13 15:41 HP-PS2-Keyboard.txt ----------------------------------------------------------------- Thinkcentre-M57p:/tmp> cat HP-PS2-Keyboard.txt the script works ----------------------------------------------------------
-- Cheers / Saludos, Carlos E. R. (from 15.5 x86_64 at Telcontar)