Was just wondering if there is software or program/app that would switch the power from AC to battery on a ubuntu laptop without having to pull the power cord? Look in google, but only found software to change power modes(high to low). Asking if I could leave power cord attached, but run on battery if I wanted.


This is suitable for people that like to let their laptop batteries discharge automatically and then recharge at a certain percentage.

Hardware component (20 bucks)

First you need an TP-Link HS100 compatible smart plug like this one:

tp-link hs-100 smart plug.png

Software component (Free)

Then you need some free Linux software like tp-link Wi-Fi Smart Plug HS100:

Switch plug on:

hs100.sh on

Switch plug off:

hs100.sh on

Check if plug is on or off:

hs100.sh check

Print plug system status:

hs100.sh status

Blog about developing hs100.sh including full bash script

  • Didn't realize TP had Ubuntu software... +1
    – David
    Oct 26 '19 at 2:06
  • 1
    @David Technically it's Linux so works with all distro's that have a command line interface. Oct 26 '19 at 2:07
  • Ah, gotcha. Good to know
    – David
    Oct 26 '19 at 4:54
  • Seems to be typo with plug off command. Thanks for your answer.
    – crip659
    Oct 26 '19 at 10:24
  • Just a confirmation, this will work out of the box with Ubuntu plus the download, or do we need an android/ios app for setup like for chromecast.
    – crip659
    Oct 26 '19 at 12:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.