KDE has section in System Settings for this. I have no idea about other DE.
In terminal you can do this:
echo 20 > /sys/class/power_supply/BAT0/charge_start_threshold
echo 90 > /sys/class/power_supply/BAT0/charge_stop_threshold
First command enable charging at 20% battery level, second disable charging at 90% battery level.