Skip to content

Add country flags in IP adresses #488

Closed

Description

@aymnart

Has this issue been covered in the Wiki?

  • I have read the Wiki and my issue is not covered.

Is there an existing issue reported already?

  • I have searched the existing issues, it does not exist.

Describe the new feature you would like

it would be so mush better if you add country flags instead of an icon when displaying the ip address of the machine this help users know their ip address especially helpful when using proxy or vpn

Activity

  1. azadevlab commented on Feb 25, 2026

    @azadevlab

    @aymnart hi, is it still actual?
    before implementing let's check via dirty hack - is it comfortable with flags?
    if yes, then can share PR with implementing emoji_* type, we will catch this emoji_* type in extension.js, so finally it will be without network icon, just flag as icon

    1. add new file ~/.local/share/gnome-shell/extensions/Vitals@CoreCoding.com/helpers/utils.js
    /*
      Conv ISO country code ('US', 'TH', 'KZ', 'RU', 'UK', 'UA' etc) to Emoji Flag
    */
    export function getFlagEmoji(countryCode) {
        if (!countryCode || countryCode.length !== 2) return '🌐';
    
        const codePoints = countryCode
            .toUpperCase()
            .split('')
            .map(char => 127397 + char.charCodeAt(0));
    
        return String.fromCodePoint(...codePoints);
    }
    
    
    1. edit ~/.local/share/gnome-shell/extensions/Vitals@CoreCoding.com/sensors.js
      2.1) add in the import block
    import * as HelpersUtils from './helpers/utils.js';
    

    2.2) replace/update _refreshIPAddress(callback) block

        _refreshIPAddress(callback) {
            // let url = 'https://ipv4.corecoding.com';
            // let url = 'http://ip-api.com/json';
            let url = 'https://api4.my-ip.io/v2/ip.json';
    
            // check IP address
            new FileModule.File(url).read().then(contents => {
                try{
                    let obj = JSON.parse(contents);
    
                    if (obj.success === true) {
                        let ip = obj.ip
                        let countryCode = obj.country.code;
                        let flag = HelpersUtils.getFlagEmoji(countryCode);
                        let ipWithFlag = flag + ' ' + ip;
                        this._returnValue(callback, 'Public IP', ipWithFlag, 'network', 'string');
                    } else {
                        this._returnValue(callback, 'Public IP', '🏳️ API Error', 'network', 'string');
                    }
                } catch (e) {
                    this._returnValue(callback, 'Public IP', '⛓️‍💥 Parse Error', 'network', 'string');
                }
            }).catch(err => {
                  this._returnValue(callback, 'Public IP', '📡 Offline', 'network', 'string');
            });
        }
    
    Image
  2. azadevlab commented on Feb 25, 2026

    @azadevlab

    @corecoding hi, would it be possible to include the country code in the API response as well, due nowadays it returns?-

    [azadevlab@arch ~]$ G_MESSAGES_DEBUG=libsoup gjs -m ~/000/ipv4.corecoding.com.js 
    {"IPv4":"171.6.236.51"}
    [azadevlab@arch ~]$ 
    
    
  3. corecoding commented on Feb 26, 2026

    @corecoding
    Owner

    I could probably add country to my API - but I am curious, is the api4.my-ip.io API free?

  4. azadevlab commented on Feb 26, 2026

    @azadevlab

    I've just googled and used 2 first links
    not sure that's good idea, what if 2k-3k Vitals' users will turn on Public IP and owner of site will decide to turn it off or monetize?

    https://www.my-ip.io/faq

    How much do you cost?

    MyIP is free to use, you don't need an account you can just start calling us.1

    Are there any limitations?

    You are free to call the service multiple times a day, however we do rate-limit and will throttle you if you call us too often. Under such circumstances you will recieve a 429 response code and are expected to backoff for a while. We also reserve the right to ban you for an unspecified amount of time if you abuse our services.2

    still waiting @aymnart feedback - @aymnart could you test firstly (please check message above - there is code blocks) due having colored flag in top panel make my eyes bloody, maybe it's useless and no need 🙏

  5. aymnart commented on Feb 27, 2026

    @aymnart
    Author

    Image

    WORKS FINE
    I think it will be useful for people who use VPN a lot and switch between countries, this will provide a visual indicator, instead of just an IP address.
    I think it would be better remove the icon and just replace it with flag,
    Image
    and also, when I switch countries, the IP wont update, until I manually refresh:

    Screencast.From.2026-02-27.13-49-44.mp4

    @azadevlab thanks for this.

  6. azadevlab commented on Apr 1, 2026

    @azadevlab

    @corecoding hi Chris, would it be possible to add the country code to the IP response? like == {"IPv4":"171.6.237.217", "countryCode":"TH"}.
    it seems the response handled by Apache, you could delegate this to your reverse proxy HAProxy/NGINX for better performance and easier geo-ip integration

     ~  curl -i -H "User-Agent: gvfs/" https://ipv4.corecoding.com                     ✔ 
    HTTP/1.1 200 OK
    Date: Wed, 01 Apr 2026 17:00:58 GMT
    Server: Apache/2.4.52
    Vary: Accept-Encoding
    X-Frame-Options: sameorigin
    Transfer-Encoding: chunked
    Content-Type: text/html; charset=UTF-8
    
    {"IPv4":"171.6.237.217"}%                                                                                                                                                                                             ~                     
    

    dudes https://github.com/sapics/ip-location-db provide go-ip databases on GitHub that doesn't require a maxmind login, they provide both mmdb and csv formats
    also you could change the endpoint like to https://corecoding.com/myip (so in the future reverse proxy also will return ipv6)

    just imho, ofc up to you

  7. corecoding commented on Apr 5, 2026

    @corecoding
    Owner

    @azadevlab Thank you for the reminder. Country code has been added.

  8. corecoding commented on Apr 5, 2026

    @corecoding
    Owner

    @azadevlab Please note that if it doesn't detect your country, an empty value will be sent.

  9. azadevlab commented on Apr 6, 2026

    @azadevlab

    @azadevlab Thank you for the reminder. Country code has been added.

    Chris, fantastic, thank you so much

  10. corecoding commented on Apr 8, 2026

    @corecoding
    Owner

    Can we try replacing the cloud icon next to Public IP with the country flag? instead of putting it between Public IP and the IP itself.

  11. azadevlab commented on Apr 11, 2026

    @azadevlab

    @corecoding @aymnart here you're :)

    #537

    @aymnart Aymen, please could you close Issue once MR will be approved and merged? 🙏

  12. aymnart commented on Apr 11, 2026

    @aymnart
    Author

    @azadevlab thank you so mush for this, issue closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions