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

Set Theme from Command Line #958

Open
manaphychu opened this issue Nov 18, 2024 · 52 comments
Open

Set Theme from Command Line #958

manaphychu opened this issue Nov 18, 2024 · 52 comments

Comments

@manaphychu
Copy link

Is there a way to set the RetroBar Theme from the Command Line? For Example: Luna, is something I want to set it as

@ghost
Copy link

ghost commented Nov 18, 2024

Is there a way to set the RetroBar Theme from the Command Line? For Example: Luna, is something I want to set it as

not build-in to RetroBar, but here is a bat file that does exactly that.

save as ChangeRetroBarTheme.bat and run as administrator (check that the retrobar path is correct on the end of the file)

Example of theme name to type if you want to change to win xp blue:

Windows XP Blue

dont include " " in the theme name or .xaml, just the name of the theme.

@echo off
setlocal enabledelayedexpansion

:: Define the path to the settings.json file
set "file_path=%LocalAppData%\RetroBar\settings.json"

:: Check if the file exists
if not exist "%file_path%" (
    echo File not found: %file_path%
    pause
    exit /b
)

:: Prompt the user for the new theme value
set /p new_theme=Enter the new theme: 

:: Create a temporary file
set "temp_file=%file_path%.new"

:: Process the file line by line
(
    for /f "usebackq delims=" %%i in ("%file_path%") do (
        set "line=%%i"
        echo !line! | findstr /c:"\"Theme\"" >nul
        if not errorlevel 1 (
            echo       "Theme": "!new_theme!",
        ) else (
            echo !line!
        )
    )
) > "%temp_file%"

:: Replace the original file with the updated one
move /y "%temp_file%" "%file_path%" >nul

echo Theme updated successfully to "%new_theme%".

:: Kill the RetroBar process
taskkill /f /im RetroBar.exe >nul 2>&1

:: Start RetroBar again
start "" "C:\Program Files\RetroBar\RetroBar.exe"

echo RetroBar has been restarted.
pause


@ghost
Copy link

ghost commented Nov 18, 2024

and if you want the bat to not ask user for theme name, do this:

change

set /p new_theme=Enter the new theme:

to

set "new_theme=Windows XP Blue"

and remove the "pause" from the end of the bat

@manaphychu
Copy link
Author

trying to get this to work but won't

@ghost
Copy link

ghost commented Nov 18, 2024

trying to get this to work but won't

what is the theme file name?

Luna.xaml or what?

@manaphychu
Copy link
Author

I am trying to change this to XP Blue but won't change theme, any other way to make it work with the BAT File for changing the entire theme of Windows?

@manaphychu
Copy link
Author

trying to get this to work but won't

what is the theme file name?

Luna.xaml or what?

@echo off
setlocal enabledelayedexpansion

:: Define the path to the settings.json file
set "file_path=%LocalAppData%\RetroBar\settings.json"

:: Check if the file exists
if not exist "%file_path%" (
echo File not found: %file_path%
pause
exit /b
)

:: Prompt the user for the new theme value
set new_theme=Windows XP Blue

:: Create a temporary file
set "temp_file=%file_path%.new"

:: Process the file line by line
(
for /f "usebackq delims=" %%i in ("%file_path%") do (
set "line=%%i"
echo !line! | findstr /c:""Theme"" >nul
if not errorlevel 1 (
echo "Theme": "!new_theme!",
) else (
echo !line!
)
)
) > "%temp_file%"

:: Replace the original file with the updated one
move /y "%temp_file%" "%file_path%" >nul

echo Theme updated successfully to "%new_theme%".

:: Kill the RetroBar process
taskkill /f /im RetroBar.exe >nul 2>&1

:: Start RetroBar again
start C:\Classic\RetroBar\RetroBar.exe

echo RetroBar has been restarted.

here's the command

@ghost
Copy link

ghost commented Nov 18, 2024

the command you used for set windows xp blue is wrong,

try this one: (see the difference?)

@echo off
setlocal enabledelayedexpansion

set "new_theme=Windows XP Blue"
set "file_path=%LocalAppData%\RetroBar\settings.json"


if not exist "%file_path%" (
    echo File not found: %file_path%
    pause
    exit /b
)

set "temp_file=%file_path%.new"

(
    for /f "usebackq delims=" %%i in ("%file_path%") do (
        set "line=%%i"
        echo !line! | findstr /c:"\"Theme\"" >nul
        if not errorlevel 1 (
            echo       "Theme": "!new_theme!",
        ) else (
            echo !line!
        )
    )
) > "%temp_file%"

