On 02-13-2024 04:49PM, Carlos E. R. wrote:
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.
Ok
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.
I moved the file. That's good to know. locate PS2-Keyboard.sh /usr/local/sbin/PS2-Keyboard.sh I think it's important to 'updatedb' when/if moving these files and changing their names is that correct? I made an error initially by the naming approach of "HP-PS2-Keyboard" then decided PS2-Keyboard would be a better approach in this situation.
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.
Yes, I see .sh is easier to see in a way than a file without that extension.
------------------------------------------------------------------------ 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")
When you speak of "(local "one")" I do not understand what you are referring to very well. Can you please explain this a bit more perhaps?
Or
logger -t Mine -p local1.info "Disabling wakeup in PS2 keyboard"
Does this below look like the correct way to implement what you suggest in your second 'trick example' directly above? I probably don't need the "echo "the script works" >> /tmp/PS2-Keyboard.txt", it is informative though. - #!/bin/bash echo KBC0 >/proc/acpi/wakeup echo "Disabling wakeup in PS2 keyboard" >> /tmp/PS2-Keyboard.txt logger -t Mine -p local1.info "Disabling wakeup in PS2 keyboard" - It's nice to have this so functional now. Many Thanks
and you will see that line printed in "journalctl" output.