I want to run this command as root on login:
systemctl mask --now sleep.target suspend.target hibernate.target hybrid-sleep.target
I had some problems with the laptop randomly logging out, every 1 - 2 minutes before I applied this script. (This question is not asking to solve this problem)
I can make a code that allows me to unmask these on demand, and then logout, allowing me to save battery.
I have attempted, as the answer here told me to, to have it run via editing the ~/.profile file, but it then showed a black screen after login, and I had to revert that change in recovery mode before it allowed me to login again.
I just naively added the code like this, to the end of the file:
~/.profile:
...
if [ -d "$HOME/.local/bin" ] ; then
PATH="$HOME/.local/bin:$PATH"
fi
systemctl mask --now sleep.target suspend.target hibernate.target hybrid-sleep.target
Is there another way I can run this script on login? Or did I do something wrong and how can I do it right?
It is a Samsung Galaxy Book 2, with Windows dual boot, Ubuntu 20.04 with the latest kernel(6.1.9) installed.
Previously, I used Linux Mint on an older Samsung machine, and it ran flawlessly.