# Audible or Visual warning if the batttery is about to give out

**URL:** <https://forum.clockworkpi.com/t/audible-or-visual-warning-if-the-batttery-is-about-to-give-out/1757>\
**Category:** GameShell\
**Tags:** feedback, battery\
**Created:** [September 28, 2018, 3:56pm UTC](https://forum.clockworkpi.com/t/audible-or-visual-warning-if-the-batttery-is-about-to-give-out/1757 "2018-09-28T15:56:05Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![develroo](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/develroo/32/1266_2.png) [@develroo](https://forum.clockworkpi.com/u/develroo)\
**Post date:** [September 28, 2018, 3:56pm UTC](https://forum.clockworkpi.com/t/audible-or-visual-warning-if-the-batttery-is-about-to-give-out/1757/1 "2018-09-28T15:56:05Z")

</div>

Hey guys,

Having great fun playing with the gameshell however just got a little miffed when I just completed a boss fight and was about to save when the battery gave out. Arrrg

So is there a chance that there can be some sort of audible warning or a quick flash on screen when the battery is say 10% or 5% and needs charging sooner not later?

Would certainly cut down on frustration , trust me. 🙂

Thanks for such a compelling product.

PS. I did post this as a git issue first cause I completely forgot about the forum. Doh! my bad… and I can remove it from git if you want.

---

<div class="post-metadata">

**Author:** ![YoshiK1](https://avatars.discourse-cdn.com/v4/letter/y/919ad9/32.png) [@YoshiK1](https://forum.clockworkpi.com/u/YoshiK1)\
**Post date:** [September 28, 2018, 4:58pm UTC](https://forum.clockworkpi.com/t/audible-or-visual-warning-if-the-batttery-is-about-to-give-out/1757/2 "2018-09-28T16:58:32Z")

</div>

There’s a thread on here for some Git code to display a battery indicator. You could put this kind of update into that thread. For me I don’t think it’ll work as I use the battery indicator but the console just turned off at a fairly high percentage. The first time it turned off about 19%. It’s likely my battery needing charged more as I never gave it a long charge but still have a look for the thread and that might help.

---

<div class="post-metadata">

**Author:** ![Petrakis](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/petrakis/32/256_2.png) [@Petrakis](https://forum.clockworkpi.com/u/Petrakis)\
**Post date:** [September 28, 2018, 5:53pm UTC](https://forum.clockworkpi.com/t/audible-or-visual-warning-if-the-batttery-is-about-to-give-out/1757/3 "2018-09-28T17:53:56Z")

</div>

You could try this: [[APP] Battery status on emulators](https://forum.clockworkpi.com/t/app-battery-status-on-emulators/1272)

---

<div class="post-metadata">

**Author:** ![develroo](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/develroo/32/1266_2.png) [@develroo](https://forum.clockworkpi.com/u/develroo)\
**Post date:** [October 1, 2018, 4:33pm UTC](https://forum.clockworkpi.com/t/audible-or-visual-warning-if-the-batttery-is-about-to-give-out/1757/4 "2018-10-01T16:33:08Z")

</div>

Perfect. That should be installed and run by default I think and toggled off if you want to.

---

<div class="post-metadata">

**Author:** ![Petrakis](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/petrakis/32/256_2.png) [@Petrakis](https://forum.clockworkpi.com/u/Petrakis)\
**Post date:** [October 1, 2018, 8:49pm UTC](https://forum.clockworkpi.com/t/audible-or-visual-warning-if-the-batttery-is-about-to-give-out/1757/5 "2018-10-01T20:49:00Z")

</div>

On the new version you can toggle it on and off but I haven´t released that version

Edit:2019-10-19T22:00:00Z [BatMon - Battery Status on emulators for Clockwork OS v0.3](https://forum.clockworkpi.com/t/batmon-battery-status-on-emulators-for-clockwork-os-v0-3/3461)

---

<div class="post-metadata">

**Author:** ![develroo](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/develroo/32/1266_2.png) [@develroo](https://forum.clockworkpi.com/u/develroo)\
**Post date:** [October 1, 2018, 10:30pm UTC](https://forum.clockworkpi.com/t/audible-or-visual-warning-if-the-batttery-is-about-to-give-out/1757/6 "2018-10-01T22:30:19Z")

</div>

Good to know. Really helps to see the battery level when I start a game, you’d be surprised how quickly you forget you are playing.

Cheers,

---

<div class="post-metadata">

**Author:** ![Petrakis](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/petrakis/32/256_2.png) [@Petrakis](https://forum.clockworkpi.com/u/Petrakis)\
**Post date:** [October 1, 2018, 10:42pm UTC](https://forum.clockworkpi.com/t/audible-or-visual-warning-if-the-batttery-is-about-to-give-out/1757/7 "2018-10-01T22:42:43Z")

</div>

Yeah, and your question why isnt by default installed is because its not an app from clockwork, they were trying their own option I think, on update 1.22 but something went wrong and they reverted that update

---

<div class="post-metadata">

**Author:** ![guu](https://avatars.discourse-cdn.com/v4/letter/g/7ab992/32.png) [@guu](https://forum.clockworkpi.com/u/guu)\
**Post date:** [October 9, 2018, 5:03am UTC](https://forum.clockworkpi.com/t/audible-or-visual-warning-if-the-batttery-is-about-to-give-out/1757/8 "2018-10-09T05:03:08Z")

</div>

In launcher after 1.22  
we switch TWM to Awesome for global notification window and prevent focus-stealing and maybe other features

**This is an introduction to the pre-trial. if you are not good at linux console**  
**Later, there will be an official release.**  
**So do it on your own risk**

😉

Manually, you need ssh into gameshell

make sure you have launcher \>= 1.21 running with bluetooth support(sudo apt-get install bluez bluetooth)

> **[Home](https://github.com/clockworkpi/bluetooth/wiki)**
>
> CPI Bluetooth driver, kernel and configuration. Contribute to clockworkpi/bluetooth development by creating an account on GitHub.

# Upgrade launcher

currently there is no release hash for launcher ,so you just need to

> cd /home/cpi/apps/launcher  
> git pull

**then move launcher out of `/home/cpi/apps/` to `/home/cpi/`**

The launcher will become more independent so that we can backup the user data easier in the future

> mkdir /home/cpi/apps/Menu

Create a folder named `Menu` , this folder is for games/apps

We can put our games/apps, which was previously needed to place in the `/home/cpi/apps/launcher/Menu/GameShell` , into this directory (not belong to launcher`s)

and the games/apps folder is the all-in-one style  
the icon ,the startup script, and others be in one simple folder, no need to put icon and script apart like before(  
scripts in `/home/cpi/apps/launcher/Menu/GameShell` and icons in `/home/cpi/apps/launcher/skin/default/Menu/GameShell/`)

games/apps folder examples:

> **[GitHub - cuu/Pcsx: pcsx rearmed for GameShell](https://github.com/cuu/Pcsx)**
>
> pcsx rearmed for GameShell

> **[GitHub - cuu/Calculator: Calculator made by love2d for GameShell](https://github.com/cuu/Calculator)**
>
> Calculator made by love2d for GameShell

> **[GitHub - cuu/NyanCat: NyanCat for GameShell](https://github.com/cuu/NyanCat)**
>
> NyanCat for GameShell

> **[GitHub - cuu/Mr.Boom: Bomberman for GameShell](https://github.com/cuu/Mr.Boom)**
>
> Bomberman for GameShell

All of the above examples come from the forum players, thank you all, I just borrowed , I hope you wouldn’t mind

🙂

Then change the bottom of `/home/cpi/.bashrc` to point X to use new **.xinitrc** inside launcher

```
if [-f /tmp/autologin]
then
        rm -f /tmp/autologin
        mpd ~/.mpd.conf **startx /home/cpi/launcher/.xinitrc -- -nocursor \> /dev/null 2\>&1** fi
```

### .xinitrc

```auto
feh --bg-center ~/launcher/sys.py/gameshell/wallpaper/loading.png 
exec ~/launcher/load.sh &
exec ~/launcher/sys.py/gsnotify/gsnotify-arm &
exec awesome -c ~/launcher/awesome/rc.lua

```

Here is , new `.xinitrc` invoked a small widget called `gsnotify`

[gsnotify](https://github.com/cuu/gsnotify)

Though the readme of gsnotify ,there are 3 examples  
one of them is the battery notify script

```auto
#!/bin/bash

BAT_PNT=`upower -i $(upower -e | grep 'battery') | grep -E "state|to\ full|percentage" | awk '/perc/{print $2}' | cut -d % -f1 `

if ["$BAT_PNT" -lt "20"]; then
	if ["$BAT_PNT" -lt "15"]; then
			echo '{"type":"once","content":"Power<15%"}'
	fi

	if ["$BAT_PNT" -lt "10"]; then
		echo "keydown" | socat - UNIX-CONNECT:/tmp/gameshell
		echo '{"type":"repeat","content":"Power<10%,will poweroff soon"}'
	fi

	echo "keydown" | socat - UNIX-CONNECT:/tmp/gameshell
	echo '{"type":"once","content":"Power<20%"}'

else
	echo $BAT_PNT
fi

```

the script use **upower** to check the battery ,get percent  
and use **socat** to communicate launcher’s unix socket under `/tmp/` to light the screen if the screen is in dark  
and of cause ,print the message to gsnotify to show up

you can put the script into `/home/cpi/launcher/sys.py/gsnotify/Jobs` now

The [gsnotify](https://github.com/cuu/gsnotify) will do a round-robin check every 30s for the scripts under `/home/cpi/launcher/sys.py/gsnotify/Jobs` directory in simple json return formatted and  
show a small window that slides down from the top, reminding the battery that it is nearly exhausted, etc.  
and freely configurable

# Install awesome and upower

```auto
sudo apt-get install awesome socat upower

--reboot--

```

## Fix RetroArch issue

Even All is done ,you will not see any notifications while retroarch is running,because  
the retroarch in GS ,is kind a wild window for X11 currently now  
so change config to fix this issue by two lines:

in top of `/home/cpi/.config/retroarch/retroarch.cfg`

```auto
video_fullscreen = "false"
...
video_windowed_fullscreen = "true"

```

_–reboot–_

# Options

## upgrade to debian buster to get newer software

in `/etc/apt/source.list`  
change all source to **buster**  
then upgrade the debian system

```auto
sudo apt-get update
sudo apt-get upgrade

sudo apt-get install awesome socat upower

--reboot--

```

#### At end:

In the new launcher , we use Awesome to deal on-top windows ,even the [battery monitor widget](https://forum.clockworkpi.com/t/app-battery-status-on-emulators/1272) can work better , no need to kill and re-launch it time by time

I apologize for my bad English. If you have any accidents during the actual operation or do not understand my explanation, please let me know, let’s do more tests together.

---

<div class="post-metadata">

**Author:** ![Petrakis](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/petrakis/32/256_2.png) [@Petrakis](https://forum.clockworkpi.com/u/Petrakis)\
**Post date:** [October 9, 2018, 7:20am UTC](https://forum.clockworkpi.com/t/audible-or-visual-warning-if-the-batttery-is-about-to-give-out/1757/9 "2018-10-09T07:20:03Z")

</div>

> [@guu](#):
>
> #### At end:
> 
> In the new launcher , we use Awesome to deal on-top windows ,even the [battery monitor widget](https://forum.clockworkpi.com/t/app-battery-status-on-emulators/1272) can work better , no need to kill and re-launch it time by time
> 
> I apologize for my bad English. If you have any accidents during the actual operation or do not understand my explanation, please let me know, let’s do more tests together.

Currently the limitations of the battery widget come from the twm limitations, cant wait for awesome 😃

> no need to kill and re-launch it time by time

In a version that I haven´t released yet, I dealt with that but lost transparency. It has a solid background.

Edit: Released [BatMon - Battery Status on emulators](https://forum.clockworkpi.com/t/batmon-battery-status-on-emulators-for-clockwork-os-v0-3/3461)

---

<div class="post-metadata">

**Author:** ![guu](https://avatars.discourse-cdn.com/v4/letter/g/7ab992/32.png) [@guu](https://forum.clockworkpi.com/u/guu)\
**Post date:** [October 10, 2018, 5:13am UTC](https://forum.clockworkpi.com/t/audible-or-visual-warning-if-the-batttery-is-about-to-give-out/1757/10 "2018-10-10T05:13:53Z")

</div>

Glad to hear that you like it

you can try awesome , the new launcher now

🙂

---

<div class="post-metadata">

**Author:** ![lasvegas](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/lasvegas/32/769_2.png) [@lasvegas](https://forum.clockworkpi.com/u/lasvegas)\
**Post date:** [October 10, 2018, 6:23am UTC](https://forum.clockworkpi.com/t/audible-or-visual-warning-if-the-batttery-is-about-to-give-out/1757/11 "2018-10-10T06:23:16Z")

</div>

> [@guu](#):
>
> in `/etc/apt/source.list`  
> change all source to **buster**  
> then upgrade the debian system

I tried following the step by step until I got to the above instruction. I could not figure out what had to change to **buster**. So I carefully backtracked and returned everything to it’s previous state. Thank goodness I’m good at that! Back to normal…

---

<div class="post-metadata">

**Author:** ![guu](https://avatars.discourse-cdn.com/v4/letter/g/7ab992/32.png) [@guu](https://forum.clockworkpi.com/u/guu)\
**Post date:** [October 10, 2018, 7:06am UTC](https://forum.clockworkpi.com/t/audible-or-visual-warning-if-the-batttery-is-about-to-give-out/1757/12 "2018-10-10T07:06:55Z")

</div>

yeah,that seems a risk

Though it’s ok to upgrade to buster, I’ve tested already

I found out that debian buster has python 3.6.5+,which is a requirement for  
[http://arcade.academy/](http://arcade.academy/)

but Even not with buster, all steps and the launcher should works ,too

Change above instruction now, thanks @lasvegas

---

<div class="post-metadata">

**Author:** ![lasvegas](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/lasvegas/32/769_2.png) [@lasvegas](https://forum.clockworkpi.com/u/lasvegas)\
**Post date:** [October 10, 2018, 2:36pm UTC](https://forum.clockworkpi.com/t/audible-or-visual-warning-if-the-batttery-is-about-to-give-out/1757/13 "2018-10-10T14:36:10Z")

</div>

What do we change to **buster** in source.list? This is what I couldn’t figure out.

---

<div class="post-metadata">

**Author:** ![nouty](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/nouty/32/4255_2.png) [@nouty](https://forum.clockworkpi.com/u/nouty)\
**Post date:** [October 10, 2018, 9:12pm UTC](https://forum.clockworkpi.com/t/audible-or-visual-warning-if-the-batttery-is-about-to-give-out/1757/14 "2018-10-10T21:12:34Z")

</div>

I’m stuck at the loading screen. ☹

Have done all the recent steps, added the line to .bashrc, checked .xinitrc (looks like your’s, upgraded my system like you told and moved the launcher.

Have any idea how to figure out what’s going wrong?

---

<div class="post-metadata">

**Author:** ![guu](https://avatars.discourse-cdn.com/v4/letter/g/7ab992/32.png) [@guu](https://forum.clockworkpi.com/u/guu)\
**Post date:** [October 11, 2018, 6:09am UTC](https://forum.clockworkpi.com/t/audible-or-visual-warning-if-the-batttery-is-about-to-give-out/1757/15 "2018-10-11T06:09:18Z")

</div>

you can still ssh into gs right now,right?

if you can see the **loading screen** , means X is up ,that’s a good news

the lines in .bashrc should be replaced ,not add

and you can test the launcher by ssh if the launcher did not up,find out the reason

```auto
cpi@clockworkpi:~$ cd /home/cpi/launcher  
cpi@clockworkpi:~$ DISPLAY=:0 ./load.sh

```

---

<div class="post-metadata">

**Author:** ![nouty](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/nouty/32/4255_2.png) [@nouty](https://forum.clockworkpi.com/u/nouty)\
**Post date:** [October 11, 2018, 9:35pm UTC](https://forum.clockworkpi.com/t/audible-or-visual-warning-if-the-batttery-is-about-to-give-out/1757/16 "2018-10-11T21:35:02Z")

</div>

Yes, that’s no problem. If I run your command, it says:

```
cpi@clockworkpi:~$ cd /home/cpi/launcher
cpi@clockworkpi:~/launcher$ DISPLAY=:0 ./load.sh
Traceback (most recent call last):
  File "run.py", line 526, in <module>
setup_dbus()
  File "/home/cpi/launcher/sys.py/libs/DBUS/ __init__.py", line 49, in setup_dbus
proxy_obj = bus.get_object("org.bluez", "/")
  File "/usr/lib/python2.7/dist-packages/dbus/bus.py", line 241, in get_object
follow_name_owner_changes=follow_name_owner_changes)
  File "/usr/lib/python2.7/dist-packages/dbus/proxies.py", line 248, in __init__
self._named_service = conn.activate_name_owner(bus_name)
  File "/usr/lib/python2.7/dist-packages/dbus/bus.py", line 180, in activate_name_owner
self.start_service_by_name(bus_name)
  File "/usr/lib/python2.7/dist-packages/dbus/bus.py", line 278, in start_service_by_name
'su', (bus_name, flags)))
  File "/usr/lib/python2.7/dist-packages/dbus/connection.py", line 651, in call_blocking
message, timeout)
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.ServiceUnknown: The name org.bluez was not provided by any .service files
```

---

<div class="post-metadata">

**Author:** ![guu](https://avatars.discourse-cdn.com/v4/letter/g/7ab992/32.png) [@guu](https://forum.clockworkpi.com/u/guu)\
**Post date:** [October 12, 2018, 2:58am UTC](https://forum.clockworkpi.com/t/audible-or-visual-warning-if-the-batttery-is-about-to-give-out/1757/17 "2018-10-12T02:58:51Z")

</div>

it seems that there is no bluetooth on your GS

**Sorry for that**  
I forgot to explicitly mention Bluetooth support in above instruction

did u update the kernel to support bluetooth?

anyway

> sudo apt-get install bluez bluetooth

Install bluez to get the launcher up and running

But I suggest see wiki to enable bluetooth

> **[Home](https://github.com/clockworkpi/bluetooth/wiki)**
>
> CPI Bluetooth driver, kernel and configuration. Contribute to clockworkpi/bluetooth development by creating an account on GitHub.

and auto setup bluetooth script:

> [@Bluetooth device on gameshell](https://forum.clockworkpi.com/t/bluetooth-device-on-gameshell/617/13):
>
> sudo su cat \<\<EOF \>/etc/rc.local #!/bin/sh -e sleep 15 brcm\_patchram\_plus --patchram /lib/firmware/brcm/bcm43438a0.hcd --enable\_hci --bd\_addr B0:F1:EC:2D:07:5B --no2bytes --tosleep 5000 /dev/ttyS1 & EOF chmod +x /etc/rc.local systemctl daemon-reload systemctl start rc-local systemctl status rc-local systemctl enable bluetooth reboot use rc.local to auto set bluetooth everytime rebooted add two lines in /etc/systemd/system/dbus-org.bluez.service Restart=always RestartSec=3 under [Service]…

---

<div class="post-metadata">

**Author:** ![nouty](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/nouty/32/4255_2.png) [@nouty](https://forum.clockworkpi.com/u/nouty)\
**Post date:** [October 12, 2018, 6:17am UTC](https://forum.clockworkpi.com/t/audible-or-visual-warning-if-the-batttery-is-about-to-give-out/1757/18 "2018-10-12T06:17:18Z")

</div>

Okay, that’s it. Thansk! Now I’m stuck with updating kernel and ulmage. .\_.

---

<div class="post-metadata">

**Author:** ![guu](https://avatars.discourse-cdn.com/v4/letter/g/7ab992/32.png) [@guu](https://forum.clockworkpi.com/u/guu)\
**Post date:** [October 12, 2018, 9:46am UTC](https://forum.clockworkpi.com/t/audible-or-visual-warning-if-the-batttery-is-about-to-give-out/1757/19 "2018-10-12T09:46:27Z")

</div>

well  
if you don’t know how to update kernel ,you can leave it alone  
just don’t get into bluetooth  
I think the rest will work as same

soon will be an image contains new kernel and etc

---

<div class="post-metadata">

**Author:** ![develroo](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/develroo/32/1266_2.png) [@develroo](https://forum.clockworkpi.com/u/develroo)\
**Post date:** [November 8, 2018, 9:23am UTC](https://forum.clockworkpi.com/t/audible-or-visual-warning-if-the-batttery-is-about-to-give-out/1757/20 "2018-11-08T09:23:21Z")

</div>

Try [here](https://www.debian.org/doc/manuals/debian-faq/ch-uptodate.en.html) The GameShell runs debian.

[Next page](https://forum.clockworkpi.com/t/audible-or-visual-warning-if-the-batttery-is-about-to-give-out/1757.md?page=2)