move /y "%temp_file%" "%file_path%" >nul

taskkill /f /im RetroBar.exe
start "" "C:\Program Files\RetroBar\RetroBar.exe"


@manaphychu
Copy link
Author

still nope...

the command you used for set windows xp blue is wrong,

try this one: (see the difference?)

@echo off
setlocal enabledelayedexpansion

set "new_theme=Windows XP Blue"
set "file_path=%LocalAppData%\RetroBar\settings.json"


if not exist "%file_path%" (
    echo File not found: %file_path%
    pause
    exit /b
)

set "temp_file=%file_path%.new"

(
    for /f "usebackq delims=" %%i in ("%file_path%") do (
        set "line=%%i"
        echo !line! | findstr /c:"\"Theme\"" >nul
        if not errorlevel 1 (
            echo       "Theme": "!new_theme!",
        ) else (
            echo !line!
        )
    )
) > "%temp_file%"

move /y "%temp_file%" "%file_path%" >nul

taskkill /f /im RetroBar.exe
start "" "C:\Program Files\RetroBar\RetroBar.exe"

still nope

@ghost
Copy link

ghost commented Nov 18, 2024

what is the path to retrobar.exe?

this bat works fine on my end

@manaphychu
Copy link
Author

what is the path to retrobar.exe?

this bat works fine on my end

for me: C:\Classic\RetroBar

@ghost
Copy link

ghost commented Nov 18, 2024

C:\Classic\RetroBar

@echo off
setlocal enabledelayedexpansion

set "new_theme=Windows XP Blue"
set "file_path=%LocalAppData%\RetroBar\settings.json"

if not exist "%file_path%" (
    echo File not found: %file_path%
    pause
    exit /b
)

set "temp_file=%file_path%.new"

(
    for /f "usebackq delims=" %%i in ("%file_path%") do (
        set "line=%%i"
        echo !line! | findstr /c:"\"Theme\"" >nul
        if not errorlevel 1 (
            echo       "Theme": "!new_theme!",
        ) else (
            echo !line!
        )
    )
) > "%temp_file%"

move /y "%temp_file%" "%file_path%" >nul
taskkill /f /im RetroBar.exe
start "" "C:\Classic\RetroBar\RetroBar.exe"


test:
1

@manaphychu
Copy link
Author

C:\Classic\RetroBar

@echo off
setlocal enabledelayedexpansion

set "new_theme=Windows XP Blue"
set "file_path=%LocalAppData%\RetroBar\settings.json"

if not exist "%file_path%" (
    echo File not found: %file_path%
    pause
    exit /b
)

set "temp_file=%file_path%.new"

(
    for /f "usebackq delims=" %%i in ("%file_path%") do (
        set "line=%%i"
        echo !line! | findstr /c:"\"Theme\"" >nul
        if not errorlevel 1 (
            echo       "Theme": "!new_theme!",
        ) else (
            echo !line!
        )
    )
) > "%temp_file%"

move /y "%temp_file%" "%file_path%" >nul
taskkill /f /im RetroBar.exe
start "" "C:\Classic\RetroBar\RetroBar.exe"

test: 1

not working for me?!

@ghost
Copy link

ghost commented Nov 18, 2024

you need to run it as administrator:

shift+rightclick the bat file and select "run as administrator"

@manaphychu
Copy link
Author

still no sign of theme changing

@ghost
Copy link

ghost commented Nov 18, 2024

still no sign of theme changing

can you save it to c:\classic\changetheme.bat

then hit windowsbutton+r and type "cmd"

now type "c:\classic\changetheme.bat"
take a screenshot and send here so we can see if it gives some kind of error.

@manaphychu
Copy link
Author

image
ughhh... it won't, god dammit windows

@ghost
Copy link

ghost commented Nov 18, 2024

ok so there is a permission error, you dont have admin rights apparently

@manaphychu
Copy link
Author

manaphychu commented Nov 18, 2024

ok so there is a permission error, you dont have admin rights apparently

how do I make it not reject the change? without admin permissions?

@ghost
Copy link

ghost commented Nov 18, 2024

type this to cmd

net user %username%

does it say "administrators" at the bottom?

@manaphychu
Copy link
Author

yeah

@ghost
Copy link

ghost commented Nov 18, 2024

well try closing retrobar manually and then run the bat when retrobar is not running

if this works, then something is blocking the taskkill command, might be antivirus protecting you?

