1. You can add a ready-made script to autostart.
Depending on your desktop environment, you have a graphical application.
Or just put script there ~/.config/autostart
There may be differences depending on the graphical environment.
For example on mate I have *.desktop files where is link to script.
But I suppose the *.bash script will also work.
The graphical application just won't be able to see.
Doc if you need:
https://specifications.freedesktop.org/ ... atest.html
2. Depending on your desktop environment, you can probably assign hotkeys in the settings.
Then you can use in bash script (for example) with xdotool. ( " man command " and examples are your friends )
3. Problems with falling asleep often occur because good cooperation hardware with ACPI is needed.
( sometimes there are other problems as well because it is still being developed )
- ACPI is supported by hardware and the kernel.
If you want read
https://www.kernel.org/doc/html/latest/ ... index.html
If you want report to kernel
-
https://korg.docs.kernel.org/bugzilla.html
-
https://bugzilla.kernel.org/describecom ... oduct=ACPI
- If you want disable ACPI read
https://help.ubuntu.com/community/BootOptions
( especially at the very bottom about GRUB and Kernel Options )
Warning: After disabling ACPI, you will not be able to control the functional buttons. ( they won't work )
e.g. to brighten the screen.
Edited
If I write nonsense, please correct me, because I haven't dealt with this topic for a long time.
And I could be wrong.
Edited
It may not be recommended for a beginner user, but maybe you will find something interesting on the websites
-
https://wiki.ubuntu.com/DebuggingKernelSuspend
-
https://wiki.archlinux.org/title/Power_ ... _hibernate