windows android

Notifying Windows 10 PC When Android Smartphone Battery Is Low

I'll introduce a program that notifies a Windows 10 PC when an Android smartphone battery is low. It sends an audio notification on the PC when the Android battery reaches 15%...

Shou Arisaka
5 min read
Oct 9, 2025

I’ll introduce a program that notifies a Windows 10 PC when an Android smartphone battery is low.

I wrote this because it seemed like there might be demand for it.

It sends an audio notification on the PC when the Android battery reaches 15%.

Overall Flow

Each individual task isn’t difficult, but as usual there are many technologies used, so it may take time depending on the situation, but if you can do this, you can apply it to other Android data exchanges, so please give it a try.

  1. When Android battery gets low, make a web request with IFTTT
  2. Receive it with an Ubuntu Sinatra server and write any command to a file
  3. Execute the file text as a command. (popup notification; tts; etc)
## Preparation
  • Get a WiFi router that can do port forwarding.
By port forwarding, you request to a locally running server from a public URL with a global IP, so if you don't have such a router, buy one. Fortunately, which router to buy is clear.

The Best WiFi Router Derived from Testing 4 Routers After Optical Line Construction

WSL

Let’s create a Ruby environment

We’ll run Sinatra with Ruby. It can be done in 3 minutes, so let’s quickly set up the environment.

sudo apt update ; sudo apt install build-essential patch zlib1g-dev liblzma-dev ruby{,-dev} -y ; sudo gem install bundler

mkdir -p /mnt/c/pg/ruby_dev && cd $_

sudo bundle init
vim Gemfile
sudo bundle install

vim Gemfile

# add
gem "pry"
gem "sinatra"

Procedure

  • Set up port forwarding on your WiFi router
![Image](/images/blog/sharex_screenshot_056219d2-d4f2-4e9d-89a5-0c6ec5a9_d06f31e9.png)
  • Create an applet in IFTTT
[Make an Applet - IFTTT](https://ifttt.com/create)
this ... android battely
that ... webhooks

title(example) ... If Battery drops below 15%, then get request to server
URL(example) ... http://220.247.111.111:8005/android-battely
method ... get
type ... json
body ... (blank)
  • Set up IFTTT on the Android side
If you haven't already, install the IFTTT app on Android and enable the applet.

IFTTT - Apps on Google Play

  • Mount a Windows folder to enable file synchronization
sudo mount -t  cifs //192.168.0.167/_sync_ ~/share -o user=user,pass=pass,dir_mode=0777,file_mode=0777

We’ll implement later: storing text to execute as commands in command.txt in the share directory, and periodically reading and executing it with WSL. This is because even if you execute commands directly on the server, sound-related processes won’t work because the process is a subprocess(?), so you need to go through a file.

  • Run Sinatra
dev.rb ```rb require "sinatra" require "open3" require 'json' require 'pry'

Encoding.default_external = ‘UTF-8’

get “/android-battely” do

# binding.pry

stdout, stderr, statusCode = Open3.capture3( %( bash -c " host #{request.ip} | awk '{print $5}' | awk '/amazonaws.com|ifttt.com/' || echo '' " ) )
if stdout.to_s.strip.empty? then redirect to('/404') end

# puts "ok"
puts @body = request.body.read

    stdout, stderr, statusCode = Open3.capture3( %( bash -ic "printf 'tts \\"android battery low\\"' > /home/yuis/share/command.txt || echo '' " ) )

puts stdout, stderr, statusCode

end

```bash
sudo bundle exec ruby dev.rb -o 0.0.0.0

Image

Simple explanation …

stdout, stderr, statusCode = Open3.capture3( %( bash -c " host #{request.ip} | awk '{print $5}' | awk '/amazonaws.com|ifttt.com/' || echo '' " ) )
if stdout.to_s.strip.empty? then redirect to('/404') end

When you publish a server, you get quite a bit of malicious access from hackers. If you leave this alone, at worst your PC could be hacked or broken, or in this example at least you’ll get notifications all day.

So, to filter such things, with Sinatra it’s troublesome, but it seems good to redirect to a 404 page. We’ll block all access that’s not from IFTTT. Since IFTTT is AWS, we’ll only allow that.

Even with this, AWS is quite wide-ranging, so you might still get strange access. In that case, you can add parameters to the GET request on the IFTTT side as a token and authenticate on the server side for certainty.

printf 'tts \\"android battery low\\"'

You need to escape in two stages, Ruby and Bash, so use two backslashes.

  • Define the function to use on the WSL side
This time I'm using tts. This reads text aloud via PowerShell by doing tts text.

TTS (text-to-speech) with PowerShell

Execute the following in bash or put it in .bashrc.

tts ()
{
    /mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/powershell.exe -  <<EOF
tts "${1}"
EOF

}
  • Run a script on the WSL side that periodically monitors the file containing command text
Execute the following script in ConEmu or similar and leave it running. ```bash while true; do

echo -ne ”$(isodate)\tNothing updated on the clipboard.\033[0K\r”

[[ -s “$SHAREDDIR/command.txt” ]] && { eval ”$(cat “$SHAREDDIR/command.txt”)” ; > “$SHAREDDIR/command.txt” ; printf “A command excuted.” ; }

sleep 2s done

![Image](/images/blog/sharex_screenshot_7ad36b6d-d722-46e0-9227-6ad333b3_06541327.png)
<ul>
 	<li>Test if it actually works</li>
</ul>
Please comment if you have any problems.

Share this article

Shou Arisaka Oct 9, 2025

🔗 Copy Links