@manaphychu
Copy link
Author

idk?

@ghost
Copy link

ghost commented Nov 18, 2024

test running the bat when retrobar is closed and i might have a possible fix for you, first we need to find the problem

@manaphychu
Copy link
Author

because it won't change theme when open

@ghost
Copy link

ghost commented Nov 18, 2024

because it won't change theme when open

it will change, but on your case it does not. so try this then, it closes retrobar first:

@echo off
setlocal enabledelayedexpansion

set "new_theme=Windows XP Blue"
set "file_path=%LocalAppData%\RetroBar\settings.json"

taskkill /f /im RetroBar.exe
if not exist "%file_path%" (
    exit /b
)
set "temp_file=%file_path%.new"
(
    for /f "usebackq delims=" %%i in ("%file_path%") do (
        set "line=%%i"
        echo !line! | findstr /c:"\"Theme\"" >nul
        if not errorlevel 1 (
            echo       "Theme": "!new_theme!",
        ) else (
            echo !line!
        )
    )
) > "%temp_file%"
move /y "%temp_file%" "%file_path%" >nul
start "" "C:\Classic\RetroBar\RetroBar.exe"

@manaphychu
Copy link
Author

uuuughhh! nope.... it doesn't...

@ghost
Copy link

ghost commented Nov 18, 2024

type this to cmd and take a screenshot:

tasklist /fi "imagename eq RetroBar.exe"

@manaphychu
Copy link
Author

where do I put it in?

@manaphychu
Copy link
Author

my PID for RetroBar is 3696

@ghost
Copy link

ghost commented Nov 18, 2024

my PID for RetroBar is 3696

take screenshot so i can see if these give error, type exactly what i typed:
1

@manaphychu
Copy link
Author

manaphychu commented Nov 18, 2024

The process cannot access the file because it is being used by another process.... :(
TWO TIMES!
image

@ghost
Copy link

ghost commented Nov 18, 2024

The process cannot access the file because it is being used by another process.... :(

do you have something else also running? like OpenShell or similar? that might be the reason this is failing

another possibilities:
no administrator access
antivirus is blocking taskkill command

@manaphychu
Copy link
Author

no admin access... :(

@manaphychu
Copy link
Author

Dremin needs to make a new feature where you can set the theme from one single command line without restart

@manaphychu
Copy link
Author

image
because I was working on a modification of the Windows eXPerience Extras Pack Theme Changer for my Windows 11 Customization Pack

@ghost
Copy link

ghost commented Nov 18, 2024

well i will make it for you, maybe an hour and it is done? probably, lets see (no promises)

give me some details what you want from the cmd command?

RetroBar.exe -ChangeTheme "Windows Xp Blue"

is this good?

@manaphychu
Copy link
Author

lemme try

@ghost
Copy link

ghost commented Nov 18, 2024

I mean i can make a feature for it and the make a pull request so you can download a retrobar with cmd functionality, that is not a problem, i can do it if you want something like that.

@manaphychu
Copy link
Author

sure

@ghost
Copy link

ghost commented Nov 18, 2024

ok, i will post it here when it is done.

@manaphychu
Copy link
Author

thx

@ghost
Copy link

ghost commented Nov 18, 2024

yeah i have it working now, i am just cleaning code, mayb 10 minutes and you can test

@ghost
Copy link

ghost commented Nov 18, 2024

here you go:

#959

@ghost
Copy link

ghost commented Nov 18, 2024

i tested and it works fine on my system.
details on the pull request.

@manaphychu
Copy link
Author

nope, download failed, something went wrong.

@manaphychu
Copy link
Author

it detected a threat... what a pain in the ass for me..

@ghost
Copy link

ghost commented Nov 18, 2024

you can compile it yourself too if you have visual studio

@ghost
Copy link

ghost commented Nov 18, 2024

it is no trojan for sure, i just compiled it myself
https://www.mediafire.com/file/bvmkene8a8kut56/RetroBar-cmd-net6.0-windows.rar

@manaphychu
Copy link
Author

download failed again... 😭

@manaphychu
Copy link
Author

WHY WINDOWS DEFENDER?!!?

@ghost
Copy link

ghost commented Nov 18, 2024

Well this is all I can do for you at the moment :D
RetroBar now has the cmd command feature, so I hope you get your windows defender to co-operate with you.

Best of luck! :)

@manaphychu
Copy link
Author

yeah,, they just detected RB as a false positive

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

1 participant