My laptop supports battery conservation mode, so that it only charges up to 60%, which is very handy.
To enable this I need to change the contents of the file from “0” to “1”; which i am doing by “sudo nano” opening the file, changing the contents and then saving.
What I would like to do is create an alias that changes the content of the file. For example, open a terminal and type “halfbattery” and it will then change the contents of the file to “1”. Then when I need a full charge, opening a terminal and typing “fullbattery”, which will in turn change the contents of the file to “0” so that I get a 100% charge.
You need to write 2 files, that will be magically transformed into scripts that do exactly what you want.
Save the following as halfbattery.sh in your home directory.
Then do the same with a file “fullbattery” with level=0. Mind that this overwrites all of the file contents, so if there’s more in that file, you need to add it to the script.
Next, make both scripts executable:
chmod +x ~/*battery.sh
If you’ve done this right, typing the name of either script will write the contents of the script (the part between “”) to the file. I do suggest you start by testing this to a made-up file that doesn’t actually do anything before attempting the real thing. You don’t want to mess up your config unless you know what you’re doing
Your script has a bug. You will just output the string to the console when you run that. You probably meant to do something like (substitute the relevant line):
echo "level=1" > /path/to/file
Sorry, on my phone and it doesn’t like special characters. The double quotes needs to be around what you want to output (literally level=1 in this case). The > says to redirect that output to something, and the /path/to/file names that something as the file in that path.
Something like that?
(Shorter aliases might be easier, like haba and fuba, which look mor pleasing in themselves…)
Then open new terminal/bash session?