Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request import costum themes for router #94

Open
s-b-repo opened this issue Nov 4, 2024 · 3 comments
Open

Request import costum themes for router #94

s-b-repo opened this issue Nov 4, 2024 · 3 comments

Comments

@s-b-repo
Copy link

s-b-repo commented Nov 4, 2024

can we have a menu for a costum them for our router which we can import or just change router background like how a wallpaper is changed we upload it to a library filled with wallpaper

@s-b-repo
Copy link
Author

s-b-repo commented Nov 4, 2024

The main CSS file for the I2P web console is typically found in the webapps/console/themes directory within your I2P installation folder. Look for files like main.css or default.css (or a similarly named file in your theme folder).

Modify the Background:

Open the CSS file in a text editor.
Find the section controlling the body element or the background of the main interface. Look for CSS classes or IDs named #content, .background, or similar.
Add or modify the background property:

css

body {
background-color: #YOUR_COLOR_CODE; /* For solid colors /
background-image: url('path/to/your-image.jpg'); /
For a background image /
background-size: cover; /
Make the image cover the entire background */
}

@s-b-repo
Copy link
Author

s-b-repo commented Nov 4, 2024

import os
import re
import sys

class I2PBackgroundChanger:
def init(self, i2p_path):
self.i2p_path = i2p_path
self.css_file_path = os.path.join(i2p_path, "webapps", "console", "themes", "default", "main.css")

def check_css_file(self):
    if not os.path.isfile(self.css_file_path):
        print(f"CSS file not found at {self.css_file_path}")
        sys.exit(1)

def set_background_color(self, color):
    """Set a solid background color."""
    self.check_css_file()
    with open(self.css_file_path, 'r+') as file:
        content = file.read()
        # Replace or add a background-color in the body or main container style
        new_content = re.sub(r'background(-color)?:.*?;', f'background-color: {color};', content)
        file.seek(0)
        file.write(new_content)
        file.truncate()
    print(f"Background color changed to {color}")

def set_background_image(self, image_path):
    """Set a background image."""
    self.check_css_file()
    if not os.path.isfile(image_path):
        print(f"Image file not found at {image_path}")
        sys.exit(1)
    
    # Convert image path to a relative path within the I2P directory
    rel_image_path = os.path.relpath(image_path, self.i2p_path)
    
    with open(self.css_file_path, 'r+') as file:
        content = file.read()
        # Replace or add a background-image in the body or main container style
        new_content = re.sub(
            r'background(-image)?:.*?;',
            f'background-image: url(\'{rel_image_path}\'); background-size: cover;',
            content
        )
        file.seek(0)
        file.write(new_content)
        file.truncate()
    print(f"Background image changed to {image_path}")

def reset_background(self):
    """Reset to the original background settings."""
    self.check_css_file()
    with open(self.css_file_path, 'r+') as file:
        content = file.read()
        # Remove custom background settings
        new_content = re.sub(r'background(-color)?:.*?;|background-image:.*?;', '', content)
        file.seek(0)
        file.write(new_content)
        file.truncate()
    print("Background reset to default")

def run(self):
    if len(sys.argv) < 2:
        print("Usage:")
        print("  Set color: python i2p_background_changer.py color #YOUR_COLOR_CODE")
        print("  Set image: python i2p_background_changer.py image path/to/your-image.jpg")
        print("  Reset: python i2p_background_changer.py reset")
        sys.exit(1)

    command = sys.argv[1].lower()
    if command == "color":
        color = sys.argv[2] if len(sys.argv) > 2 else "#FFFFFF"
        self.set_background_color(color)
    elif command == "image":
        image_path = sys.argv[2] if len(sys.argv) > 2 else ""
        self.set_background_image(image_path)
    elif command == "reset":
        self.reset_background()
    else:
        print(f"Unknown command: {command}")
        sys.exit(1)

Run the script if it's executed directly

if name == "main":
# Replace 'your_i2p_installation_path' with the actual I2P path on your system
i2p_path = "your_i2p_installation_path"
changer = I2PBackgroundChanger(i2p_path)
changer.run()

@zzzi2p
Copy link
Contributor

zzzi2p commented Nov 29, 2024

We are not going to do this, but you may wish to try the i2p plus fork https://github.com/I2PPlus/i2pplus that has more themes and I believe makes it easier to install your own theme. If you need help, ask in IRC #saltr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants