v17 Add the result of my addon to the home page
#1
First thing first, this is a very basic addon, as well as my first addon ever for kodi.

I've simply cloned the hello world example and changed the addon.py file to this:

import xbmcaddon
import xbmcgui
import subprocess
import urllib
import requests
import json

addon = xbmcaddon.Addon()
addonname = addon.getAddonInfo('name')


def check_location():
send_url = 'http://freegeoip.net/json'
r = requests.get(send_url)
j = json.loads(r.text)
city = j['city']
return "Currently connected from: " + city;

def check_ip():
public_ip = subprocess.check_output(["ifconfig `ip route get 8.8.8.8 | grep 8.8.8.8 | cut -d' ' -f5` | grep \'inet \' | awk -F'[: ]+' '{ print $4 }'"], shell=True);
result = ("Your IP is : %s " % public_ip);
return result;

xbmcgui.Dialog().ok("Check IP and Location", check_ip(), check_location())
This simple script, get the external Ip and the location and prints them in a modal when runs.

What I'd like to do, is to have this results printed on the home page (I am using titan skin if this help in any way) but I have no idea where to start, as google doesn't really help either.

I don't care if I have to create two new menu entries with that as a result, or I have I to change some skin files, but the idea is to keep the IP and the Location always visible on the home page, as I need to check instantly if my VPN drops the connection so that I can reconnect (or at least I know i'm not connected anymore)

I've also posted this on stackoverflow, and the url is here: http://stackoverflow.com/questions/43707...-home-page but I think I might have more possibilities to get an useful response here.


Thanks in advance for any help
Reply
#2
I am not a skinner, nor a skilled coder, but I think I can get you started. Proceed at your own risk! Wink

First, I believe you'll need your add-on to run as a service.

Second, you'll have to modify the Includes.xml file of the Titan skin. Make a backup copy first!

Below code was added at line 616, and adds the local network IP just below the date on the home screen.

Code:
<control type="grouplist">
                <!--Date Grouplist Line 3-->
                <posx>1260</posx>
                <posy>130</posy>
                <width>600</width>
                <height>50</height>
                <align>right</align>
                <itemgap>4</itemgap>
                <orientation>horizontal</orientation>
                <usecontrolcoords>true</usecontrolcoords>
                <visible>!ControlGroup(400).HasFocus()</visible>
                <control type="label">
                    <!--IP-->
                    <width min="0" max="400">auto</width>
                    <height>50</height>
                    <info>Network.IPAddress</info>
                    <font>Reg30</font>
                    <textcolor>$INFO[Skin.String(HeaderTextColor)]</textcolor>
                    <shadowcolor>$INFO[Skin.String(HeaderTextShadowColor)]</shadowcolor>
                </control>
            </control>

Keep in mind I have Titan installed on Gotham here, so the exact line number may be different in newer versions of the skin. You'll need to change the <info> tag to include the info you want to display.

Image
Kodi Nexus on Dell Optiplex 980 Lubuntu 20.04 | Kodi Nexus on HTPC Lubuntu 20.04 | My Add-ons | Legacy Repo | Matrix Repo
Reply
#3
Thank you. I got it now. Thanks again Smile
Reply

Logout Mark Read Team Forum Stats Members Help
Add the result of my addon to the home page0