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

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

:wink:

Manually, you need ssh into gameshell

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

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:

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

:slight_smile:

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

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

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

#!/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 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

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

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

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 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.

4 Likes