Page 1 of 1

[Tutorial] Kite's Circuit board RetroPie menu item for the battery indicator

Posted: Fri Mar 15, 2019 11:28 am
by diko_d
In addition to the previous tutorial focusing on Kite's update script for his boards (viewtopic.php?f=51&t=7613), I am adding this tutorial for a menu item to turn ON/OFF the battery indicator. One major benefit with this menu item, it does not require a reboot of the device as indicated in Kite's wiki pages. This tutorial is also compatible with all the Circuit boards without the need to modify the script!
IMG_3638.jpeg
IMG_3638.jpeg (2.44 MiB) Viewed 3407 times
Here is a quick link to download a short video to see how it operates:
battery-indicator.mov
(4.98 MiB) Downloaded 316 times
You two options for installation:
- You can run the automated install using info in this repo: https://github.com/dikodahan/cs-hud-shortcuts. This will take care of everything listed below and you do not need to continue with this tutorial.
- You can follow the manual process listed here if you wish so.

You will need to SSH into your Circuit Gem/Sword to get this set up once. In my specific example, this is a Circuit Gem, but aside from some minor variations I will note below, the process is the same.
  1. First off, you will need to copy this image file here to your PC. Make sure it is saved as battery.png
    battery.png
    battery.png (101.18 KiB) Viewed 3421 times
  2. SSH to your Kite board.
  3. Go into the retromenu directory. Any sh file in this directory will automatically show up in RetroPie configuration menu.

    Code: Select all

    cd RetroPie/retropiemenu/
  4. Create a new shell script file to launch the script.

    Code: Select all

    nano battery.sh
  5. Paste the following lines in the file.

    Code: Select all

    #! /bin/sh
    
    sudo systemctl stop cs-hud.service
    
    if [[ -d "${HOME}/Circuit-Gem" ]]; then
      if grep -q "ExecStart=/home/pi/Circuit-Gem/cs-hud/cs-hud -s" "/lib/systemd/system/cs-hud.service"; then
        sudo sed -i 's/ExecStart=\/home\/pi\/Circuit-Gem\/cs-hud\/cs-hud -s/ExecStart=\/home\/pi\/Circuit-Gem\/cs-hud\/cs-hud/g' /lib/systemd/system/cs-hud.service
      else
        sudo sed -i 's/ExecStart=\/home\/pi\/Circuit-Gem\/cs-hud\/cs-hud/ExecStart=\/home\/pi\/Circuit-Gem\/cs-hud\/cs-hud -s/g' /lib/systemd/system/cs-hud.service
      fi
    elif [[ -d "${HOME}/Circuit-Sword" ]]; then
      if grep -q "ExecStart=/home/pi/Circuit-Sword/cs-hud/cs-hud -s" "/lib/systemd/system/cs-hud.service"; then
        sudo sed -i 's/ExecStart=\/home\/pi\/Circuit-Sword\/cs-hud\/cs-hud -s/ExecStart=\/home\/pi\/Circuit-Sword\/cs-hud\/cs-hud/g' /lib/systemd/system/cs-hud.service
      else
        sudo sed -i 's/ExecStart=\/home\/pi\/Circuit-Sword\/cs-hud\/cs-hud/ExecStart=\/home\/pi\/Circuit-Sword\/cs-hud\/cs-hud -s/g' /lib/systemd/system/cs-hud.service
      fi
    elif [[ -d "${HOME}/Circuit-Sword-Lite" ]]; then
      if grep -q "ExecStart=/home/pi/Circuit-Sword-Lite/cs-hud/cs-hud -s" "/lib/systemd/system/cs-hud.service"; then
        sudo sed -i 's/ExecStart=\/home\/pi\/Circuit-Sword-Lite\/cs-hud\/cs-hud -s/ExecStart=\/home\/pi\/Circuit-Sword-Lite\/cs-hud\/cs-hud/g' /lib/systemd/system/cs-hud.service
      else
        sudo sed -i 's/ExecStart=\/home\/pi\/Circuit-Sword-Lite\/cs-hud\/cs-hud/ExecStart=\/home\/pi\/Circuit-Sword-Lite\/cs-hud\/cs-hud -s/g' /lib/systemd/system/cs-hud.service
      fi
    else
      echo "It seems like Kite's CS-HUD software is not installed on your device :("
      echo "Please follow Kite's guides and images to make sure it is installed: https://github.com/kiteretro"
      sleep 10s
    fi
    
    sudo systemctl daemon-reload
    sudo systemctl start cs-hud.service
  6. To save the file press Ctrl+x, Then y and then press Enter.
  7. Make the shell script executable:

    Code: Select all

    chmod +x battery.sh
  8. Now we need to update the RetroPie configuration menu to add this item properly.

    Code: Select all

    sudo nano /opt/retropie/configs/all/emulationstation/gamelists/retropie/gamelist.xml
  9. Scroll all the way down to the end of the file and just above the last line </gameList> add the following lines.

    Code: Select all

    <game>
    	<path>./battery.sh</path>
    	<name>Battery Indicator</name>
    	<desc>Turns ON and OFF the battery indicator in Kite's HUD software.</desc>
    	<image>./icons/battery.png</image>
    </game>
  10. To save the file press Ctrl+x, Then y and then press Enter.
  11. Close the SSH connection.
  12. Now you need to copy the battery.png file over to the following directory on your Circuit board: /home/pi/RetroPie/retropiemenu/icons
    I will not cover how to copy a file over to RetroPie from a PC or a Mac in this tutorial. You can easily google this part.
  13. From your HUD software perform a proper shutdown and turn your hand-held back on. You now have the battery indicator toggle easily accessible from RetroPie menu!!!

Re: [Tutorial] Kite's Circuit board RetroPie menu item for the battery indicator

Posted: Wed Apr 03, 2019 1:03 pm
by pbutters
Very cool idea and great tutorial to getting it working.

Idea/suggestion: Would it be possible to integrate this feature into the "mode" button found on the circuit sword? I have the circuit sword lite and being able to quickly turn off/on wifi and the virtual keyboard I find to be a super neat feature. Adding this battery display toggle would make a great addition.

Posted: Thu Apr 04, 2019 4:28 am
by kite
pbutters wrote:
Wed Apr 03, 2019 1:03 pm
Very cool idea and great tutorial to getting it working.

Idea/suggestion: Would it be possible to integrate this feature into the "mode" button found on the circuit sword? I have the circuit sword lite and being able to quickly turn off/on wifi and the virtual keyboard I find to be a super neat feature. Adding this battery display toggle would make a great addition.
Add a request here: https://github.com/kiteretro/Circuit-Sword-Lite/issues